case WM_COMMAND:
{
switch(LOWORD(wparam))
{
case BN_CLICKED:
{
PostQuitMessage(0);
return(0);
break;
}
default:break;
}
}
Trouble being notified which button was pressed.
I made a window with a few buttons on it. I set it up so when a button is pressed, the window closes. I want to know how to tell which button was pressed. The Quit (hQuitButton) button in pertictular. This is what I have:
lParam will have a handle to the button in it
The loword of wParam contains the ID of the control - not the notification code (i.e. BN_CLICKED) that''s in the hiword.
BN_CLICKED
I haven''t used this much, but that''s what both the MSDN and Petzold say.
Magmai Kai Holmlor
- Not For Rent
The loword of wParam contains the ID of the control - not the notification code (i.e. BN_CLICKED) that''s in the hiword.
BN_CLICKED
I haven''t used this much, but that''s what both the MSDN and Petzold say.
Magmai Kai Holmlor
- Not For Rent
So, I do this?:
I says: error C2446: ''=='' : no conversion from ''long'' to ''struct HWND__ *''
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
case WM_COMMAND: { switch(LOWORD(wparam)) { case BN_CLICKED: { if(hQuitButton == lparam) { PostQuitMessage(0); return 0; break; } break; default:break; } }
I says: error C2446: ''=='' : no conversion from ''long'' to ''struct HWND__ *''
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
Well, make it happy and cast it - in this case it's what you need to do:
Magmai Kai Holmlor
- Not For Rent
Edited by - Magmai Kai Holmlor on November 7, 2001 1:52:07 AM
switch(HIWORD(wparam)){case BN_CLICKED:if(hQuitButton == (HWND)lparam)}
Magmai Kai Holmlor
- Not For Rent
Edited by - Magmai Kai Holmlor on November 7, 2001 1:52:07 AM
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement