Control message handling

This is a discussion on Control message handling within the Windows Programming forums, part of the Platform Specific Boards category; Ok, I have created a button control during runtime, and I want to know how I can handle it. I ...

First, GetDlgItem() only works for Dialogs. (Duh.) Dialogs use WM_INITDIALOG message. So, are you using a dialog or a window? The above appears to be a window. If it's a dialog, I'd look up WM_INITDIALOG, and see I might perhaps create those controls in a resource file.

Regardless of it is a window or a dialog, if the button is being created, all is good. To get a button "click", you can process the WM_COMMAND message. And bunch of controls will sent this whenever something happens to them, including buttons. The WM_COMMAND message contains a notification code, a handle to the window (button) that generated the message, and (possibly) the id of the control. (Usually in dialogs, where you know the ID and not the handle) Look up WM_COMMAND and BN_CLICKED, that should give what you want.

Remember that as you have declared the HWNDs for the conrols as non static in the callback that they will not retian their values after the WM_CREATE msg is processed.
This means you will have to use the controls ID#, not HWND to find if that control has been used.

You read my mind >.>

That was one of my many questions I planned on asking in the future,thanks, When I was closing through my menu, I could hear my button making a message box and closing quickly... But everything is working perfectly since I changed my button to a static =D