Wednesday, December 23, 2009

Lazarus(FPC) forms even more compatible with delphi.

Starting with FPC version 2.5.1 lazarus and FPC allow to save forms in lfm format without the need of LRS files.

This change make even easy migrate code from Delphi to Lazarus.

Prereqs:

Lazarus trunk version.
FPC trunk version (tested with version 2.5.1, don't know which is the minimal version required).
(Edited: minimal version required is FPC Version 2.4.0. Thanks Paul!)

The steps are:

1) Go to project options, tab miscellaneous and select fpc resources.

2) Copy dfm file to lfm file.

3) Open pas file on lazarus.

4) search your dfm reference and replace it for

{$IFDEF LCL}
{$R *.lfm}
{$ELSE}
{$R *.dfm}
{$ENDIF}

5) Search the include for lrs file at inicialization section and remove it.

6) HIT F12 (to see the lfm file).

7) You can safely ignore warnings about properties non presents in lazarus. That is true for the most of cases, but like you are a serious programmer will always read the warning messages to evaluate importance of the message, right? ;)
Save

8) Build. Done!

As always, don't forget to add need uses clauses in header of units ( i mind LclType, LResources,etc).

Enjoy!

12 comments:

Alan Clark said...

That's great!

Is it possible to make list of properties to ignore when loading dfm/lfm files, then Lazarus could use the dfm file directly, one less file to maintain.

Also this is picky but I prefer the following to avoid the double negative -

{$IFDEF LCL}
{$R *.lfm}
{$ELSE}
{$R *.dfm}
{$ENDIF}

Donald Shimoda said...

Yes, is possible to implement a list of properties to ignore, the problem is like with any OS project who will maintain this list up to date...

Your suggestion is ok, editing right now.

Anonymous said...

If you want to advertise FreePascal/Lazarus, would you at least make your blog a little more readable? I mean black-and-white theme first.

Donald Shimoda said...

Is a fact black background is more readable, do a favor to the eyes and consume less power at displays.

Sec, who are you to judge to anybody else? Who tell the things are right only in the way you do?

What is your problem to do that kind of negative comment? Do you feel angry about lazarus and fpc? Sorry, they are a fact.

Anonymous said...

Just don't know what to say. I am sympathetic to parallel worlds, but why on earth this "who are you" nonsence?

Donald Shimoda said...

Forget it, Merry Christmas.

Anonymous said...

Merry Christmas. Good luck to Lazarus(FPC) and the Gregorian calendar. The Orthodox Christmas is after the New Year. :)

Жељко Аврамовић said...

Hello Donald,

I have seen that you are using mikroPascal for AVR/PIC/8051. There is more powerful AVRco Multitasking Pascal for AVR micro processors with nice debugger, simulator, and free demo. You can take a look at www.e-lab.de.

Donald Shimoda said...

More powerful? Don't even support PIC18xx series...

Mikroe pascal are a mature product right now, i think you better take a look there.

Thanks.

Unknown said...

Required fpc version is 2.4.0 which will out soon. Trunk of course works too :)

Donald Shimoda said...

Thanks for the info Paul!

Unknown said...

Hi friends,

Really amazing blog post. I saw and read your blog,This site is useful to Delphi Developers. I know that it will

help me in my own stuffs. I think it may be relevant.