Recent

Author Topic: Adding a Delphi visual package to IDE  (Read 5322 times)

Rog

  • New member
  • *
  • Posts: 12
Adding a Delphi visual package to IDE
« on: December 29, 2015, 06:31:28 pm »
I have started to play with Lazarus after several years away from Delphi (D7), as I have an old program that needs some updates.

The program uses a specific component, which I need to imprort into Lazarus.

1) I have run the pas file through the Lazarus Tools/Delphi Conversion/Convert Delphi Unit Into Lazarus Unit module and it seems to have converted ok: it Replaced unit "Windows" with "LCLIntf, LCLType, LMessages" in uses section.

2) I have used lazres to create the IDE icon from the png icon I extracted from the .dcu file.

This gave me 2 files: YP.pas and YP.lrs

3) Added a reference to LResources to the  Uses clause of the YP.pas.

4) Added:
initialization
  {$I YP.lrs}
just before the final .end of the .pas file.

I am a bit confused by the various instructions %), so can someone confirm what has to be done to add the component to the IDE?

Many thanks




howardpc

  • Hero Member
  • *****
  • Posts: 3010
Re: Adding a Delphi visual package to IDE
« Reply #1 on: December 29, 2015, 08:46:28 pm »
It may be a good idea, before you add the component to the IDE palette to write a very simple test program that exercises the converted component to check that the conversion does not need further tweaking. Could be as simple as adapting this:


Code: Pascal  [Select]
  1. var
  2.   test: TMyComponent=nil;
  3.  
  4.  
  5. TForm1.OnCreate(Sender: TObject);
  6. begin
  7.   test:=TMyComponent.Create(Self);
  8.   test.Left:=xx;
  9.   test.Top:=yy;
  10.  // test.OtherProperty:=... etc.
  11.   test.Parent:=Self;
  12. end;

Rog

  • New member
  • *
  • Posts: 12
Re: Adding a Delphi visual package to IDE
« Reply #2 on: January 04, 2016, 01:21:40 pm »
Happy New Year everyone!

Sorry for delay - but been away over Xmas!

Have tested as suggested and it works fine, have tried but have not been able to add it to the IDE, so can you let me know exactly what needs to be done to add it as a visual component to the IDE

Thanks for help

x2nie

  • Sr. Member
  • ****
  • Posts: 478
  • Impossible=I don't know the way
    • impossible is nothing - www.x2nie.com
Re: Adding a Delphi visual package to IDE
« Reply #3 on: January 04, 2016, 02:18:31 pm »
yes, it sometime happened on me too: fail on converting delphi DPK into lazarus LPK (package).


Usually, it was resolved by manually add files into package dialog via clicking 'Add>>'.
and sometime I need to remove and then add back files needed.


If you can open the package created (*.lpk), please compile the package.
if it okay, please checkmark the "register unit". see attachment:


(I assumed you already know that : your package is for designtime, not runtime-only)
When you were logged in, you can see attachments.
Lazarus Trunk @ Windows7 64bit, XP 32bit, Debian under VirtualMachine

x2nie

  • Sr. Member
  • ****
  • Posts: 478
  • Impossible=I don't know the way
    • impossible is nothing - www.x2nie.com
Re: Adding a Delphi visual package to IDE
« Reply #4 on: January 04, 2016, 02:23:21 pm »
if everything is okay, on your package dialog, click USE >> INSTALL.
and then wait. it will restart lazarus if success.
after lazarus restart, your component will be in component palette.
When you were logged in, you can see attachments.
Lazarus Trunk @ Windows7 64bit, XP 32bit, Debian under VirtualMachine

howardpc

  • Hero Member
  • *****
  • Posts: 3010
Re: Adding a Delphi visual package to IDE
« Reply #5 on: January 04, 2016, 02:54:06 pm »
Presumably you've already looked at:
http://wiki.lazarus.freepascal.org/Code_Conversion_Guide
and
http://wiki.lazarus.freepascal.org/Lazarus_Packages


which between them cover most of the details of what you need to know. Both wikis have sections specific to porting Delphi code.
There is little point repeating all that information on this forum using different words.
But if you have further specific questions/problems, ask away.