evc 热键注册

hotkey

 

A hot key is a key combination that generates a WM_HOTKEY message. The message is routed to a particular window, regardless of whether or not that window is the current foreground window or focus window.

You define a hot key by calling the RegisterHotKey function and specifying the combination of keys that generates the WM_HOTKEY message, the handle of the window to receive the message, and the identifier of the hot key. When the user presses the hot key, the system places a WM_HOTKEY message in the message queue of the thread that created the specified window. The wParam parameter of the message contains the identifier of the hot key. Before the application terminates, it should use the UnregisterHotKey function to destroy the hot key.

 

F1热键注册

2010096 部分代码
memset(szValue,0,sizeof(szValue));
dwKey
=GetIniValue("F1",szType,"",szValue,sizeof(szValue),szFile);
if(dwKey>0)
{
bOk
= RegisterHotKey(hWnd, 1, 0, VK_F1);
if(!bOk)
{
::MessageBox(
0, _T("RegisterHotKey Error"), _T(""), 0);
return false;
}
else
{
bOk1
= true;
}
memset(szF1,
0,sizeof(szF1));
strcpy(szF1, szValue);
}

 

 

星号、井号的热键注册 

2010096 部分代码
memset(szValue,0,sizeof(szValue));
//读ini配置档,获取*键对应的配置
dwKey=GetIniValue("*",szType,"",szValue,sizeof(szValue),szFile);
if(dwKey>0)
{
bOk
= RegisterHotKey(hWnd, 11, 0, 106);//注册*键
if(!bOk)
{
::MessageBox(
0, _T("RegisterHotKey Error"), _T(""), 0);
return false;
}
else
{
bOk11
= true;
}
memset(szF11,
0,sizeof(szF11));
strcpy(szF11, szValue);
}

memset(szValue,
0,sizeof(szValue));
dwKey
=GetIniValue("#",szType,"",szValue,sizeof(szValue),szFile);
if(dwKey>0)
{
bOk
= RegisterHotKey(hWnd, 12, MOD_SHIFT, 51);//注册#键 shift+'3'
if(!bOk)
{
::MessageBox(
0, _T("RegisterHotKey Error"), _T(""), 0);
return false;
}
else
{
bOk12
= true;
}
memset(szF12,
0,sizeof(szF12));
strcpy(szF12, szValue);
}

 

posted @ 2010-09-07 09:02  牧羊的小牧童  阅读(214)  评论(0编辑  收藏  举报