About WM_COMMAND messages and windows simple data types
The basic data types of windows (and CPUs) are: BYTE (unsigned 8-bit), WORD (unsigned 16-bit) and DWORD (double word, unsigned 32-bit)
you can store two BYTEs in one WORD, and two WORDs in one DWORD
in memory, a DWORD is the same as
Code:
BYTE BYTE BYTE BYTE
\ / \ /
WORD WORD
\ /
DWORD
to combine two BYTEs to a WORD, you use the MAKEWORD macro
to combine two WORDs to a DWORD, use the MAKELONG macro
:P
to extract a WORD from a DWORD, use the HIWORD and LOWORD macros
for bytes, use the HIBYTE and LOBYTE macros
:confused:
the two components are called low and high:rolleyes:
the WM_COMMAND mesage has this structure:
wParam (a DWORD despite it's name):
LOWORD = ID of sender, this can be a menu option or a control
if menu option, it is the thing you are looking for.
if control, you probably don't need it.
HIWORD = notification code
this is important if the message comes from a control, because it contains the real information. e.g. if a button was clicked, HIWORD(wParam) has the value BN_CLICKED
for a menu, this is less important, it is 0 if the menu option was selected and 1 if the corresponding accelerator key was pressed
lParam contains the HWND of the control, or NULL if the sender is a menu.
I hope that clears something up