Im creating my own button like control. My question is when you create the window, does windows save the text you pass as the lpWindowName? Or am i going to have to allocate memory for it myself and copy the text to it?
I'm pretty sure you have to handle it yourself. WM_CREATE, WM_SETTEXT,
WM_GETTEXT :). At least that's how I have handled the stuff.
WM_GETTEXT :). At least that's how I have handled the stuff.
thanks
No, Windows will save it away in the window structure. You don't need to keep the text after you call CreateWindow or CreateWindowEx.
To get it, use GetWindowText.
You have two choices: allocate a buffer at WM_CREATE, save a pointer to it in GWL_USERDATA, and ask GetWindowText to put the window name in the buffer. At every WM_PAINT you just need to refer to this buffer, but remember to dealloc the buffer at WM_DESTROY.
Or, allocate a LOCAL buffer at WM_PAINT, and at each WM_PAINT just use GetWindowText to put it into the LOCAL buffer. Slightly less fast maybe, but easier to do.
You have two choices: allocate a buffer at WM_CREATE, save a pointer to it in GWL_USERDATA, and ask GetWindowText to put the window name in the buffer. At every WM_PAINT you just need to refer to this buffer, but remember to dealloc the buffer at WM_DESTROY.
Or, allocate a LOCAL buffer at WM_PAINT, and at each WM_PAINT just use GetWindowText to put it into the LOCAL buffer. Slightly less fast maybe, but easier to do.