Register the hotkey operation in MFC -- Take chotkeyctrl as an Example

Source: Internet
Author: User

Use chotkeyctrl to add a hotkey for the program to hide the display on the main interface, similar to the boss key. The specific operations are as follows:


1. Obtain the set hotkey and use registerhotkey to register the hotkey. The Code is as follows:

// Obtain the hot key value chotkeyctrl * photk = (chotkeyctrl *) getdlgitem (idc_hotkey1); Word vkey, fsmoderfiers; photk-> gethotkey (vkey, fsmoderfiers ); // register the hotkey bool r = registerhotkey (m_hwnd, 111, fsmoderfiers, vkey); // judge the registration result


Second, add the wm_hotkey message to receive the response hotkey message. The Code is as follows:

Void ctestdlg: onhotkey (uint nhotkeyid, uint nkey1, uint nkey2) {// if multiple hotkeys are registered, you can use the switch statement to process static bool flag = false; if (nhotkeyid = 111) {// hide the display window showwindow (FLAG); flag =! Flag;} cdialog: onhotkey (nhotkeyid, nkey1, nkey2 );}


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.