简体   繁体   English

纯Win32跨进程子窗口

[英]Pure win32 cross-process child windows

I need to create a transparent overlay window, that goes above another window. 我需要创建一个透明的叠加窗口,该窗口位于另一个窗口之上。 The other window is from another vendor. 另一个窗口来自另一个供应商。 And when the user drags that window mine needs to follow. 当用户拖动窗口时,我的窗口需要跟随。

WS-CHILD seems like a nice idea but it cannot be combined with WS-EX-LAYERED, which I really need (for transparency). WS-CHILD似乎是一个不错的主意,但不能与WS-EX-LAYERED结合使用,这是我真正需要的(透明性)。 But I still can set a parent without using WS-CHILD. 但是我仍然可以在不使用WS-CHILD的情况下设置父级。

Parenting does give my winproc notifications (WM-WINDOWPOSCHANGING), but only after dragging is complete, on mouse-up. 育儿确实会给我winproc通知(WM-WINDOWPOSCHANGING),但只有在拖动完成后,才能将鼠标举起。 To give a nice feeling i need to get those notifications (or for example WM-MOVE) continuosly while dragging. 为了给人一种很好的感觉,我需要在拖动时连续获取这些通知(例如WM-MOVE)

I guess my problem is similar to docking, but the fine docking solution seen fx at CodeProjet uses WS-CHILD. 我猜我的问题类似于对接,但是CodeProjet上fx看到的精细对接解决方案使用WS-CHILD。 ( http://www.codeproject.com/KB/toolbars/dockwnd.aspx ) http://www.codeproject.com/KB/toolbars/dockwnd.aspx

I guess I could use polling but that is not what I am looking for. 我想我可以使用轮询,但这不是我想要的。 Also I could use ::SetWindowsHook(). 我也可以使用:: SetWindowsHook()。 But that is my final resort. 但这是我的最后选择。 I am hoping I have missed something trivial and that somebody can point me in a good direction. 我希望我错过了一些琐碎的事情,并且有人可以指出我的正确方向。

Thanx 感谢名单

I know it is not your preferred solution, but I think you need to use a global mouse hook. 我知道这不是您的首选解决方案,但是我认为您需要使用全局鼠标挂钩。 Pass WH_MOUSE_LL to SetWindowsHookEx() and do nothing in the default case of your low-level mouse proc. 通过WH_MOUSE_LLSetWindowsHookEx()什么也不做你的低级别鼠标PROC的默认情况。 But when you get the WM_WINDOWPOSCHANGING notification, start tracking the mouse movements and making appropriate calls to MoveWindow() or whatever. 但是,当您收到WM_WINDOWPOSCHANGING通知时,就开始跟踪鼠标的移动并适当地调用MoveWindow()或其他方法。

I use a LayeredWindow for that and set the other window as parent. 我为此使用了LayeredWindow并将另一个窗口设置为父窗口。

This is the code I used for that: 这是我用于此的代码:

::SetWindowLong(GetHwnd(), GWL_EXSTYLE, GetWindowLong(GetHwnd(), GWL_EXSTYLE) |WS_EX_LAYERED);
::SetLayeredWindowAttributes(GetHwnd(), RGB(255,0,255), 255, LWA_COLORKEY | LWA_ALPHA);
::SetWindowLongPtr(GetHwnd(),GWLP_HWNDPARENT,(long)GetParentHWND());
::SetWindowPos(hndOtherWindow, hndOverlayWinow, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |SWP_NOACTIVATE);

It works for my purposes. 它适用于我的目的。 There's only one problem left: If my overlaying window loses the focus I want to set the focus, or activate the other window. 只剩下一个问题:如果我的覆盖窗口失去焦点,我想设置焦点,或者激活另一个窗口。 Do you have an idea? 你有想法吗?

How about WM_MOVING message? WM_MOVING消息如何? You may try intercepting this message and move your window accordingly. 您可以尝试拦截此消息并相应地移动窗口。

If you want to know when a window in another process is being moved or sized, you need to install a hook,catch the WM_MOVING and WM_SIZING messages and reflect those messages back to your controller process. 如果您想知道何时在移动或调整另一个进程中的窗口的大小,则需要安装一个钩子,捕获WM_MOVING和WM_SIZING消息并将这些消息反映回您的控制器进程。 Sorry it's not the answer you want! 抱歉,这不是您想要的答案! I don't blame you for wanting to avoid cross process hooks, its a bit of a pain... 我不怪你要避免跨进程钩子,这有点痛苦...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM