nbsp;if(hCallWnd[index]==hWnd){
if(HotKey[index]==cKey&&HotKeyMask[index]==cMask){
hCallWnd[index]=NULL;
HotKey[index]=0;
HotKeyMask[index]=0;
bRemoved=TRUE;
KeyCount--;
break;
}
}
}
return bRemoved;
}
3. 钩子函数如下:
LRESULT CALLBACK KeyboardProc(int nCode,WPARAM wParam,LPARAM lParam)
{
BOOL bProcessed=FALSE;
if(HC_ACTION==nCode)
{
if((lParam&0xc0000000)==0xc0000000){// 有键松开
switch(wParam)
{
case VK_MENU:
MaskBits&=~ALTBIT;
break;
case VK_CONTROL:
MaskBits&=~CTRLBIT;
break;
case VK_SHIFT:
MaskBits&=~SHIFTBIT;
break;
default: //judge the key and send message
break;
}
for(int index=0;index<MAX_KEY;index++){
if(hCallWnd[index]==NULL)
continue;
if(IsWindow(hCallWnd[index])&&(HotKey[index]==wParam)&&(HotKeyMask[index]==MaskBits)){
SendMessage(hCallWnd[index],WM_HOTKEY,wParam,WM_KEYUP);
bProcessed=TRUE;
}
}
}