Recent

Author Topic: Is possible use DFM files (delphi) in lazarus ide?  (Read 37181 times)

laguna

  • Sr. Member
  • ****
  • Posts: 323
Is possible use DFM files (delphi) in lazarus ide?
« on: April 01, 2010, 12:21:55 pm »
Is possible use DFM files (delphi) in lazarus ide?
i use Last version lazarus and fpc.

jagorath

  • New Member
  • *
  • Posts: 34
Re: Is possible use DFM files (delphi) in lazarus ide?
« Reply #1 on: April 01, 2010, 12:53:43 pm »
Yes but if you are using recent versions of Delphi you'll get errors because of missing properties such as ExplicitLeft, ExplicitTop etc.  Better to convert to lfm and conditionally include it instead of the dfm.

Zaher

  • Hero Member
  • *****
  • Posts: 679
    • parmaja.org
Re: Is possible use DFM files (delphi) in lazarus ide?
« Reply #2 on: April 02, 2010, 11:06:23 pm »
Not a good idea.

Garry Hopkins

  • Newbie
  • Posts: 2
Re: Is possible use DFM files (delphi) in lazarus ide?
« Reply #3 on: April 06, 2010, 03:34:37 pm »
No,this should work.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8746
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Is possible use DFM files (delphi) in lazarus ide?
« Reply #4 on: April 07, 2010, 01:57:35 pm »
Use Lazarus snapshot's improved Delphi project converter. It has the ability to preserve Delphi compilation.

Lex_Liven

  • New member
  • *
  • Posts: 8
  • Just another Lazarus newbie :)
Re: Is possible use DFM files (delphi) in lazarus ide?
« Reply #5 on: May 29, 2011, 03:18:18 pm »
I've writed my own Delphi-Lazarus converter. There is no text "ExplicitLeft" in my converted project (neither in .LPR file no in .PAS or .LFM) but i still get message "Unknown property: "ExplicitLeft"". What can I do with this problem?

P.S.: I don't like Lazarus converter.
======================================================================
Sorry! I've found "ExplicitLeft" in my unit3.lfm. Trying to fix it.
Fixed. I've deleted this text and some more uncompatible properties and my project was successfully compiled.
« Last Edit: May 29, 2011, 03:38:47 pm by Lex_Liven »

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4459
  • I like bugs.
Re: Is possible use DFM files (delphi) in lazarus ide?
« Reply #6 on: May 29, 2011, 07:06:29 pm »
I've writed my own Delphi-Lazarus converter. There is no text "ExplicitLeft" in my converted project (neither in .LPR file no in .PAS or .LFM) but i still get message "Unknown property: "ExplicitLeft"". What can I do with this problem?
P.S.: I don't like Lazarus converter.
======================================================================

Please use the latest converter in Lazarus trunk for best results.

And yes, I am not happy with it either even though I wrote most of it.
It is still a dummy converter. It doesn't do any deep code analysis which is needed for mapping some Delphi classes and their properties + methods to Lazarus classes. OpenGL and XML components are two common cases that would need it.
The converter uses Codetools which is very good for parsing and modifying "uses" sections and interfaces but not for parsing the actual code.
The converter is able to replace function calls inside code but it implements a parser for it, which contains only little context checking and thus is not very robust.
In long term there could be an "advanced converter" using another parser.

Windows API calls and OLE automation (for cross-platform conversion) and 3rd party components which are not ported to Lazarus make things still worse. Those projects are very difficult to convert even manually, automatic conversion will never be possible.

Still, some Delphi projects can be converted fully automatically into a cross-platform Lazarus project, without a single manual change!
Please load and test projects from "http://delphiforfun.org/", for example Cannonballs and others. They are small but "real" applications (not just "Hello World").

Quote
Sorry! I've found "ExplicitLeft" in my unit3.lfm. Trying to fix it.
Fixed. I've deleted this text and some more uncompatible properties and my project was successfully compiled.

The "Explicit*" properties were recently registered internally in LCL to be skipped while reading a form file. They are also removed during conversion. So it seems the Lazarus built-in converter does a better job than your home made Delphi-Lazarus converter, at least on this one detail. :)

Would you like to join forces and help developing the Delphi converter in Lazarus?
I know the code looks first intimidating because it uses codetools and because it links to other parts of Lazarus ... and because parsing and converting Object Pascal source is complicated by nature. I am ready to help if someone is truly learning the code.

Is your home made converter better in some area? Would you like to share the code?
I know many things could be improved in Lazarus' converter also when using the current parser and architecture.

