How properly hook WM_COMMAND

后端 未结 1 1899
北海茫月
北海茫月 2021-01-16 19:50

I\'m trying to hook a button click in a mfc window.And I used WM_COMMAND and WM_NOTIFY.For test, if the button is clicked, the hook must create a messagebox. The problem is

1条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-16 20:38

    The lParam for a WH_CALLWNDPROC hook is of type CWPSTRUCT. Your CallWndProc should look like this:

    // ...
    const CWPSTRUCT& cwps = *(CWPSTRUCT*)lParam;
    switch ( cwps.message ) {
    case WM_COMMAND:
        MessageBox( ... );
        break;
    // ...
    

    0 讨论(0)
提交回复
热议问题