Shouldn't buffer now have the text from the edit box? It doesn't.Code:PTSTR buffer; int length; ... length = GetWindowTextLength(hwndEdit); GetWindowText(hwndEdit, buffer, length +1);
Shouldn't buffer now have the text from the edit box? It doesn't.Code:PTSTR buffer; int length; ... length = GetWindowTextLength(hwndEdit); GetWindowText(hwndEdit, buffer, length +1);
No, you have to allocate memory to hold the string, eg. 1which runs the risk of truncation if the text is longer. Or, eg. 2Code:TCHAR buffer[256]; GetWindowText(hwnd,buffer,255);Code:TCHAR *buffer; int length; length=GetWindowTextLength(hwnd); buffer=new TCHAR[length+1]; /*or use malloc in C */ GetWindowText(hwnd,buffer,length); /*and when you're done, free up the memory*/ delete[] buffer; /*or use free if memory allocated with malloc */
CProgramming FAQ
Caution: this person may be a carrier of the misinformation virus.
It works
Thanks again to everyone that helped me with this, I couldn't have done it with you.