Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2020-08

Installing custom control in Lazarus - where can I find it?

6 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Bo Berglund

I am (again) trying to port a Delphi application to Lazarus/FPC. This time I need a customized version of TListView, which I converted to use in Lazarus back in 2018.
See thread titled:
"Converting a component package Delphi->Lazarus using built-in converter?"

I found the files for the converted component on my disk as: easylistview.lpk THis is the package file
EasyListView.pas
EasyListView.dcr

No using Lazarus 2.0.8 and FPC 3.0.4 I did the following:
- Started Lazarus
- Told it to start a new project (to not interfere with my current project)
- Package/Open package file
- Navigated to the easylistview.lpk file
- Clicked the Compile button. Finished successfully.
- Use/Install. Lazarus started to rebuild itself
- No visible errors shown
- Lazarus restarted

Now, how do I find the component I just installed so I can use it? I expected a new tab named AGI to appear with the component inside of it but I cannot find it...

This is what is (or rather was, see below) in the register procedure in EasyListView.pas:

procedure Register;
begin
	RegisterComponents('AGI', [TEasyListView]);
end;

And this is the lpk file content after the compile/install:

<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<Package Version="4">
<PathDelim Value="\"/>
<Name Value="EasyListView"/>
<Type Value="RunAndDesignTime"/>
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<SearchPaths>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> </SearchPaths>
</CompilerOptions>
<Files Count="1">
<Item1>
<Filename Value="EasyListView.pas"/>
<UnitName Value="EasyListView"/>
</Item1>
</Files>
<RequiredPkgs Count="1">
<Item1>
<PackageName Value="IDEIntf"/>
</Item1>
</RequiredPkgs>
<UsageOptions>
<UnitPath Value="$(PkgOutDir)"/>
</UsageOptions>
<PublishOptions>
<Version Value="2"/>
</PublishOptions>
<CustomOptions Items="ExternHelp" Version="2">
<_ExternHelp Items="Count"/>
</CustomOptions>
</Package>
</CONFIG>

Now the strangest thing is that in this process Lazarus has completely mangled the EasyListView.pas source file so it now only has this content wheras the original was 27 kbytes....:

{ This file was automatically created by Lazarus. Do not edit! This source is only used to compile and install the package. }

unit EasyListView;
{$warn 5023 off : no warning about unused units}
interface
uses
  LazarusPackageIntf;
implementation
procedure Register;
begin
end;
initialization
  RegisterPackage('EasyListView', @Register);
end.

So it is overwriting the source file for the component with a basically empty file, which it successfully installs and is nowhere to be found....

Apparently I am doing something completely wrong here, but what?

Bo Berglund Developer in Sweden

Reply by email

Werner Pamler
to Bo Berglund
Bo Berglund wrote
Now the strangest thing is that in this process Lazarus has completely mangled the EasyListView.pas source file so it now only has this content wheras the original was 27 kbytes....:

I guess the component code is in unit EasyListView.pas and the package is named EasyListview.lpk. This is bad because installation creates the "package unit" with the same name as the package file, i.e. it overwrites your component unit.

Remedy: give the package a different, more "package-like" name, e.g. EasyListViewPkg, or LazEasyListView (also to distinguish from any Delphy package). Carefully check the contents of the new LazEasyListView.lpk file to make sure that the old package name is not mentioned any more (or recreate the package from the start - this is not difficult and almost no work).

IIRC, I had tried to convert this component some time ago, too, and found it very difficult. Well, maybe because my intention was to make it cross-platform.

Reply by email

Salvatore Coppola
to Bo Berglund: I am (again) trying to port a Delphi application to Lazarus/FPC. This time I need a…

Have restarted the lazarus just recompiled?

⁣Ottieni BlueMail per Android ​

Il giorno 27 Ago 2020, 22:51, alle ore 22:51, Bo Berglund via lazarus ha scritto:

