winapi - Why do WM_APPCOMMAND LPARAM have to be multiplied by 65536 -
i trying control master volume. able succesfully this:
hwnd mainhwnd = createwindow(szwindowclass, _t("window-noit-ext-profilist"), 0, 0, 0, 0, 0, hwnd_message, null, wcex.hinstance, null); if (!mainhwnd) { messagebox(null, _t("profilist: call createwindow failed!"), _t("window-noit-ext-profilist"), null); return 1; } sendmessage(mainhwnd, wm_appcommand, (wparam)mainhwnd, (lparam)(appcommand_volume_mute * 65536)); // mute sendmessage(mainhwnd, wm_appcommand, (wparam)mainhwnd, (lparam)(appcommand_volume_down * 65536)); // vol down sendmessage(mainhwnd, wm_appcommand, (wparam)mainhwnd, (lparam)(appcommand_volume_up * 65536)); // vol
why have multiply 65,536? docs not state this. if don't multiply, doesn't work.
for wm_appcommand, lparam
parameter packs 3 values in single integer.
the lower 16bit word, dwkeys
, indicates whether various virtual keys down.
the higher 16bit word packs 2 fields: highest 4 bits, udevice
, specifies input device generating input event. lower 12 bits, cmd
, contains application command.
multiplying 65536 same bit shifting 16 bits left (because 65536 = 0x10000 in hexadecimal). so, when send message appcommand_volume_up * 65536
, specifying cmd
appcommand_volume_up
, , udevice
, dwkeys
both zero.
Comments
Post a Comment