c++winapi

Win32 get the HWND of the object which sent the event from the Window WndProc


I'm unsure how to get the HWND of the control that sent the event from the WndProc of the parent Window. The reason I need the HWND is because some metadata about the control is stored in one of its user-defined slots (information about wrapper function pointers, and such) however after some fiddling it seems I need to filter and dispatch events from the parent window.

ie: the user clicks a button, but the event is sent to WM_COMMAND of the buttons parent Window. How can I get the HWND of the button from here?


Solution

  • For WM_COMMAND messages send from child controls the child HWND is sent in lParam.