Lazarus

Installation => Mac OS X => Topic started by: yazzdi on September 03, 2019, 04:52:34 pm

Title: All components in a TGroupbox are lower than expected when ported from Delphi
Post by: yazzdi on September 03, 2019, 04:52:34 pm
The compatibility of Mac LFM Lazarus forms when porting from Delphi is amazing, and thank you to the Lazarus developers for this.

One issue I have is with TGroupBox. If I port a Delphi windows form to Mac LFM/Lazarus, any items in the TGroupbox will be about 20 pixels lower than in Delphi windows, making some of them out if the tGroupbox entirely.

What’s the reason for this, and what’s the recommended fix. Of course I can edit the LFM file and change all the Y locations of the components in every group box, but maybe there’s a better solution than that. For example, maybe someone has a routine to fix a TGroupbox that has this problem.
Title: Re: All components in a TGroupbox are lower than expected when ported from Delphi
Post by: wp on September 03, 2019, 05:23:13 pm
This is because Delphi calculates coordinates in TPanel, TGroupbox, TRadioGroup the client rect to be identical with the outer bounds of the controls. In Lazarus, however, the ClientRect is the inner region which is available for the controls. As a test: add a TEdit to a TGroupbox, set its Left and Top to 0. In Delphi the edit will cover the caption of the groupbox while in Lazarus the caption is uncovered and the edit is below the caption - see screenshots.

When you use the Delphi-to-Lazarus converter (menu "Tools" > "Delphi Conversion") coordinate offsets are automatically corrected by default (see section "Coordinate offsets" in the converter dialog).
Title: Re: All components in a TGroupbox are lower than expected when ported from Delphi
Post by: yazzdi on September 04, 2019, 12:43:56 am
That’s very cool. Will save lots of time. Does that also strip out unrecognized lines ina. Delphi dfm - those can cause strange compiler or run time errors. Never been sure why Lazarus doesn’t just skip over an unrecognized line rather than shutting down the whole show.
Title: Re: All components in a TGroupbox are lower than expected when ported from Delphi
Post by: wp on September 04, 2019, 12:53:50 am
Read this: https://wiki.freepascal.org/Delphi_Converter_in_Lazarus