用Visual C++实现屏幕抓程序(4)
#define CTRLBIT 0x04
#define ALTBIT 0x02
#define SHIFTBIT 0x01
#pragma data_seg("shareddata")
HHOOK hHook =NULL;
UINT nHookCount =0;
static UCHAR HotKey[MAX_KEY] = {0}; //hotkey
static UCHAR HotKeyMask[MAX_KEY] = {0}; //flag for hotkey, value is VK_CONTRL or VK_NEMU or VK_SHIFT
static HWND hCallWnd[MAX_KEY] = {0}; //window associated with hotkey
static int KeyCount =0;
static UCHAR MaskBits =0; //00000 Ctrl Alt Shift
#pragma data_seg()
HINSTANCE hins;
void VerifyWindow();
BEGIN_MESSAGE_MAP(CHookApp, CWinApp)
//{{AFX_MSG_MAP(CHookApp)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
CHookApp::CHookApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
CHookApp theApp;
LRESULT CALLBACK KeyboardProc(int nCode,WPARAM wParam,LPARAM lParam)
{
BOOL bProcessed=FALSE;
if(HC_ACTION==nCode)
{
if((lParam&0xc0000000)==0xc0000000){// Key up
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 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;
}
}
}
else if((lParam&0xc000ffff)==1){ //Key down
switch(wParam)
{
case VK_MENU:
- 上一篇:VC++中实现以复杂线条为基础的图形绘图
- 下一篇:通过例程分析状态条用法