Recent

Author Topic: extracting part of a Delphi5 dfm  (Read 3434 times)

ronhud

  • Jr. Member
  • **
  • Posts: 84
extracting part of a Delphi5 dfm
« on: September 14, 2018, 03:53:11 pm »
I have some old Delphi5 code and wish to reuse a TPel with all its components in a Lazarus project.    I have created new form in the Lazarus project and added the panel and its components as text from the Delphi dfm.  I then added the declarations for the panel etc to the new form class.   When I open the new form .pas file the panel and all its components appear in the Object Inspector but if I press F12 then only the empty form appears.   Any suggestions as to whether I have missed something or that what I am attempting cannot be done.

Thaddy

  • Hero Member
  • *****
  • Posts: 14213
  • Probably until I exterminate Putin.
Re: extracting part of a Delphi5 dfm
« Reply #1 on: September 14, 2018, 03:55:41 pm »
usually use the project or unit  converter option first
Specialize a type, not a var.

valdir.marcos

  • Hero Member
  • *****
  • Posts: 1106
Re: extracting part of a Delphi5 dfm
« Reply #2 on: September 14, 2018, 04:43:26 pm »
I have some old Delphi5 code and wish to reuse a TPel with all its components in a Lazarus project.    I have created new form in the Lazarus project and added the panel and its components as text from the Delphi dfm.  I then added the declarations for the panel etc to the new form class.   When I open the new form .pas file the panel and all its components appear in the Object Inspector but if I press F12 then only the empty form appears.   Any suggestions as to whether I have missed something or that what I am attempting cannot be done.
There are many solutions.

Please, consider this is not a rule, just my personal opinion.
The easiest and fastest solution I could find so far is to rebuild the project step by step:
Open the old Delphi project on Delphi, create a new project on Lazarus.
Drop the components on Lazarus one by one, and setting everything studying the old project and considering Delphi and Lazarus have important differences, avoid copy and past the components.
Do copy and past code by small chunks, try to compile, solve the problems, test the project and understand (learn) what is happening part by part as you build the new project.
Accept that sometimes, you will need to create new code or new components because Delphi old solution is bad coded, components don't exist on Lazarus, or code simply doesn't work on Lazarus, or even because there are important differences between Delphi and Lazarus. Remember that Lazarus is much more than a Delphi clone.
This is a sustainable professional solution which demands time, patience and learning, not a fast flushed solution.

Thaddy

  • Hero Member
  • *****
  • Posts: 14213
  • Probably until I exterminate Putin.
Re: extracting part of a Delphi5 dfm
« Reply #3 on: September 14, 2018, 05:59:25 pm »
On D5-D7 code the likely option should be the import delphi  option. Specifically for these versions the converter does a very good job. I do not agree with your advice in that respect.
It becomes a different story when third party components were used. What you describe is an often not necessary last resort.
Specialize a type, not a var.

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: extracting part of a Delphi5 dfm
« Reply #4 on: September 14, 2018, 06:00:30 pm »
I have some old Delphi5 code and wish to reuse a TPel with all its components in a Lazarus project.    I have created new form in the Lazarus project and added the panel and its components as text from the Delphi dfm.  I then added the declarations for the panel etc to the new form class.   When I open the new form .pas file the panel and all its components appear in the Object Inspector but if I press F12 then only the empty form appears.   Any suggestions as to whether I have missed something or that what I am attempting cannot be done.
First, I assume that a "TPel" is a "TPanel".

I just tried this modified approach: In Delphi's form designer (form view, not text view!) copy the panel into the clipboard. Go to Lazarus' form designer (again normal form view, not text view) and paste the copied panel. This works (in principle) if all required components are installed in Lazarus and if they share the same properties. Event handlers are not copied this way.

I also tested your approach via pasting into the text view of the lfm file. After one unsuccessful test I found out this working solution

* Lazarus: Create a new form (empty).
* Delphi: Copy the component declarations from the pas file to the clipboard
* Lazarus: Paste the clipboard into the new pas file.
* Delphi: Switch the form designer to text mode, select all the dfm text and copy to the clipboard
* Lazarus: Switch the new form to lfm text view. Paste the clipboard. Edit the text and remove all unknown properties and components. Save and test
* As for the unknown properties/components: Manually add LCL components which don't have a matching buddy in the VCL. Set LCL properties to the corresponding values of the VCL components. Or try other workarounds.
* Of course, event handlers, again, are not copied this way.

