A RegisterHotKey system API is used to set a hotkey for a program. Of course, some APIs are relatively simple to use, but you also need to pay attention to some places, so please refer to the relevant documentation of MSDN before using the API. This article only provides an example code for setting the program hotkey:
1. Call RegisterHotKey in OnInitDialog to set the hotkey
RegisterHotKey (m_hWnd, 1001, MOD_CONTROL | MOD_SHIFT,'s ');
2. Declare the hotkey handler in the header file of the dialog box.
Afx_msg LRESULT OnHotKey (WPARAM wParam, LPARAM lParam );
3. Implement the hotkey processing function in the implementation file of the dialog box.
LRESULT CTestDlg: OnHotKey (WPARAM wParam, LPARAM lParam)
{
If (wParam = 1001)
CWnd: SetForegroundWindow ();
Return 0;
}
4. ing hotkey messages and processing functions
ON_MESSAGE (WM_HOTKEY, OnHotKey)