Relationship between pretranslatemessage and windowproc,

Source: Internet
Author: User

Http://topic.csdn.net/u/20070828/17/a4283e65-6176-4673-8559-5e822667b4d3.html

 

1:
In MFC, pretranslatemessage is getmessage (...) next-level operation of the function, that is, getmessage (...) after obtaining a message from a message queue, it is processed by pretranslatemessage (). If false is returned, it is processed by translatemessage and dispatchmessage (entering windowproc );
If sendmessage is used, the message is directly delivered to windowproc for processing. Therefore, getmessage does not obtain the sendmessage message. Of course, pretranslatemessage will not be called.
If postmessage is used, the message enters the message queue and is obtained by getmessage. pretranslatemessage has the opportunity to process the message.

2:
Sendmessage must be differentiated from the environment. If it is the sendmessage window of the current thread, windowproc is called directly without passing through any message loop or putting it into the message queue. Therefore, neither getmessage nor pretranslatemessage can be captured; if sendmessage is sent to a window of another thread or other processes, the message enters the message queue. getmessage and pretranslatemessage can capture this message .??? Realy ???

Summary:
Not all messages pass through pretranslatemessage ()
For example, you can use sendmessage () to send messages to this form. directly enter windowproc.
For example, none of my pagepower pretranslatemessage () messages can be received !!!
After trying, The pretranslatemessage () in maindlg cannot receive any message. It seems that it is because of the problem of using MFC to expand the DLL in Win32.

Because a thread has only one message queue, there is only one translatemessage () and dispatch. In general, there are many windowproc, and one window corresponds to one windowproc.
Not all messages pass through windowproc ()
For example, if the window contains a subwindow, if you move the mouse over the subwindow, the message is directly distributed to the subwindow windowproc () in pretranslatemessage ().

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.