According to this SO article, you can hook the WM_SETFOCUS
message.
You can get the Control ID by using GetDlgCtrlID
with the hwnd
returned by the hook.
But beware of popping up a MessageBox
, that will change the focus and trigger your hook proc, making it go into a loop!