There are several reasons why when maximizing or minimizing a window and trying to get the values via FormResize or WindowState events doesn't work to try and get the correct wsNormal values after, I force a wsNormal prior to closing the window.
There is an issue with the GTK version:
http://bugs.freepascal.org/view.php?id=8576This code, in the FormClose event, is what I am using to get the values, but it forces me to do a wsNormal if the window is maximized or minimized:
if (WindowState = wsMaximized) or (WindowState = wsMinimized) then
begin
if WindowState = wsMaximized then
cMaximized := 1;
WindowState := wsNormal;
{$IFDEF LGLGTK2}
cHeight := RestoredHeight;
cWidth := RestoredWidth;
cTop := RestoredTop;
cLeft := RestoredLeft;
{$ELSE}
cHeight := Height;
cWidth := Width;
cTop := Top;
cLeft := Left;
{$ENDIF}
endThe GTK version can't grabbed the Height, etc., it needs the Restored values. How odd.
Some reasons for doing it my way are:
1) If the app opens with the windows maximized, there is no Restored values, they are zero. (For first time run height, etc., are set in the code or can be read from the config file prior to running the app).
2) If you move the window and then maximize or minimize, and never restore the window, the Restored values will never be had. (Moving a window around on the screen never calls FormResize or WindowState events).
There are a few more. All this for just trying to get the value to store in a state config file for when the next time the app is opened your windows will be in the same spot (or maximized).