Recent

Author Topic: FPC (Lazarus) vs. Delphi forms  (Read 27573 times)

pepak

  • New member
  • *
  • Posts: 7
FPC (Lazarus) vs. Delphi forms
« on: May 11, 2010, 01:43:58 pm »
Hi!

I have a CLI/GUI application, originally written in Delphi 5. I wanted to modify it for FreePascal/Lazarus compatibility, and succeeded, after a fashion: the application compiles without errors or warnings, and the CLI version runs fine (even in situations where I didn't expect it). But I can't get the GUI version to work - when I try to create my first form, the application crashes. An open console window reveals that the problem lies in "unknown properties" of my form - e.g., Delphi 5 has "TForm.TextHeight", which is unknown to Lazarus, and as soon as the DFM-reader encounters it, it throws an exception. Apparently, there are many other properties which work in Delphi but don't in Lazarus. Is there an easy way, via a switch while compiling or something, to keep the same .DFM file for both Delphi and Lazarus? (If it matters, I do my compile from command-line with the command:
Code: [Select]
fpc -B -Mdelphi source.dpr
Thanks, Pepak

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4460
  • I like bugs.
Re: FPC (Lazarus) vs. Delphi forms
« Reply #1 on: May 11, 2010, 02:00:06 pm »
...the problem lies in "unknown properties" of my form - e.g., Delphi 5 has "TForm.TextHeight", which is unknown to Lazarus, and as soon as the DFM-reader encounters it, it throws an exception. Apparently, there are many other properties which work in Delphi but don't in Lazarus. Is there an easy way, via a switch while compiling or something, to keep the same .DFM file for both Delphi and Lazarus? (If it matters, I do my compile from command-line with the command:
Code: [Select]
fpc -B -Mdelphi source.dpr

Currently it is not realistic to use the same .DFM file for both Delphi and Lazarus. Please use the latest SVN version of Lazarus to convert your project. The converter can remove unknown properties. Still, the conversion is not fully automatic, so you still need to edit your code manually.

Juha
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

pepak

  • New member
  • *
  • Posts: 7
Re: FPC (Lazarus) vs. Delphi forms
« Reply #2 on: May 11, 2010, 02:08:59 pm »
I did the code by hand already, thanks to a number of IFDEFs. It's just the DFM which is causing trouble for now :-(

Would it be realistic to, say, override DFM-loading code so that it ignores unknown properties? I am only using a handful of mostly-standard components, so it is quite acceptable for me to simply ignore what's wrong and override the rest in a constructor...

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4460
  • I like bugs.
Re: FPC (Lazarus) vs. Delphi forms
« Reply #3 on: May 11, 2010, 02:33:02 pm »
I did the code by hand already, thanks to a number of IFDEFs. It's just the DFM which is causing trouble for now :-(

Would it be realistic to, say, override DFM-loading code so that it ignores unknown properties? I am only using a handful of mostly-standard components, so it is quite acceptable for me to simply ignore what's wrong and override the rest in a constructor...

Maybe DFM-loading code will be changed some day. Now unfortunately you must maintain 2 versions of form files, .DFM and .LFM. Lazarus designer should let you remove the unknown properties when you open the form file there.

Juha
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4460
  • I like bugs.
Re: FPC (Lazarus) vs. Delphi forms
« Reply #4 on: May 11, 2010, 02:48:48 pm »
I was writing in a hurry. Actually there is a system in the latest SVN Lazarus version where those unknown properties are registered and then ignored by the loader. Could you please test with latest version and tell how it works for you.

Juha
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

pepak

  • New member
  • *
  • Posts: 7
Re: FPC (Lazarus) vs. Delphi forms
« Reply #5 on: May 13, 2010, 04:31:53 pm »
I will give it a try tomorrow.

Robert Gilland

  • Full Member
  • ***
  • Posts: 160
Re: FPC (Lazarus) vs. Delphi forms
« Reply #6 on: May 14, 2010, 12:48:53 am »
I am using the lazarus SVN compiled on 5/5/10.

I can use delphi datamodule .DFM in lazarus however lazarus will not show this the datamodule in the IDE.

Is this what you were expecting?

I was expecting to see the datamodule in lazarus IDE.

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4460
  • I like bugs.
Re: FPC (Lazarus) vs. Delphi forms
« Reply #7 on: May 14, 2010, 05:14:39 am »
I am using the lazarus SVN compiled on 5/5/10.

I can use delphi datamodule .DFM in lazarus however lazarus will not show this the datamodule in the IDE.

Is this what you were expecting?

I was expecting to see the datamodule in lazarus IDE.

Does it compile and work otherwise? There is a known limitation, button F12 does not switch between .DFM file and source code. It works only for .LFM files.
I will make a bug report about it...

Juha
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4460
  • I like bugs.
Re: FPC (Lazarus) vs. Delphi forms
« Reply #8 on: May 14, 2010, 06:28:36 am »
Bug tracker issue:
0016475: A form file named *.DFM is invisible in form designer
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

pepak

  • New member
  • *
  • Posts: 7
Re: FPC (Lazarus) vs. Delphi forms
« Reply #9 on: May 14, 2010, 05:31:19 pm »
I tried the latest nightly build and I didn't see any improvement over the stable build's behavior*): I am still getting the same exception. Searching the site, I noticed there is a DFM to LFM converter, but it didn't really work and when I tried to immitate its functions by hand, it turned out that I really would have to redesign the GUI completely. So I give up, at least for now - I am not a huge fan of GUI, anyway, and command-line version compiles and runs well.

