Recent

Author Topic: TForm.SessionProperties Left,Top don't work with poDefault, poDefaultPosOnly,...  (Read 1255 times)

RolfW

  • New Member
  • *
  • Posts: 24
Left and Top are stored in the sessionproperties file, but are not applied to the form at runtime. Requires TForm.Position=poDesigned, poDefaultSizeOnly,poMainFormCenter or poOwnerFormCenter. The TForm.Width property is always applied to the form from the session storage.
This is not documented in the help file and I'm assuming this is a bug since the session property Width works with all position settings.
I've tried in vain to find where the sessionproperty values are applied to the form. Perhaps someone can help me.
TForm.SessionProperties is the published FSessionProperties string of TControl. There are no relevant occurences of FSessionPproperties or GetPropertyList in the LCL source code (*.pas, *.pp, *.p, *.inc files) show where it is applied to the form.

Thanks,
Rolf

Bart

  • Hero Member
  • *****
  • Posts: 5497
    • Bart en Mariska's Webstek
If Position is poDefault of poDefaultPosOnly the OS determines where the form will be shown.
If you want to decide where the form is shown (Top/Left), use poDesigned.

Bart

RolfW

  • New Member
  • *
  • Posts: 24
Sorry, Bart.
This isn't user friendly.
1. It's not documented.
2. Width in SessionProperties works even with Position=poDefaultSizeOnly
3. If I add Top and Left to SessionProperties I expect that this will override the Positon setting.

Do you know where it is done in the code?

Thanks,
Rolf

Bart

  • Hero Member
  • *****
  • Posts: 5497
    • Bart en Mariska's Webstek
AFAIK the behaviour of TForm.Position is well documented.
Position can override Top/Left, this is how it has always been.
The sessionproperties just stores all the forms porperties, it has nothing to do with how the Position property behaves.

Bart

Handoko

  • Hero Member
  • *****
  • Posts: 5386
  • My goal: build my own game engine using Lazarus
I didn't use SessionProperties. Maybe it is not what you want, but you can try:
https://forum.lazarus.freepascal.org/index.php/topic,66776.msg512749.html#msg512749

dsiders

  • Hero Member
  • *****
  • Posts: 1327
3. If I add Top and Left to SessionProperties I expect that this will override the Positon setting.

Then you need to add Position to the SessionProperties (using the desired value) as well.

Do you know where it is done in the code?

SessionProperties are saved when the form instance is close or freed. They get restored when the form instance is created. It's actually performed by OnCreate and OnDestroy handlers found in the TFormPropertyStorage base class. They're added to (and removed from) the form instance when the property storage class is created and destroyed.

Sounds like this blurb needs to be added to the docs for TformPropertyStorage, and mentioned in TForm.SessionProperties.
Preview the next Lazarus documentation release at: https://dsiders.gitlab.io/lazdocsnext

 

TinyPortal © 2005-2018