Windows消息(事件) [英] Windows Messages (events)

查看:64
本文介绍了Windows消息(事件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使一个窗口始终位于另一个窗口的前面.
顶部的窗口将Always On Top属性设置为True.当后面的窗口失去焦点时,我将使用
禁用始终在最前面
Win32.SetWindowPos(getChatHandle(pid),(IntPtr)Win32.SpecialWindowHandles.HWND_NOTOPMOST,0,0,0,0,Win32.SetWindowPosFlags.SWP_NOMOVE | Win32.SetWindowPosFlags.SWP_NOSIZE | Win32.SetWindowPosFlags.ACT 我也尝试用HWND_BOTTOM替换,这倾向于隐藏应该位于顶部的窗口.
HWND_NOTOPMOST将窗口留在顶部,不需要在新选择的窗口顶部.

我认为WM_INACTIVE可以解决上述问题.

原始问题:

我发现了WM_ACTIVATE消息,它接收到wParam来指示它是活动的(还是鼠标活动的)还是不活动的.

问题发生在WA_INACTIVE上,未按预期触发.

如果在任务栏中单击另一个窗口,或者在窗口标题部分上单击鼠标,就会发生这种情况.

如果用户单击另一个窗口客户端区域,系统按钮之一(最小化,最大化,关闭),或者单击时没有松开,则不会发生这种情况.

PS:我考虑过使用更改后的样式,因为当它失去活动的窗口绘制样式时,它确实会触发,但是不幸的是,我还没有发现哪个标志确定了该样式.

谢谢.

I am attempting to make one window stay in front of another window always.
The window on top has the Always On Top attribute set to True. When the window behind loses focus I am disabling the Always on top using

Win32.SetWindowPos(getChatHandle(pid), (IntPtr)Win32.SpecialWindowHandles.HWND_NOTOPMOST, 0, 0, 0, 0, Win32.SetWindowPosFlags.SWP_NOMOVE | Win32.SetWindowPosFlags.SWP_NOSIZE | Win32.SetWindowPosFlags.SWP_NOACTIVATE);
I tried replacing with the HWND_BOTTOM also, that has the tendency of hiding the window that should be on top.
The HWND_NOTOPMOST leaves the window on top, on top of the newly selected window witch is not desired.

I think WM_INACTIVE works fine the problem originated as described above.

Original question:

I have found the WM_ACTIVATE message, it receives wParam to indicate if it is active(also for mouse) or inactive.

The problem occurs on WA_INACTIVE it doesn''t trigger as expected.

It occurs if another window is clicked in the taskbar, or a simple click on the window title section.

It doesn''t occur if the user clicks another window client area, one of the system buttons (minimize, maximize, close), or clicks without releasing.

PS: I considered using the style changed, for when it loses the active window drawing style, that does trigger, unfortunately I haven''t found out which flag determines that.

Thank you.

推荐答案

,您可以改用消息WM_NCACTIVATE.如果您更改窗口样式,则应调用SetWindowPos(hwnd,0,0,0,0,0, SWP_NOZORDER| SWP_NOSIZE| SWP_NOMOVE| SWP_FRAMECHANGED);.
问候.
you can use the message WM_NCACTIVATE instead. If you change your window style you should call SetWindowPos(hwnd,0,0,0,0,0, SWP_NOZORDER| SWP_NOSIZE| SWP_NOMOVE| SWP_FRAMECHANGED);.
Regards.


我设法两次使用SetWindowPos找到了解决方案,
-首先在HWND_BOTTOM上设置窗口
秒,以将窗口设置在HWND_TOP或我正在使用的窗口上方,具体取决于GetForegroundWindow
似乎工作正常,需要更多调整.
I managed to find the solution, using SetWindowPos twice,
-first to set the window on HWND_BOTTOM
-second to set the window on HWND_TOP or above the window which I''m working with, depending on the GetForegroundWindow
Seems to work fine, needs more tunning.


这篇关于Windows消息(事件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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