Juha
« Last Edit: May 29, 2011, 07:38:13 pm by JuhaManninen »
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

xenblaise

  • Sr. Member
  • ****
  • Posts: 358
Re: Is possible use DFM files (delphi) in lazarus ide?
« Reply #7 on: May 29, 2011, 07:55:26 pm »
Share the code for Lazarus community   O:-)
HELP :D

Lex_Liven

  • New member
  • *
  • Posts: 8
  • Just another Lazarus newbie :)
Re: Is possible use DFM files (delphi) in lazarus ide?
« Reply #8 on: May 30, 2011, 04:49:03 pm »
I can share the code but I don't find it too interesting to community. It's very simple and not optimized.
It doesn't convert any objects or methods - only recode strings like "#1023#1235':'#6542#4532" into Unicode string (for Delphi forms).
I doubt that it's better than Lazarus' converter in any part.
Quote
P.S.: I don't like Lazarus converter.
Actually, now I doubt my own words :)

(rus: Хорошо бы тут оказался кто-то русскоговорящий... Тяжело на английском общаться.)

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4459
  • I like bugs.
Re: Is possible use DFM files (delphi) in lazarus ide?
« Reply #9 on: May 30, 2011, 10:47:48 pm »
I can share the code but I don't find it too interesting to community. It's very simple and not optimized.
It doesn't convert any objects or methods - only recode strings like "#1023#1235':'#6542#4532" into Unicode string (for Delphi forms).

Converting to Unicode (utf-8) during Delphi conversion is on my ToDo list but not implemented.
It means your converter does a better job here.

I have not studied the topic yet, I am not even sure what exactly must be converted. (all pascal + .lfm?)
There is Converter/ChgEncoding.pas made by Mattias Gärtner that could work as an example.

Patches are very welcome!

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

Lex_Liven

  • New member
  • *
  • Posts: 8
  • Just another Lazarus newbie :)
Re: Is possible use DFM files (delphi) in lazarus ide?
« Reply #10 on: May 31, 2011, 04:34:33 am »
Well... If I want to send patch I need to install svn version? Can I share here code of function that does this job? Or attach an archived project?
======
OK. I'll comment all code and attach project here.
« Last Edit: May 31, 2011, 07:37:15 am by Lex_Liven »

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4459
  • I like bugs.
Re: Is possible use DFM files (delphi) in lazarus ide?
« Reply #11 on: May 31, 2011, 07:32:21 am »
Well... If I want to send patch I need to install svn version? Can I share here code of function that does this job? Or attach an archived project?

Sure. You can copy a piece of code here or then provide a link.

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

Lex_Liven

  • New member
  • *
  • Posts: 8
  • Just another Lazarus newbie :)
Re: Is possible use DFM files (delphi) in lazarus ide?
« Reply #12 on: May 31, 2011, 10:40:55 am »
Got it! Wow, it's hard to comment my own code in english, but I hope it wasn't wasted efford.
My code is more clear than my comments at least for me.

Quote
I have not studied the topic yet, I am not even sure what exactly must be converted. (all pascal + .lfm?)
There is Converter/ChgEncoding.pas made by Mattias Gärtner that could work as an example.
DPR and Delphi PAS = pascal code in ansi encoding. Cyrillic characters write as cp1251. (1 char = 1 byte).
LPR and Lazarus PAS = pascal code in UTF8. Cyrillic - unicode (1 char = 2 bytes)

DFM = Form in ansi codepage. Cyrillic writeb by pseudocode (as #1234)
LFM = Form in UTF8. All symbols - Unicode (1-2 bytes).

All other files are not necessary, IMHO.
*.Dproj, *.bdsproj and *.bdsgroup = UTF8-XML. I don't know how to convert it.
« Last Edit: May 31, 2011, 02:09:50 pm by Lex_Liven »

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: Is possible use DFM files (delphi) in lazarus ide?
« Reply #13 on: May 31, 2011, 02:55:33 pm »


Delphi 2009+ is also UTF8 source encoding btw.

Lex_Liven

  • New member
  • *
  • Posts: 8
  • Just another Lazarus newbie :)
Re: Is possible use DFM files (delphi) in lazarus ide?
« Reply #14 on: May 31, 2011, 02:57:53 pm »
Delphi 2009+ is also UTF8 source encoding btw.
I'm used Delphi 10 (dunno what year it is) - it saved PAS and DPRs in ansi.
This isn't big problem - both converters (my and Lazarus') works with UTF8 files too.

 

TinyPortal © 2005-2018