Window消息
当我们选择文件,双击文件和拖动文件时,系统发出什么消息?以下是引用cnfarer在2010-3-14 21:18:18的发言:
鼠标消息
鼠标的9个消息
1.WM_LBUTTONDBLCLK //鼠标左键双击
2.WM_LBUTTONDOWN //鼠标左键按下
3.WM_LBUTTONUP //鼠标左键放开
4.WM_MBUTTONDOWN //鼠标中键按下
5.WM_MBUTTONUP ...
可是下以的DLL代码,调用后双击没反应……鼠标消息
鼠标的9个消息
1.WM_LBUTTONDBLCLK //鼠标左键双击
2.WM_LBUTTONDOWN //鼠标左键按下
3.WM_LBUTTONUP //鼠标左键放开
4.WM_MBUTTONDOWN //鼠标中键按下
5.WM_MBUTTONUP ...
#include<windows.h>
extern "C"__declspec(dllexport) void startHook();
extern "C"__declspec(dllexport) void stopHook();
HHOOK hook=NULL;
LRESULT CALLBACK HookProc(int nCode,WPARAM wparam,LPARAM lparam)
{
MOUSEHOOKSTRUCT *lpmouse=NULL;
if(nCode<0)
return CallNextHookEx(hook,nCode,wparam,lparam);
if(nCode==0)
{
if(WM_LBUTTONDBLCLK==wparam)
{
lpmouse=(MOUSEHOOKSTRUCT *)lparam;
MessageBox(lpmouse->hwnd,"不能双击!","错误!",0);
}
}
return CallNextHookEx(hook,nCode,wparam,lparam);
}
void startHook()
{
hook=SetWindowsHookEx(WH_MOUSE,HookProc,GetModuleHandle("mydll3.dll"),0);
}
void stopHook()
{
if(hook!=NULL)
UnhookWindowsHookEx(hook);
}