用钩子啊
SetWindowsHookEx(WH_MOUSE,MouseHookCallBack,
GetModuleHandleFromInstance, GetCurrentThreadID);
function MouseHookCallBack(Code: integer; Msg: WPARAM;
MouseHook: LPARAM): LRESULT; stdcall;看看Msg,MouseHook参数里面的内容应该有你要的位置信息
SetWindowsHookEx(WH_MOUSE,MouseHookCallBack,
GetModuleHandleFromInstance, GetCurrentThreadID);
function MouseHookCallBack(Code: integer; Msg: WPARAM;
MouseHook: LPARAM): LRESULT; stdcall;看看Msg,MouseHook参数里面的内容应该有你要的位置信息
SetCapture(GetDesktopWindow),然后在主程序种截取WM_LBUTTONDOWN,但这样得不到鼠标在窗体外的消息!
你这样好象只能得到鼠标在本程序窗口单击时的坐标,在其它程序窗口上的单击时坐标无法得到!
var CurPos:TPoint; //全屏幕下的鼠标坐标
......
if (Msg.LParam=WM_LBUTTONDOWN) then //响应鼠标左键消息
GetCursorPos(CurPos); //获得鼠标坐标
还是行不通的,难道除了用钩子就没办法了吗???
建议还是用mouse hook解决,如需要的话,我可以把我做的一个屏幕取色的程序寄给你参考一下
Point:tpoint;
begin
getcursorpos(point)
x:=point.x;
y:=point.y;
end;x y 为鼠标单击后的坐标
非常感谢,我很想看一下您的屏幕取色的程序!
我的信箱是: [email protected]
谢谢您!