Global Mouse Hook和SetWindowPos [英] Global Mouse Hook and SetWindowPos

查看:59
本文介绍了Global Mouse Hook和SetWindowPos的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好。


现在,我正在尝试开发桌面应用以重新定位窗口。


我使用Global Mouse Hook和SetWindowPos来重置窗口的位置。


首先我通过SetWindowHookEx安装了LowLevel Mouse Hook(WH_MOUSE_LL,MouseProc,Null,Null)


MouseProc是回调函数。


它的声明是这样的:  LRESULT CALLBACK MouseProc(int code,WPARAM wParam,LPARAM lParam)


wParam here


与鼠标消息有关。


我在WM_LBUTTONUP中使用了SetWindowPos()函数。只需单击鼠标左键就可以正常工作。 


但是当我将鼠标移动和鼠标左键单击组合时,它的效果很奇怪。


问题是窗口捕捉到原始位置,这是在执行SetWindowPos()之前的位置。


我认为这取决于系统窗口的拖动,我不确定。 / p>

请建议您的想法。


感谢您的帮助。

Cris

解决方案

你好。


你怎么称呼SetWindowPos()?在移动窗口时或之后调用SetWindowPos()时,x / y值是否会发生变化?


请提供更多信息。


问候,Guido


Hi, Everyone.

Now, I'm trying to develop the desktop app to re-position the window.

I used Global Mouse Hook and SetWindowPos to reset the position of the window.

First I installed LowLevel Mouse Hook by SetWindowHookEx(WH_MOUSE_LL, MouseProc, Null,Null)

MouseProc is callback function.

Its declaration is like this:   LRESULT CALLBACK MouseProc( int code, WPARAM wParam, LPARAM lParam)

wParam here

is about Mouse Message.

I've used SetWindowPos() function in WM_LBUTTONUP. It works well when I simply click the mouse left button. 

But When I combined mouse move and mouse left button click, it works strange.

The problem is that the window snap into original position which is position before SetWindowPos() was executed.

I think that it's up to system window dragging and I'm not sure.

Please suggest your ideas about it.

Thanks for your kind help.
Cris

解决方案

Hello.

How do you call SetWindowPos()? Do the x/y values change when you call SetWindowPos() when or after moving the window?

Please give us more information.

Regards, Guido


这篇关于Global Mouse Hook和SetWindowPos的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