MFC registers the hotkey for the dialog box and the hotkey for the mfc dialog box.

Source: Internet
Author: User

MFC registers the hotkey for the dialog box and the hotkey for the mfc dialog box.
 

Add the following content to the header file:

//} AFX_MSG
Afx_msg LRESULT OnHotKey (WPARAM wParam, LPARAM lParam); // (this behavior is added)
BEGIN_MESSAGE_MAP (DlgYesNo, CDialog)
// {AFX_MSG_MAP (DlgYesNo)

Add the following to the cpp file:
//} AFX_MSG_MAP

ON_MESSAGE (WM_HOTKEY, OnHotKey) // (this behavior is added)
END_MESSAGE_MAP ()

 

You can also add the WM_HOTKEY message method in the "Class Wizard" to generate the preceding steps.

 

Add the following content to the OnCreat event: (add message response> WM_CREAT)
RegisterHotKey (m_hWnd, 1001, MOD_ALT, 'q ');

Add: (add message response> WM_DESTROY) to the OnDestroy event)
UnregisterHotKey (m_hwnd, 1001 );

Add the message processing function: (paste it in. Note that CHotkeyDlgDlg is changed to its own class)

LRESULT CHotkeyDlgDlg::OnHotKey(WPARAM wParam,LPARAM lParam){    if(wParam == 1001)    {       int nMod = LOWORD(lParam);       int Vk = HIWORD(lParam);       CString str;       str.Format(_T("Mod = %d, Vk = %d"), nMod, Vk);       AfxMessageBox(str);    }    return true;}

 

 

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.