[Lazarus] TMenu(Item) AutoLineReduction: help needed from Delphi users/owners

Werner Pamler werner.pamler at freenet.de
Thu Sep 12 15:06:47 CEST 2024


This is with Delphi XE 11.3 (Community Edition) (do you know that the 
Community Edition is free? Its license conditions (non-commercial or 
commercial if total revenues < 5000 $) certainly apply to FPC/Laz 
development):

> Question 1.
>
> Given the following Menu:
> TopLevel
> - ItemA
> - Separator
> - ItemB
> - Separator
> - ItemC
>
> Given that TopLevelA.GetAutoLineRedction will return True.
TMenuItem.GetAutoLineReduction is protected. I used subclassing to 
verify that it is true
> Now I do: ItemB.Visible := False
> Then I do: TopLevel.RethinkLines.
>
> This will hide one of the 2 now consective separators (in our 
> implementation it hides the second one).
> So it will show as
> TopLevel
> - ItemA
> - Separator
> - ItemC
>
> I suppose this is how Delphi works as well.
Yes.
> Now I do: ItemB.Visible := True
> Then I do: TopLevel.RethinkLines.
>
> I implemented RethinkLines such that it will now restore the separator 
> after ItemB, because this makes sense to me.
> But I have absolutely no idea if Delphi does this as well.
Restores ItemB and the separator
> Question 2
>
> Given the following Menu:
> TopLevel
> - Separator
> - ItemA
> - Separator
> - Separator
> - ItemB
> - Separator
> - Separator
> - ItemC
> - Separator
>
> And TopLevel.AutoLineReduction starts out as maManual, so all 
> separators are visible.
Yes
> Now I do: TopLevel.AutoLineReduction := maAutomatic
> Then I do: TopLevel.RethinkLines
>
> It will now show as:
> - ItemA
> - Separator
> - ItemB
> - Separator
> - ItemC
>
> This is Delphi compatible AFAIK.
Hmmm... I have this code in a button. When I click on this button 
immediately after running the project, you are right, there are only 
single separators. But when I first open the menu to verify the double 
separators and then click on the button, nothing changes, and the double 
separators remain...
> Now I do: TopLevel.AutoLineReduction := maManual
> Then I do: TopLevel.RethinkLines
>
> I implemented RethinkLines so that this will set all separators Visble 
> property to True again.
> This makes sense to me, as it performs the opposite action of maAutomatic.
> But again, I'm not really sure this is what Delphi does in this case.

I added a second button for the maManual code. Running the program and 
clicking both buttons in the order of your description, nothing changes 
- there are still single separators.


More information about the lazarus mailing list