[Gambas-user] Settings.Write(MyForm) could it only update pos/size if not maximized?

Bruce Steers bsteers4 at gmail.com
Fri Jan 20 03:38:48 CET 2023


ooh, this is wonderful :)

all my programs now restore maximized if they were saved that way but
de-maximizing them restores their last saved size :)

I think what would be best though is if the windows geometry could be
stored before maximizing and use that data when saving but i'm pretty happy
with the way this simple little mod works.

Even my gambas IDE is doing it :)

blooomin lovely :D

On Fri, 20 Jan 2023 at 01:29, Bruce Steers <bsteers4 at gmail.com> wrote:

>
>
> On Fri, 20 Jan 2023 at 00:28, Bruce Steers <bsteers4 at gmail.com> wrote:
>
>> Hey Ben.
>> I've noticed something if we save a window position on program exit with
>> Settings.Write(Me) (my programs and the gambas ide)
>>
>> if the window is maximized the geometry saves as the full window size,
>> the screen and adds a var to the .Settings variant[] to specify if it's
>> maximized.
>>
>> On Reloading a previously maximized form and a Settings.Read(Me) call it
>> restores the windows full screen size then sets Maximized = True.
>>
>> Then if you un-maximize the window is still full screen just not
>> maximized.
>>
>> Wouldn't it be better or could we have an option to save the last known
>> window dimensions if maximized?
>>
>> Does that make sense? and would it even work?
>> So if window was maximized on closing then on the next load it would
>> restore the non-maximized size, then maximize the window, then upon
>> un-maximizing the window should shrink to the last saved un-maximized size.
>>
>> It seems pointless (and i think my idea is a better method) to save the
>> windows size if maximized considering the Settings.class will set
>> Form.Maximized = True anyway.
>>
>> I feel that previous window position/size was data i wish i hadn't lost :(
>>
>> ;)
>>
>> Respects
>> BruceS
>>
>
>
> I modded line 420 in Settings.class
> it was...
>     aVal = [X, Y, W, H, S, If(hWindow.Maximized, 1, 0)]
>
> I changed to...
>
>   If hWindow.Maximized And If Me[sKey &/ "Geometry"]
>     aVal = Me[sKey &/ "Geometry"]
>     aVal[4] = S
>     aVal[5] = 1
>   Else
>     aVal = [X, Y, W, H, S, If(hWindow.Maximized, 1, 0)]
>   Endif
> https://gitlab.com/bsteers4/gambas/-/tree/settings-saveNormalOnly
>
> Seems to work a treat.
> (i'm probably missing something though, maybe a flaw if S has changed?)
>
> Respects
> BruceS
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20230120/8aea9be6/attachment.htm>


More information about the User mailing list