Recent

Author Topic: Convert Delphi form results in invisible/hidden controls  (Read 10665 times)

MISV

  • Hero Member
  • *****
  • Posts: 791
Convert Delphi form results in invisible/hidden controls
« on: September 10, 2014, 02:14:46 pm »
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

  • Administrator
  • Hero Member
  • *
  • Posts: 11450
  • FPC developer.
Re: Convert Delphi form results in invisible/hidden controls
« Reply #1 on: September 10, 2014, 02:58:27 pm »
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

  • Hero Member
  • *****
  • Posts: 791
Re: Convert Delphi form results in invisible/hidden controls
« Reply #2 on: September 13, 2014, 09:09:14 am »
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

  • Hero Member
  • *****
  • Posts: 791
Re: Convert Delphi form results in invisible/hidden controls
« Reply #3 on: September 13, 2014, 06:36:36 pm »
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:
« Last Edit: September 13, 2014, 06:38:59 pm by MISV »

Mike.Cornflake

  • Hero Member
  • *****
  • Posts: 1260
Re: Convert Delphi form results in invisible/hidden controls
« Reply #4 on: September 13, 2014, 06:47:55 pm »
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...
Lazarus Trunk/FPC Trunk on Windows [7, 10]
  Have you tried searching this forum or the wiki?:   http://wiki.lazarus.freepascal.org/Alternative_Main_Page
  BOOKS! (Free and otherwise): http://wiki.lazarus.freepascal.org/Pascal_and_Lazarus_Books_and_Magazines

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Convert Delphi form results in invisible/hidden controls
« Reply #5 on: September 13, 2014, 08:50:28 pm »
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

  • Hero Member
  • *****
  • Posts: 791
Re: Convert Delphi form results in incorrect top / hidden controls in TGroupBox
« Reply #6 on: September 24, 2014, 10:59:27 pm »
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 :(
« Last Edit: September 24, 2014, 11:06:54 pm by MISV »

MISV

  • Hero Member
  • *****
  • Posts: 791
Re: Convert Delphi form results in invisible/hidden controls
« Reply #7 on: October 06, 2014, 11:15:29 am »
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

  • Hero Member
  • *****
  • Posts: 542
Re: Convert Delphi form results in invisible/hidden controls
« Reply #8 on: October 06, 2014, 12:18:25 pm »
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.
« Last Edit: October 08, 2014, 01:45:26 pm by ChrisF »

MISV

  • Hero Member
  • *****
  • Posts: 791
Re: Convert Delphi form results in invisible/hidden controls
« Reply #9 on: October 10, 2014, 06:15:24 pm »
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

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4467
  • I like bugs.
Re: Convert Delphi form results in invisible/hidden controls
« Reply #10 on: October 10, 2014, 08:52:01 pm »
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.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

MISV

  • Hero Member
  • *****
  • Posts: 791
Re: Convert Delphi form results in invisible/hidden controls
« Reply #11 on: November 11, 2014, 03:55:12 pm »
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

  • Hero Member
  • *****
  • Posts: 791
Re: Convert Delphi form results in invisible/hidden controls
« Reply #12 on: January 20, 2015, 03:41:33 am »
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.

 

TinyPortal © 2005-2018