R – Empty main form in GUI app converted from Delphi to Lazarus

delphifpcfreepascallazarus

I have converted my 2 GUI apps from Delphi to Lazarus.
Both apps compile for Win32 platform, i386 and with GUI.
Main form were converted using Lazarus tool and can be edited from IDE.
But when I run such application main form does not appear, only blank form without any controls.

I tried to debug this. It runs all code in initialization sections,
and runs code from .lpr project, but something wrong happens in CreateForm() because
it doesn't run code in the main form OnCreate event. In event log I can see all
texts I write to it with '<App.Run' appearing after I close this empty form.

Code in .lpr project:

  Application.Initialize;
  AddToEventLogInfo('App.CreateForm');
  Application.CreateForm(TfrmTst, frmTst);
  AddToEventLogInfo('App.Run>');
  Application.Run;
  AddToEventLogInfo('<App.Run');

I checked that I am able to create simple GUI apps from the Lazarus, but both converted GUI
apps do not work as expected. What can be wrong? Have I missed something?
Maybe one of many warnings and hints Lazarus write is important?

When I run my app Lazarus writes this:

  windres: warning: 14: "MAINICON": 1045: duplicate value
  windres: warning: 16: 1: 1045: duplicate value
  Project "Tst_fpc" successfully built. :)

EDIT:

Lazarus conversion tool converted .dfm -> .lfm, but has some problems with .pas file. I had to manually:

  1. add Lazarus units to uses:

    uses
    {$IFDEF FPC}
    LCLIntf, LResources,
    {$ENDIF}

  2. Conditional compile Delphi form {$R *.dfm}:

    {$IFNDEF FPC}
    {$R *.dfm}
    {$ENDIF}

  3. Add .lrs resource in initialization code:

    initialization
    {$IFDEF FPC} {$i myunit.lrs} {$ENDIF}

Best Answer

I suspect that the mainform unit (I assume it is called utest) doesn't have a {$I utest.lrs} in its initialization section. The .lrs is the lazarus resource file, created from the lfm (dfm) in delphi.

Related Topic