Show quoted text 117 lines
I am (again) trying to port a Delphi application to Lazarus/FPC. This time I need a customized version of TListView, which I converted to use in Lazarus back in 2018. See thread titled: "Converting a component package Delphi->Lazarus using built-in converter?" I found the files for the converted component on my disk as: easylistview.lpk THis is the package file EasyListView.pas EasyListView.dcr No using Lazarus 2.0.8 and FPC 3.0.4 I did the following: - Started Lazarus - Told it to start a new project (to not interfere with my current project) - Package/Open package file - Navigated to the easylistview.lpk file - Clicked the Compile button. Finished successfully. - Use/Install. Lazarus started to rebuild itself - No visible errors shown - Lazarus restarted Now, how do I find the component I just installed so I can use it? I expected a new tab named AGI to appear with the component inside of it but I cannot find it... This is what is (or rather was, see below) in the register procedure in EasyListView.pas: procedure Register; begin RegisterComponents('AGI', [TEasyListView]); end; And this is the lpk file content after the compile/install: <?xml version="1.0" encoding="UTF-8"?> <CONFIG> <Package Version="4"> <PathDelim Value="\"/> <Name Value="EasyListView"/> <Type Value="RunAndDesignTime"/> <CompilerOptions> <Version Value="11"/> <PathDelim Value="\"/> <SearchPaths> <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> </SearchPaths> </CompilerOptions> <Files Count="1"> <Item1> <Filename Value="EasyListView.pas"/> <UnitName Value="EasyListView"/> </Item1> </Files> <RequiredPkgs Count="1"> <Item1> <PackageName Value="IDEIntf"/> </Item1> </RequiredPkgs> <UsageOptions> <UnitPath Value="$(PkgOutDir)"/> </UsageOptions> <PublishOptions> <Version Value="2"/> </PublishOptions> <CustomOptions Items="ExternHelp" Version="2"> <_ExternHelp Items="Count"/> </CustomOptions> </Package> </CONFIG> Now the strangest thing is that in this process Lazarus has completely mangled the EasyListView.pas source file so it now only has this content wheras the original was 27 kbytes....: { This file was automatically created by Lazarus. Do not edit! This source is only used to compile and install the package. } unit EasyListView; {$warn 5023 off : no warning about unused units} interface uses LazarusPackageIntf; implementation procedure Register; begin end; initialization RegisterPackage('EasyListView', @Register); end. So it is overwriting the source file for the component with a basically empty file, which it successfully installs and is nowhere to be found.... Apparently I am doing something completely wrong here, but what? -- Bo Berglund Developer in Sweden -- _______________________________________________ lazarus mailing list https://lists.lazarus-ide.org/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20200828/5aeeef5e/attachment.html>

Reply by email

Bo Berglund
to Werner Pamler: I guess the component code is in unit EasyListView.pas and the package is named…
Werner Pamler wrote 20 lines
Am 27.08.2020 um 22:51 schrieb Bo Berglund via lazarus: > Now the strangest thing is that in this process Lazarus has completely > mangled the EasyListView.pas source file so it now only has this > content wheras the original was 27 kbytes....: I guess the component code is in unit EasyListView.pas and the package is named EasyListview.lpk. This is bad because installation creates the "package unit" with the same name as the package file, i.e. it overwrites your component unit. Remedy: give the package a different, more "package-like" name, e.g. EasyListViewPkg, or LazEasyListView (also to distinguish from any Delphy package). Carefully check the contents of the new LazEasyListView.lpk file to make sure that the old package name is not mentioned any more (or recreate the package from the start - this is not difficult and almost no work). IIRC, I had tried to convert this component some time ago, too, and found it very difficult. Well, maybe because my intention was to make it cross-platform.

Hello Werner!
After posting this I late last night found a mail correspondence with you from June 2018 where you helped me convert this very component!

And luckily the final files were attached in the email at the end of the conversation so I could extract them.

Meanwhile I have had to replace my old Win7 computer and lost a lot of files in the process... :(

Anyway now I have placed the files under subversion so that will not happen again.

So I took these files (where the naming was better with a difference between the package and the sourcefiles) and repeated the process and it succeeded! I now have an EasyListView component on my Lazarus palette!

This is very good because almost all of my old GUI style Delphi projects used the component to display data and so is crucial to being able to port them.

The reason I had forgotten our interaction could be that at the time in 2018 I was convalescing from a bad fall from the roof of my house and could barely move...

I want to (hopefully again) thank you so very much for your help at the time!

Bo Berglund Developer in Sweden

Reply by email