Win32 message (MSG) processing

Source: Internet
Author: User

In general, the message processing is as follows, TranslateMessage transforms Virtual-keys message to characters message, DispatchMessage dispatches a message to the window program.

// GetMessage The second argument is an HWND, which is set to NULL, // if set to Hwnd,wm_destroy message will not respond to  while (GetMessage (&msg,null,0,0) {     translatemessage (&msg);     Diapatchmessage (&msg);  }

If the window contains a non-modal dialog box, you need to use IsDialogMessage to determine whether the message is for a particular dialog box and handle it.

 while (GetMessage (&msg,null,0,0) {    if(hdlgmodeless==0| | IsDialogMessage (hdlgmodeless,&msg)   {        translatemessage (&msg);        Diapatchmessage (&msg);     }
}

If you are working with shortcut keys, you also need to process the shortcut key messages in advance through TranslateAccelerator.

 while 0 0 ) )    {        if0 | |! IsDialogMessage (hdlgmodeless, &msg))        {            if (! TranslateAccelerator (hwnd, Haccel, &msg))            {                translatemessage (&msg);                DispatchMessage (&msg);     }}}

Win32 message (MSG) processing

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.