Setting Control IDs
Hi guys, I am having trouble with my WM_COMMAND message, I want it to trap my menu items clicks, but I am not sure how to set my static controls ID so that I can trap the different IDs in the lParam of the WM_COMMAND message.
Thanks in advance for any help
What your looking for isnt in the LPARAM, it's in the WPARAM.
Are your menus resource created or function created?
Assuming you use AppendMenu() to help create your menu...
You would recive the command...
AppendMenu( hSubMenu, // Handle to the submenu.
MF_STRING, // The type of menu commponent
ID_STUFF_GO, // The id of your menu commponent.
"&Go" // The name of your commponent.
switch( LOWORD( wParam ) )
// Do your menu command here!
MessageBox( hwnd, "\"Go\" was clicked!", "Woo Ho!", MB_OK );
Is there any other way of doing it, my menu wont actually be a menu bar it is a GUI menu, using static controls for the main menu of a game that I am creating
Sorry to be a pain
My button is setup like this :
and I need to be able to catch the click events of that so i need a way of giving it an ID or anything else that would mean I could catch it in WM_COMMAND
void Setup_Button (Window* window, Button & button, char const * caption, int x, int y, int width, int height, int bitmap, DWORD exStyle)
button._style = WS_CHILD | WS_VISIBLE | SS_BITMAP | SS_NOTIFY;
button._caption = caption;
button._exStyle = exStyle;
button._x = x; // horizontal position of Button
button._y = y; // vertical position od Button
button._width = width; // Button width
button._height = height; // Button height
button._hWndParent = window->hWnd; // handle to parent or owner Button
button._data = 0; // pointer to Button-creation data
button.image = LoadBitmap(window->init.application->hInstance, (LPCSTR)bitmap);
HWND Create_Button (Window* window, Button & button)
button.hwnd = ::CreateWindowEx (
if (button.hwnd == 0)
LRESULT lResult = SendMessage(button.hwnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)button.image);
Right... you see that NULL in the CreateWindowEx call above? Try changing that to the value of an ID you'd like to catch. You may need to cast it to HMENU.