[英]How to detect the window has been maximized?
I have my application and third-party application. 我有我的应用程序和第三方应用程序。 And I need to know that the window of third-party application has been maximized.
而且我需要知道第三方应用程序的窗口已最大化。 Is there any way to know it?
有什么办法知道吗?
At first, I thought that I could use my own callback function for handling events of this window. 起初,我以为可以使用自己的回调函数来处理此窗口的事件。
SetWindowLong(hwnd, GWL_WNDPROC, (LONG)WindowProc);
But this function fails with error "Access denied". 但是此功能失败,并显示错误“访问被拒绝”。 And this happens for a reason.
这是有原因的。 It's not very wise to change something in the window that you don't own.
在您不拥有的窗口中更改某些内容不是很明智。
So what should I do? 所以我该怎么做?
You can actually get notified when a window is about to be minimized or maximized. 实际上,当窗口将要最小化或最大化时,您会收到通知。 You will need to use the SetWindowsHook procedure to install and listen to a WH_CBT_Hook.
您将需要使用SetWindowsHook过程来安装和收听WH_CBT_Hook。
Here's the general information about WIndowsHooks: 以下是有关WIndowsHooks的一般信息:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/Windowing/Hooks/AboutHooks.asp http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/Windowing/Hooks/AboutHooks.asp
Here's a thread that shows you how to do something smiliar (for a WH_Mouse_Hook) in VB: 这是一个线程,向您展示如何在VB中做一些更简单的操作(对于WH_Mouse_Hook):
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=581752&SiteID=1 http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=581752&SiteID=1
Hope this helps, 希望这可以帮助,
Use GetWindowPlacement function. 使用GetWindowPlacement函数。 Make sure you set the length member of WINDOWPLACEMENT to sizeof(WINDOWPLACEMENT) before calling GetWindowPlacement.
确保在调用GetWindowPlacement之前将WINDOWPLACEMENT的length成员设置为sizeof(WINDOWPLACEMENT)。
The showCmd field of the returned WINDOWPLACEMENT structure should be equal to SW_MAXIMIZE (3) if the window is maximized. 如果窗口最大化,则返回的WINDOWPLACEMENT结构的showCmd字段应等于SW_MAXIMIZE(3)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.