Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SetWindowPos doesn't change the maximized state

We're using SetWindowPos to well, set the position of a window and it's working great.

The only qualm I have with it, is that if the window we're moving is maximized, then it will move and become the proper size, however, it will still believe itself to be in the maximized state, and continue showing the "Restore" button.

Is there a way, once SetWindowPos is called, to tell that window to replace the Maximize button?

Also note: These windows aren't necessarily Windows Forms windows, but could be applications such as Explorer, Chrome, Firefox, Notepad, etc.

Here's our call to SetWindowPos:

PInvokeMethods.SetWindowPos( hwnd, 0, position.Left + x, position.Top + y, position.Width, position.Height, PInvokeMethods.SWP_NoZOrder | PInvokeMethods.SWP_NoActivate);

like image 568
DTI-Matt Avatar asked Oct 27 '25 19:10

DTI-Matt


1 Answers

If you want to set state and position in a single call, there is the SetWindowPlacement API.

First of all you would call GetWindowPlacement to fill out a WINDOWPLACEMENT struct with the current values. Then you would modify the showCmd and rcNormalPosition members. And then you would fire the modified struct back at SetWindowPlacement.

like image 152
David Heffernan Avatar answered Oct 29 '25 07:10

David Heffernan