Set program hotkeys in VC

Source: Internet
Author: User

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)

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.