Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 202
Ov3r1oad Avatar asked Nov 02 '22 13:11

Ov3r1oad


1 Answers

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.

like image 185
user221458 Avatar answered Nov 10 '22 00:11

user221458