LRESULT __declspec(dllexport) CALLBACK CallWndProc(
int code,// hook code
WPARAM wParam,// undefined
LPARAM lParam // address of structure with message data (CWPSTRUCT)
)
{
LPCWPSTRUCT pCwpStruct = LPCWPSTRUCT(lParam);
if (HC_ACTION == code) 

HWND hWnd = pCwpStruct->hwnd ;
UINT nMsg = pCwpStruct->message ;
WPARAM wp = pCwpStruct->wParam ;
int nID = LOWORD ( wp ) ;
if ( nMsg == WM_COMMAND && nID == IDOK )
{
MessageBox ( hWnd , "kokokok" , "HOOK" , MB_OK ) ;
return 0 ;
}
}
return CallNextHookEx(g_hCallWndProc,code,wParam,lParam);

解决方案 »

  1.   

    消息hook 按钮点击消息等,WM_LBUTTONDOWN..然后直接return
      

  2.   

    楼上我能改OnOK就不hook了,其他程序的对话框啊
      

  3.   

    你hook里,判断(hwnd==按钮句柄 && msg==WM_XXX),处理指定按钮的指定的消息,然后直接return 0.
      

  4.   

    return 0 了啊,不管用啊
      

  5.   

    return 1;
    试一试!
    return 0; 好像会继续把消息传下去!
      

  6.   

    摆脱高手们帮忙试下啊,上面的方法都不行
    MSDN:
    Return Values
    If nCode is less than zero, the hook procedure must return the value returned by CallNextHookEx. If nCode is greater than or equal to zero, it is highly recommended that you call CallNextHookEx and return the value it returns; otherwise, other applications that have installed WH_CALLWNDPROC hooks will not receive hook notifications and may behave incorrectly as a result. If the hook procedure does not call CallNextHookEx, the return value should be zero. 
      

  7.   

    return什么都不管用,WH_KEYBOARD类型钩子倒是可以用return 1来阻止消息继续传递,WH_CALLWNDPROC/WH_CALLWNDPROCRET/WH_MSGFILTER都没找到方法阻止
      

  8.   

    WH_GETMESSAGEReturn Values
    If nCode is less than zero, the hook procedure must return the value returned by CallNextHookEx. If nCode is greater than or equal to zero, it is highly recommended that you call CallNextHookEx and return the value it returns; otherwise, other applications that have installed WH_GETMESSAGE hooks will not receive hook notifications and may behave incorrectly as a result. If the hook procedure does not call CallNextHookEx, the return value should be zero. Res
    The GetMsgProc hook procedure can examine or modify the message. After the hook procedure returns control to the system, theGetMessage function returns the message, along with any modifications, to the application that originally called it. 可以通过将消息值设为WM_NULL来吃掉消息,不是靠返回值