Hotkey Control Sample CHOTKEYCTRL

xiaoxiao2021-03-06  37

I don't know how to use the HotKey control on the surface of the control plane. At that time, I didn't understand the MSDN English help. I didn't have the help of the control. I finished the hardware today. I wrote this code I wrote. , See if it is so simple, :)

============================================================================================================================================================================================================= =======================================================================================================================================================

Bool CMYHOTKEYDLG :: OnNitDialog () {cdialog :: OnInddialog (); set bi (m_hicon, true); // set big icon seticon; // set small icon // Get NotePad path char path [100]; GetWindowsDirectory; strcat (path, "notepad.exe"); m_path.format ("% s", path); Updatedata (false); // You can also set the hotkey rule, the following code limit can only be used Ctrl form hotkey //m_hotkey.setrules (HKCOMB_C ,HOTKEYF_CONTROL); // Set the default thermal key m_hotkey.SETHOTKEY (VK_F2, MOD_CONTROL); return true;}

/ / Install hotkey code void cmyhotKeydlg :: Onsetup () {// get hot key virtual code and flag Word Virtualcode, modifiers; m_hotkey.get productKey (Virtualcode, Modifiers); // Set hot key ID = 100 if (! Registerhotkey (this-> m_hwnd, 100, modifiers, virtualcode)) MessageBox ("Hotkey Setup error, possibly!"); Else MessageBox ("Hotkey Setting success!");}

Void CMYHOTKEYDLG :: OnhotKey (WPARAM WPARAM, LPARAM LPARAM) {// Custom Message WM_HOTKEY IF (WPARAM == 100) {Updatedata (TRUE); // Execute Shellexecute (this-> m_hwnd, "open", m_path, null, NULL, SW_SHOW);}}

Require word definition message WM_HOTKEY

Begin_Message_Map (CMYHOTKEYDLG, CDIALOG) // {{AFX_MSG_MAP (CMYHOTKEYDLG) ............................ on_message (wm_hotkey, onhotkey) //// }} AFX_MSG_MAPEND_MESSAGE_MAP ()

// generated message mapp functions // {{AFX_MSG (CMYHOTKEYDLG) ................ AFX_MSG Void Onhotkey (WPARAM WPARAM, LPARAM LPARAM); //}} AFX_MSG is simple to use Example, code demonstrates how to set various hot keys to open the Windows Notepad program!

转载请注明原文地址:https://www.9cbs.com/read-55639.html

New Post(0)