I have hooked WM_SETFOCUS message by calling API
hhookCallWndProc = SetWindowsHookEx(WH_CALLWNDPROC, HookCallWndProc, hInst, threadID);
Hook Procedure is
extern "C" LRESULT _declspec(dllexport) __stdcall CALLBACK HookCallWndProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if (nCode == HC_ACTION) {
CWPSTRUCT* info = (CWPSTRUCT*) lParam;
if(info->message == WM_SETFOCUS )
{
if(info->hwnd == hControl)
{
MessageBox(NULL,L"Focus on control",L"Focus",MB_OK);
}
}
}
return CallNextHookEx(hhookCallWndProc , nCode, wParam, lParam);
}
Now when I focus on the control, this hook procedure is getting called . MessageBox is shown. But as soon as I click on Ok , another message pops up.
Messages keep on popping up infinitely. I want to get messagebox only once whenever I focus on control, but here I am getting messages infinitely.
Anything I am doing wrong.