Convert Delphi form results in invisible/hidden controls lazarus / 10-Designer ---------------------------------------------------------------------- MISV · 2014-09-10 12:14 I have gotten all my compile to code. When opening a Delphi form in lazarus (simply by pressing F12), I also get minimum of warnings of properties i can just ignore. However, one thing that seems o happen sometimes is that nested controls become hidden somehow. Looking in objec inspecor it seems paren stuff is correct, but when looking in the form designer, it looks wrong - see attached screenshot: Any ideas on what is wrong and how I can solve it? ---------------------------------------------------------------------- marcov · 2014-09-10 12:58 Some tips: - I don't see the groupbox either!? You might want to start there. - Try ALT-F12 to edit the form in text, check for out of bound coordinates and width/height - Backup, thenput a panel on the ttabsheet,  set it to alclient, and all its bevels to 0. Then in the structure view (the tree view above the object inspector) drag the groupboxes on the panel. ---------------------------------------------------------------------- MISV · 2014-09-13 07:09 yes, it is muliple nestetd controls that are invisible. However I am currently trying to work though i. I will write again if/when I reach a conclusion on if anyhing in particular causes this issue ---------------------------------------------------------------------- MISV · 2014-09-13 16:36 I am almost sure that there is a rendering problem with TGroupBox. I can save/load the same form in Lazarus/Delphi meaning the coordinates are stored/persisted correctly - just seemingly rendered incorrectly in Lazarus? My form in Delphi Designtime: Looks good Runtime: Looks good My form in Lazarus Designtime: Either controls in groupbox hidden or changed position Runtime: Controls in groupbox changed position I have screenshots here in Lazarus: ---------------------------------------------------------------------- Mike.Cornflake · 2014-09-13 16:47 What happens if you cut the group box onto the clipboard (right click on gbUserInterfacePersistenceV in the Object Inspector and choose cut), then paste it onto the correct Tabsheet in the form? What you're seeing is wierd (no designer grid in your Tabsheet for a start), and I'm thinking the process of removing components and reinserting may uncorrupt whatever has gone wrong... ---------------------------------------------------------------------- howardpc · 2014-09-13 18:50 Can you post the problematic (Delphi) .pas unit and .dfm? It would help people trying to improve the converter tool to have code/data that causes the issues you see. ---------------------------------------------------------------------- MISV · 2014-09-24 20:59 Sorry for my late reply. I have somehing that can reproduce at least one of the problems. One can open this .pas/.dfm in both Lazarus 1.2.4 and Delphi (any vesion I tested 2007, 2010, XE2) and see how they are rendered differently form_program_options2.pas Code: [Select]unit form_program_options2; interface uses   Windows, Messages, SysUtils, Graphics, StdCtrls, ExtCtrls, ComCtrls,   Classes, Controls, Forms, Menus; type   TFormProgramOptions2 = class(TForm)     pnlMain: TPanel;     pgcOptions: TPageControl;     tsVisuals: TTabSheet;     gbUserInterfacePersistenceV: TGroupBox;      chkWindowsVU: TCheckBox;     chkMiscVU: TCheckBox;     pnlMainHelp: TPanel;     btnOK: TButton;     btnCancel: TButton;   private   public   end; implementation {$R *.DFM} end. form_program_options2.dfm Code: [Select]object FormProgramOptions2: TFormProgramOptions2   Left = 654   Top = 426   BorderIcons = [biSystemMenu]   Caption = 'Options'   ClientHeight = 315   ClientWidth = 555   Color = clBtnFace   Constraints.MinHeight = 240   Constraints.MinWidth = 320   Font.Charset = DEFAULT_CHARSET   Font.Color = clWindowText   Font.Height = -11   Font.Name = 'Tahoma'   Font.Style = []   OldCreateOrder = True   Position = poScreenCenter   DesignSize = (     555     315)   PixelsPerInch = 96   TextHeight = 13   object pnlMain: TPanel     Left = 0     Top = 0     Width = 555     Height = 476     Align = alTop     Anchors = [akLeft, akTop, akRight, akBottom]     TabOrder = 0     object pgcOptions: TPageControl       Left = 1       Top = 1       Width = 407       Height = 474       ActivePage = tsVisuals       Align = alClient       TabOrder = 0       object tsVisuals: TTabSheet         Caption = 'Visuals'         DesignSize = (           399           446)         object gbUserInterfacePersistenceV: TGroupBox           Left = 12           Top = 13           Width = 716           Height = 82           Anchors = [akLeft, akTop, akRight]           Caption = 'User interface persistence'           TabOrder = 0           DesignSize = (             716             82)           object chkWindowsVU: TCheckBox             Left = 10             Top = 24             Width = 690             Height = 19             Anchors = [akLeft, akTop, akRight]             Caption = 'Save &windows setup'             Checked = True             State = cbChecked             TabOrder = 0           end           object chkMiscVU: TCheckBox             Left = 10             Top = 50             Width = 690             Height = 19             Anchors = [akLeft, akTop, akRight]             Caption = 'Save &miscellaneous setup'             Checked = True             State = cbChecked             TabOrder = 1           end         end       end     end     object pnlMainHelp: TPanel       Left = 408       Top = 1       Width = 146       Height = 474       Align = alRight       BevelOuter = bvNone       TabOrder = 1     end   end   object btnOK: TButton     Left = 772     Top = 483     Width = 60     Height = 25     Anchors = [akRight, akBottom]     Caption = '&OK'     Default = True     TabOrder = 1   end   object btnCancel: TButton     Left = 837     Top = 483     Width = 60     Height = 25     Anchors = [akRight, akBottom]     Cancel = True     Caption = '&Cancel'     TabOrder = 2   end end There is also a simple explanation I think. In Delphi when a control is is palced on GroupBox, top:=0 means *top* while in Lazarus it means beneath the caption in the groupbox. I think this must be a thing for the converter. Not entiely sure. It is a rather unfortunate difference ---------------------------------------------------------------------- MISV · 2014-10-06 09:15 Bump? Can anyone think of a workaround for the issue I have been able to create a working example for? Maybe a property or something? Or when the form is a DFM file automatically adjust? If possible it would be great to maintain base compatiblity between DELPHI and Lazarus for common components. It is hard to move big projects in one go, so I think it would ease transition if there was a solution for this. (That siad, I acknowledge it is in the big scheme of things a minor issue and may take unproprotional amount of time to fix) ---------------------------------------------------------------------- ChrisF · 2014-10-06 10:18 What kind of differences are supposed to be seen between Lazarus and Delphi with your last sample ? I mean, which ones are important to you ? Testing your sample (with an old Delphi7 version), I can see a few differences indeed, but not that much: the 2 check box controls are present for instance, both in IDE and when running the executable. But it's true that the form can't be scrolled by default (at least visibly). BTW, there are small differences between Delphi and Lazarus concerning the control positions inside a group box (and may be also in some other "container" controls): - left: -2 - top: -16. Usually, for my own I just convert my Delphi .dfm files with a basic personal tool. ---------------------------------------------------------------------- MISV · 2014-10-10 16:15 Well, the demo project I uploaded demonstrated/duplicated the issue of diffeerent positioning in groupbox. (It is true that from my original problem, I think there are more issues, but I have not duplicated/repeated these in a way that is useful for this.) I have not checked your numbers, but 16pixels difference sounds about right. Of course, if one is moving to Lazarus for good, one could just fix this. However, I would like to keep my sourcecode and forms cross platforms. At least for the time being. However, I guess runtime code will be he best option here since I understand if it is too much to demand of Lazarus. ---------------------------------------------------------------------- JuhaManninen · 2014-10-10 18:52 The Delphi converter in Lazarus takes care of coordinate offsets when generation LFM files. Using the same DFM file for both Delphi and Lazarus form is problematic and should be used only with very simple GUIs. A better strategy is to use separate DFM and LFM files and IFDEFs in Pascal code. The converter already adds the IFDEF if you selected "Support Delphi". Obviously you then must change both GUIs when changes are needed. On the other hand you can better use the advanced layout features of LCL, for example anchors, in the Lazarus version of your GUI. ---------------------------------------------------------------------- MISV · 2014-11-11 14:55 I need to continue develop/add features regularly while moving to Lazarus/Windows and later Lazarus/OSX... So I will go pretty far trying to fix it with runtime code since ide/forms are *very* close at working and being compatible. But yes, if need to be, I may have to separate into two different GUIs,  but it would be nice is there were some ways to code around it. I think at least this issue can be coded around by adding an ifdef with runtime code fixing positions. Most other things work okay including alignment and anchors across Delphi and Lazarus, but there may very well be other IDE/form compability issues I have not discovered yet. One: Lazarus saving image lists in a way not compatible with Delphi is the only one I know of: http://forum.lazarus.freepascal.org/index.php?topic=25929.0 ---------------------------------------------------------------------- MISV · 2015-01-20 02:41 In the end, there is something tha at least fixes i in one of my products. In formcreate, simply iterate over all controls... And if parent is a TGroupBox, fix *Top* with minus 16 - seems to work. ---------------------------------------------------------------------- Martin Wynne · 2024-06-27 19:48 Quote from: MISV on January 20, 2015, 03:41:33 amIn the end, there is something that at least fixes it in one of my products. In formcreate, simply iterate over all controls... And if parent is a TGroupBox, fix *Top* with minus 16 - seems to work. Many thanks for this. I've been converting a project from Delphi to Lazarus, with about 70 forms and a great many well-filled groupboxes. I couldn't understand why Lazarus had messed everything up. The above kludge works fine and fixes things until I can work through all the forms to fix them properly. I found that minus 20 works better in most cases. Thanks again, Martin.