Recent

Author Topic: All components in a TGroupbox are lower than expected when ported from Delphi  (Read 345 times)

yazzdi

  • New Member
  • *
  • Posts: 16
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.

wp

  • Hero Member
  • *****
  • Posts: 6491
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).
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

yazzdi

  • New Member
  • *
  • Posts: 16
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.

wp

  • Hero Member
  • *****
  • Posts: 6491
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10