Reputation: 1125
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?
Upvotes: 7
Views: 7142
Reputation: 736
Use GetWindowPlacement function. Make sure you set the length member of WINDOWPLACEMENT to sizeof(WINDOWPLACEMENT) before calling GetWindowPlacement.
The showCmd field of the returned WINDOWPLACEMENT structure should be equal to SW_MAXIMIZE (3) if the window is maximized.
Upvotes: 7
Reputation:
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.
Here's the general information about WIndowsHooks:
Here's a thread that shows you how to do something smiliar (for a WH_Mouse_Hook) in VB:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=581752&SiteID=1
Hope this helps,
Upvotes: 2