*) Note: I only tried compiling from command line. I did not run the Lazarus GUI at all, and don't intend to for now - I am only interested in an application that can compile with both Delphi and FreePascal using a batch file.

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4460
  • I like bugs.
Re: FPC (Lazarus) vs. Delphi forms
« Reply #10 on: May 14, 2010, 08:42:40 pm »
@pepak:
Nightly build of ... Lazarus? ... or FPC?
The latest FPC version doesn't help here because the visual components and their properties are part of LCL which is part of Lazarus.

"DFM to LFM converter" in Tools menu only converts from binary to text and checks syntax. The menu item text is changed accordingly in SVN version.

The Delphi project conversion tries to convert form files, too, by substituting non-existent components with some LCL component and removing unknown properties. It is not perfect yet though.

TForm.TextHeight property is registered and shouldn't cause problems. If you encountered other Delphi-only properties or components that cause problems, please list them here or make a bug report.

What means: "I tried to imitate its functions by hand, it turned out that I really would have to redesign the GUI completely" ?
Is it possible to get your code / form and use it for testing?

Juha
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

pepak

  • New member
  • *
  • Posts: 7
Re: FPC (Lazarus) vs. Delphi forms
« Reply #11 on: May 16, 2010, 11:44:03 am »
@pepak:
Nightly build of ... Lazarus? ... or FPC?
Lazarus.

Quote
"DFM to LFM converter" in Tools menu only converts from binary to text and checks syntax. The menu item text is changed accordingly in SVN version.
As I said, I never even run the GUI. I was referring to http://wiki.freepascal.org/XDev_Toolkit.

Quote
What means: "I tried to imitate its functions by hand, it turned out that I really would have to redesign the GUI completely" ?
Is it possible to get your code / form and use it for testing?
http://www.pepak.net/files/youtube/ytd-0.28-source.zip
Build using the argument "fpc". (The FPC part is not completely up-to-date, but it does compile.)

Robert Gilland

  • Full Member
  • ***
  • Posts: 160
Re: FPC (Lazarus) vs. Delphi forms
« Reply #12 on: May 16, 2010, 11:53:55 pm »
Yes it all works except the most important part.
Delphi Forms (.DFM) needs to be viewable in the IDE.

Any unknown components obviously will not be shown. this would be expected.

but all known components TPanel, TButton etc. should be visible.

Robert Gilland

  • Full Member
  • ***
  • Posts: 160
Re: FPC (Lazarus) vs. Delphi forms
« Reply #13 on: May 20, 2010, 11:07:13 pm »
Am now using this.

However I am wondering why the compilation creates an extra DFM file in the unit output directory location?

pepak

  • New member
  • *
  • Posts: 7
Re: FPC (Lazarus) vs. Delphi forms
« Reply #14 on: May 21, 2010, 01:27:43 am »
I never noticed that with my Delphi 5.

 

TinyPortal © 2005-2018