0
SendMessage(hEditControl, WM_GETTEXT,255,(LPARAM)editbuffer);
 GetWindowText(hTextControl, (LPWSTR)allText,GetWindowTextLength(hTextControl));

//allText = appendStrings((char*)TEXT("whatever"), (char*)TEXT("whatever"));
SetWindowText(hTextControl, (LPCWSTR)allText);

//where editbuffer and allText are defined as:

    static WCHAR*       editbuffer;
    static WCHAR*       allText;

where hEditControl is the handle to an edit control and hTextControl is a handle to a static text control. I want to take the data from the edit control and append it to the static control text. But my program crashes at the getwindowtext function and I can't figure out why. Even without the appendstring function, it still crashes. By the way, this code is in my message processing function for the main window.

Iowa15
  • 3,027
  • 6
  • 28
  • 35

1 Answers1

3

Your two buffers have no space allocated for them, so anything being written to them is undefined behaviour. You need to allocate memory, preferably static for editBuffer and dynamic for allText, since C++ doesn't support VLAs.

chris
  • 60,560
  • 13
  • 143
  • 205