CHotKeyCtrl控件

CHotKeyCtrl控件

获取热键数据

注册热键

响应热键事件

 

一、CHotKeyCtrl控件

void SetHotKey( WORD wVirtualKeyCode, WORD wModifiers );

二、获取热键数据

DWORD GetHotKey( ) const;

void GetHotKey( WORD &wVirtualKeyCode, WORD &wModifiers ) const;

三、注册系统热键

RegisterHotKey

The RegisterHotKey function defines a system-wide hot key.

BOOL RegisterHotKey(

  HWND hWnd,        // window to receive hot-key notification

  int id,           // identifier of hot key

  UINT fsModifiers, // key-modifier flags

  UINT vk            // virtual-key code

);

四、响应热键事件

GetParent

WM_HOTKEY

 

 

//获取热键值

         CHotKeyCtrl* phot=(CHotKeyCtrl*)GetDlgItem(IDC_HOTKEY1);

         WORD vkey,fsModifiers;

         phot->GetHotKey(vkey,fsModifiers);

         BOOL r=RegisterHotKey(m_hWnd,111,fsModifiers,vkey);

         TRACE("注册热键==%d \n",r);

         //注册热键功能

 

static bool flag=true;

     if (nHotKeyId==111)

     {

                  GetParent()->ShowWindow(flag);

                   flag=!flag;

     }

         CDialog::OnHotKey(nHotKeyId, nKey1, nKey2);

posted @ 2014-07-13 16:56  紫旭  阅读(384)  评论(0编辑  收藏  举报