1
votes

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}

3

3 Answers

2
votes

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.

1
votes

The empty form is the form of for the current project as you used the convert Delphi project from tools which means the current project is active.
Try this:

  • On the project option close the current project.
  • On the small main window named as project wizard, use the convert Delphi project option.
0
votes

I'm sorry I can't give you a straight answer. From what I understand there's a problem a problem with the resource file. In delphi that's the *.res, I don't know what they look like in Lazarus. Use a program like resedit, http://www.resedit.net/, to open the resource file. I tried it and found a "folder" Icon where there was a post MAINICON. I'm guessing you have two. In that case remove one of them.