I'm creating a simple win32 program using c++, although I think i'm only using c in this app. I need to determine which HWND button was pressed on the app. I've searched msdn reference and it only told me HIWORD is the notification code, and LOWORD is the identifier, for the BN_CLICKED message. I've managed to get as far as determining when a button is clicked, but it only applies for all buttons. All my buttons are created in the WM_CREATE message. This is what i managed to whip up so far:
case: WM_CREATE:
HWND hPlus = CreateWindowEx( 0, L"BUTTON", L"+", WS_CHILD | WS_VISIBLE, 130, 240, 35, 30, hwnd, ( HMENU )IDC_MENU, GetModuleHandle( NULL ), NULL );
HWND hEquals = CreateWindowEx( 0, L"BUTTON", L"=", WS_CHILD | WS_VISIBLE, 170, 205, 65, 65, hwnd, ( HMENU )IDC_MENU, GetModuleHandle( NULL ), NULL );
break;
case WM_COMMAND:
switch( HIWORD( wParam ) )
{
case BN_CLICKED:
MessageBox( hwnd, L"OK", "OK", MB_OK );
break;
}
break;
I've tried comparing hEquals to LOWORD( wParam ) but that gave me an error when compiling. I think I also tried comparing it to HIWORD and LOWORD of lParam as well, which also didn't compile. Now I'm clueless for what to do next.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…