Home > Software engineering >  MFC program how to intercept any messages
MFC program how to intercept any messages

Time:10-29

Is there a function, the application of forward all messages through the interface, I want to in the function to deal with specific messages

CodePudding user response:

If the Windows window message can hook with other network news, of course, also can hook API

CodePudding user response:

The CWnd: : PreTranslateMessage
Override the virtual function can intercept all messages on one of the Windows
CWinApp: : PreTranslateMessage
Override the virtual function can be obtained in the MFC program all the messages on the window

CodePudding user response:

WH_GETMESSAGE via message hook

CodePudding user response:

PeekMessage

CodePudding user response:

reference oyljerry reply: 3/f
through the message hook WH_GETMESSAGE


Could you tell me how to use news hook WH_GETMESSAGE? ClassWizard seems to be no

CodePudding user response:

refer to the second floor CharlesSimonyi response:
CWnd: : PreTranslateMessage
Override the virtual function can intercept all messages on one of the Windows
CWinApp: : PreTranslateMessage
Override the virtual function can intercept the MFC applications on all Windows message


CWinApp: : PreTranslateMessage function cannot intercept all messages, such as the WM_SHOWWINDOW cannot intercept, and WM_PAINT only intercept the message of the Button

CodePudding user response:

The
reference 4 floor schlafenhamster reply:
PeekMessage


I in the main dialog box class to write a while loop, called PeekMessage intercepted messages, don't know why cut less than any news

CodePudding user response:

reference 5 floor yushengl reply:
Quote: refer to the third floor oyljerry response:

Through the message hook WH_GETMESSAGE


Could you tell me how to use news hook WH_GETMESSAGE? ClassWizard seems no

SetWindowsHookEx (... WH_GETMESSAGE,.. );

CodePudding user response:

All the message type hooks in the hook

CodePudding user response:

refer to 6th floor yushengl response:
Quote: refer to the second floor CharlesSimonyi response:

The CWnd: : PreTranslateMessage
Override the virtual function can intercept all messages on one of the Windows
CWinApp: : PreTranslateMessage
Override the virtual function can intercept the MFC applications on all Windows message


CWinApp: : PreTranslateMessage function cannot intercept all messages, such as the WM_SHOWWINDOW cannot intercept, while the WM_PAINT intercepted the news of the Button

To check the MSDN, messages are classified in PreTranslateMessage, through the classification should be able to capture all the message of this process,
  • Related