valdir.marcos

  • Hero Member
  • *****
  • Posts: 1106
Re: extracting part of a Delphi5 dfm
« Reply #5 on: September 14, 2018, 06:52:01 pm »
On D5-D7 code the likely option should be the import delphi  option. Specifically for these versions the converter does a very good job. I do not agree with your advice in that respect.
It becomes a different story when third party components were used. What you describe is an often not necessary last resort.
Since Clipper and Turbo Pascal in the late 1980's, and Delphi afterwards, and Lazarus recently, I don't remember a single commercial project without third party components in the last almost three decades.
Delphi and Lazarus don't even have a standard money component.
Neither standard components for webcam (photos) nor equipments such as companies' baffle gate or turnstile.
You can't even copy and past or import (R)DBMS connection and data access components between Delphi and Lazarus because they are very different.
And I am not even talking about components to "beautify" (themes or visual appearance) in the application, or bar code engine, or report engines, or cube engines.
Locally speaking, commercial projects here in Brazil are full of complex and always-changing tax law components; more recently we have the blessing open source Projeto ACBr that works on both Delphi and Lazarus.
The only few projects that I remember I have worked on without third party components where during bachelor’s degree, graduated degree, and a first tentative of master’s degree. Those were academical projects. And few projects on my voluntary work.

Thaddy

  • Hero Member
  • *****
  • Posts: 14213
  • Probably until I exterminate Putin.
Re: extracting part of a Delphi5 dfm
« Reply #6 on: September 14, 2018, 07:14:10 pm »
Well, we  - more than one job - wrote all required components ourselves, because of the risks involved by using third party.
That said: the scale of the development teams allowed for that, as well as the education (usually at least a b.sc in computer science for every team member or an master degree in another science). (usually 40+ team or even teams! and another 15+ team dedicated test department)
I fully understand that is not your average workfloor but it is how I use to develop. (these are all banks - not small ones - , I am a trade specialist if I had to choose one specialism, but closer to CTO on department scale, not corporate scale, if you didn't know that)
Specialize a type, not a var.

ronhud

  • Jr. Member
  • **
  • Posts: 84
Re: extracting part of a Delphi5 dfm
« Reply #7 on: September 15, 2018, 09:49:23 am »
WP - clipboard copying as your suggestion worked.   I had not expected that.  Thanks

valdir.marcos

  • Hero Member
  • *****
  • Posts: 1106
Re: extracting part of a Delphi5 dfm
« Reply #8 on: September 16, 2018, 02:45:33 pm »
Well, we  - more than one job - wrote all required components ourselves, because of the risks involved by using third party.
As an external consultant, I also agree with you and I also recommend that to teams, but they rarely do because of lack of knowledge, lack of resources, lack of budget and lack of time before deadline.

Quote
That said: the scale of the development teams allowed for that, as well as the education (usually at least a b.sc in computer science for every team member or an master degree in another science). (usually 40+ team or even teams! and another 15+ team dedicated test department)
Most of my audience that still uses Delphi or Lazarus are small teams from zero to 5 developers whose employers usually have an internal legacy software.
Most Delphi developers still present on teams are 40yo+ and high school graded (sometimes they are graduated, bachelor or have a college degree) with zero Lazarus experience;
The biggest part of teams are 30yo- and have never heard about neither Delphi nor Lazarus in their entire lives before getting that job.
Both groups have shallow experience on OOP and SQL.

Quote
I fully understand that is not your average workfloor but it is how I use to develop.
My workflow is to prepare and follow teams that are not used to OOP to learn fast and at low cost some OOP and some SQL to migrate Windows legacy applications (usually Clipper, VB, Java or Delphi) to (Linux and Windows) Lazarus or PHP or both. And migrate databases such as Oracle, MS SQL Server, Sybase, PostgreSQL, MySQL, Interbase, MS Access, DBase or Paradox to Firebird.
Brazil holds the largest events on Delphi and Firebird on Earth.
http://tkssoftware.com/victory/top-5-at-embarcadero-conference-brazil-2016/

Quote
(these are all banks - not small ones - , I am a trade specialist if I had to choose one specialism, but closer to CTO on department scale, not corporate scale, if you didn't know that)
I know what you mean.
Here, it's rare to see big companies developing their new core software using Delphi or Lazarus. Of course there are some, bu it's not what it used to be any more.
I always joke to close friends that our job is like getting blood out of a stone.  :) :-X

 

TinyPortal © 2005-2018