|
-
Oct 6th, 2004, 09:17 PM
#1
Thread Starter
PowerPoster
Get Text from Edit
Both work, and both seem to return a value, which is more correct:
PHP Code:
//First version -- as you see with one line commented out
//Second version -- include the memory allocation line
//--------------------
//Get text from edit box
//--------------------
char* GetTextFromEdit(HWND hwnd, DWORD ID)
{
char* Text;
int len = GetWindowTextLength( GetDlgItem(hwnd, ID) );
if(len > 0)
{
//Text = (char*)GlobalAlloc(GPTR, len + 1);
GetDlgItemText(hwnd, ID, Text, len + 1);
}
return Text;
}
Problem with the second version, is the function returns the text I need, I do not get a chance to unallocate it...Which is a problem, but it seems without allocating the memory, it works fine when returning to a char*
"From what was there, and was meant to be, but not of that was faded away." - - Steve Damm
"The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm
"When you do things right, people won't be sure if you did anything at all." - - God from Futurama
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|