Sign in Join

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

Mailing lists / lazarus / 2018-06

Converting a component package Delphi->Lazarus using built-in converter?

19 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

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

Bo Berglund

As part of an effort to port a Delphi program to FPC/Lazarus I have tried to install a custom package of components we use with Delphi from D7 to XE5 into Lazarus 1.8.4 win32.

I started by using the menu function:
Tool/Delphi Conversion/Convert Delphi Package

After navigating to the dpk file in the components source dir Lazarus thought quickly and then popped up the dialog for package handling, but no hint on what to do next....

So I tried the Compile button and it worked for a short while, again with no feedback and was back on the same dialog.
Next I tried the "Use" combo-button and selected subfunction "Install" since I want these custom component which are used in many of our Delphi programs to be available in Lazarus too.
But now there was a message:

"The package <name> does not have any "Register" procedure, which typically means, it does not provide any IDE add-on. Installing it will probably only increase the size of the IDE and may even make it unstable"
Hint: If you want to use a package in your project, use the "Add to project" menu item."

Now what? My alternatives are:
"Install it, I like the fat." or "Cancel"

This Delphi package is a collection of some 20 components and all of them have Register procedures inside of each source file. Is it not possible to collect together a number of components into a package for easy installation in Lazarus?

This is our practice in Delphi since 2002 or so...

Or is it just the converter that is havíng problems?

Bo Berglund Developer in Sweden

Reply by email

Bo Berglund
to leledumbo
leledumbo wrote 6 lines
> Or is it just the converter that is havíng problems? In the package dialog, check "Register unit" for units containing Register procedure. I didn't remember the last time I converted a Delphi package, but it could be that the converter doesn't detect Register properly.

I tried another approach, i.e. not using the I tried creating a new package and then I have added manually the main source files for the different components into the package files collection.
I also added required package LCL and removed required package FCL.

Then I tried compiling and for the first few components all I had to do was add an {$IFDEF DELPHI} bracket around some Delphi version checking code and they compiled.
I also added this to the top of each component source file: {$IFDEF FPC}
{$MODE DELPHI}
{$ENDIF}
(I don't know if this is required on all source files or if there is a master setting that enforces MODE DELPHI for the whole package).

But now I have run into a stop in one component, which is actually a descendant of TListView where we have simplified usage by adding some modified defaults and a few methods.
No I am getting errors I don't understand here:

procedure TEasyListView.DoColumnSort;
var
  SortStyle: TColumnSortStyle;
begin
  if ViewStyle  vsReport then Exit;
  if not FColumnSorting then Exit;
  case ColumnSortStyle[ActiveSortColumn] of
    ssString: CustomSort(@SortByStringProc, FSortColumn);
    ssInteger: CustomSort(@SortByIntegerProc, FSortColumn);
    ssFloat: CustomSort(@SortByFloatProc, FSortColumn);
    ssImageIndex: CustomSort(@SortByImageIndexProc, FSortColumn);
    ssCustom: begin
      if Assigned(FOnColumnSortCompare) then
      begin
        UColumnSortCompare := FOnColumnSortCompare;
        CustomSort(@SortByCustomProc, FSortColumn);
        UColumnSortCompare := nil;
      end;
    end;
    ssNone: ; // Do nothing
  end;
end;

On every line mentioning CustomSort there is an error: Error: Identifier not found "CustomSort"

CustomSort is an identifier in the parent TListView unless I am mistaken. This error never appeared in Delphi...

Any ideas?

Did I start this new package in the wrong way? I simply used Package/NewPackage to bring up the dialogs....

Bo Berglund Developer in Sweden

Reply by email

Werner Pamler
to Bo Berglund
Bo Berglund wrote 54 lines
On Fri, 8 Jun 2018 10:17:00 -0700 (MST), leledumbo via Lazarus wrote: >> Or is it just the converter that is havíng problems? > In the package dialog, check "Register unit" for units containing Register > procedure. I didn't remember the last time I converted a Delphi package, but > it could be that the converter doesn't detect Register properly. > I tried another approach, i.e. not using the converter at all. Instead I tried creating a new package and then I have added manually the main source files for the different components into the package files collection. I also added required package LCL and removed required package FCL. Then I tried compiling and for the first few components all I had to do was add an {$IFDEF DELPHI} bracket around some Delphi version checking code and they compiled. I also added this to the top of each component source file: {$IFDEF FPC} {$MODE DELPHI} {$ENDIF} (I don't know if this is required on all source files or if there is a master setting that enforces MODE DELPHI for the whole package). But now I have run into a stop in one component, which is actually a descendant of TListView where we have simplified usage by adding some modified defaults and a few methods. No I am getting errors I don't understand here: procedure TEasyListView.DoColumnSort; var SortStyle: TColumnSortStyle; begin if ViewStyle vsReport then Exit; if not FColumnSorting then Exit; case ColumnSortStyle[ActiveSortColumn] of ssString: CustomSort(@SortByStringProc, FSortColumn); ssInteger: CustomSort(@SortByIntegerProc, FSortColumn); ssFloat: CustomSort(@SortByFloatProc, FSortColumn); ssImageIndex: CustomSort(@SortByImageIndexProc, FSortColumn); ssCustom: begin if Assigned(FOnColumnSortCompare) then begin UColumnSortCompare := FOnColumnSortCompare; CustomSort(@SortByCustomProc, FSortColumn); UColumnSortCompare := nil; end; end; ssNone: ; // Do nothing end; end; On every line mentioning CustomSort there is an error: Error: Identifier not found "CustomSort"

Are the '@' correct? I thought you are in mode DELPHI.

Did I start this new package in the wrong way? I simply used Package/NewPackage to bring up the dialogs....

I think this is correct. I converted a lot of Delphi packages this way, without the converter - it gives me more control of what is happening.

Reply by email

Mattias Gaertner
to Bo Berglund: On Fri, 8 Jun 2018 10:17:00 -0700 (MST), leledumbo via Lazarus I tried another approach,…
Show quoted text 10 lines
[...] Then I tried compiling and for the first few components all I had to do was add an {$IFDEF DELPHI} bracket around some Delphi version checking code and they compiled. I also added this to the top of each component source file: {$IFDEF FPC} {$MODE DELPHI} {$ENDIF} (I don't know if this is required on all source files or if there is a master setting that enforces MODE DELPHI for the whole package).

Package / Options / Compiler Options/ Parsing / Syntax Mode

Mattias

Reply by email

Bo Berglund
to Mattias Gaertner
Mattias Gaertner wrote 16 lines
On Fri, 08 Jun 2018 20:08:02 +0200 Bo Berglund via Lazarus wrote: >[...] > Then I tried compiling and for the first few components all I had to > do was add an {$IFDEF DELPHI} bracket around some Delphi version > checking code and they compiled. > I also added this to the top of each component source file: > {$IFDEF FPC} > {$MODE DELPHI} > {$ENDIF} > (I don't know if this is required on all source files or if there is a > master setting that enforces MODE DELPHI for the whole package). Package / Options / Compiler Options/ Parsing / Syntax Mode

I found the combobox, which was set to "Object Pascal -default..." and changed to Delphi (-MDelphi)
But when I then click the compile button it stops at the same place with the same errors...

We have used this TListView descendant since May 1998 and the ColumnSorting method was added Nov 2005. It has been used in Delphi since Delphi 3 up until Delphi XE5, where we are now. The reason for the errors really must have something to do with how the source is treated with FPC/Lazarus as opposed to Delphi, but what can it be?
The CustomSort it complains about might exist in a used unit in Delphi but not in Lazarus for example?

CustomSort seems to be part of the Delphi VCL:
http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/delphivclwin32/ComCtrls_TCustomListView_CustomSort.html

Is it not available in the Lazarus library?

Bo Berglund Developer in Sweden

Reply by email

Bo Berglund
to Werner Pamler: Are the '@' correct? I thought you are in mode DELPHI. I think this is correct. I…
Werner Pamler wrote 5 lines
> Did I start this new package in the wrong way? I simply used > Package/NewPackage to bring up the dialogs.... I think this is correct. I converted a lot of Delphi packages this way, without the converter - it gives me more control of what is happening.

I thought so too, but then I might not set the correct Lazarus options? I am not doing this very often, usually I am just working on smaller projects started from scratch in Lazarus...

Bo Berglund Developer in Sweden

Reply by email

Bo Berglund
to Bo Berglund: On Sat, 9 Jun 2018 11:39:28 +0200, Mattias Gaertner via Lazarus I found the combobox,…
Bo Berglund wrote
The CustomSort it complains about might exist in a used unit in Delphi but not in Lazarus for example?

I opened Delphi 2007 and dropped an EasyListview object onto the form so I could trace this CustomSort method.

If I use the "find declaration" command on the CustomSort that Lazarus errors out on I am moved over to this code inside ComCtrls:

function TCustomListView.CustomSort(SortProc: TLVCompare; lParam:
Longint): Boolean;
begin
  Result := False;
  if HandleAllocated then
  begin
    if not Assigned(SortProc) then SortProc := @DefaultListViewSort;
    Result := ListView_SortItems(Handle, SortProc, lParam);
  end;
end;

So it seems like my Lazarus package is missing some reference to the equivalent of ComCtrls when I create the package from scratch. Surely something I have not done or such, but what could it be?

Does ComCtrls exist also in Lazarus?

Bo Berglund Developer in Sweden

Reply by email

Mattias Gaertner
to Bo Berglund: On Fri, 8 Jun 2018 10:17:00 -0700 (MST), leledumbo via Lazarus I tried another approach,…
Show quoted text 32 lines
On Fri, 8 Jun 2018 10:17:00 -0700 (MST), leledumbo via Lazarus [...] procedure TEasyListView.DoColumnSort; var SortStyle: TColumnSortStyle; begin if ViewStyle vsReport then Exit; if not FColumnSorting then Exit; case ColumnSortStyle[ActiveSortColumn] of ssString: CustomSort(@SortByStringProc, FSortColumn); ssInteger: CustomSort(@SortByIntegerProc, FSortColumn); ssFloat: CustomSort(@SortByFloatProc, FSortColumn); ssImageIndex: CustomSort(@SortByImageIndexProc, FSortColumn); ssCustom: begin if Assigned(FOnColumnSortCompare) then begin UColumnSortCompare := FOnColumnSortCompare; CustomSort(@SortByCustomProc, FSortColumn); UColumnSortCompare := nil; end; end; ssNone: ; // Do nothing end; end; On every line mentioning CustomSort there is an error: Error: Identifier not found "CustomSort" CustomSort is an identifier in the parent TListView unless I am mistaken. This error never appeared in Delphi... Any ideas?

TCustomListView.CustomSort exists in LCL as well.
Check the declaration of SortByStringProc:

function SortByStringProc(Item1, Item2: TListItem;
AOptionalParam: PtrInt): Integer; stdcall;

Mattias

Reply by email

Bo Berglund
to Mattias Gaertner
Mattias Gaertner wrote 6 lines
TCustomListView.CustomSort exists in LCL as well. Check the declaration of SortByStringProc: function SortByStringProc(Item1, Item2: TListItem; AOptionalParam: PtrInt): Integer; stdcall;

But why does it then not find it?

I found a bugtracker entry here:
https://bugs.freepascal.org/view.php?id=8536

And it says it was solved by Zeljan Rikalo on 2017-10-17

Is it not (yet) part of the Lazarus/FPC release?
I am using Lazarus 1.8.4 bundled with FPC 3.0.4 (svn rev 57972) (win32 version) on Windows7 X64

Now I have found a problem in another unit too, in this case it cannot find the StartsText function in StrUtils. Is this another slight incompatibility between Delphi and Lazarus?

Bo Berglund Developer in Sweden

Reply by email

Werner Pamler
to Werner Pamler: Are the '@' correct? I thought you are in mode DELPHI. I think this is correct. I…

Is this MustangPeak's EasyListView
https://github.com/TurboPack/MustangpeakEasyListview)? I was trying to convert it myself, but did not even get this far. I got lost in the dependence on another package which did not want to resolve - very windows-specific stuff. If it is a non-closed packaged by somebody else, or if it is an older version of MustangPeak's EasyListView why don't you pack the files needed into a zip and attach it to?

Reply by email

Bo Berglund
to Werner Pamler
Werner Pamler wrote 7 lines
Is this MustangPeak's EasyListView https://github.com/TurboPack/MustangpeakEasyListview)? I was trying to convert it myself, but did not even get this far. I got lost in the dependence on another package which did not want to resolve - very windows-specific stuff. If it is a non-closed packaged by somebody else, or if it is an older version of MustangPeak's EasyListView why don't you pack the files needed into a zip and attach it to?

No, it is an internal design by a developer that got fed up with the strange defaults and behaviour of the original TListView. It happened back in 1998 (for Delphi 3 at the time).
It has been added to ever since with new features so it is hard to port the applications needing this to FPC/Lazarus if it cannot be also converted.

Bo Berglund Developer in Sweden

Reply by email

Bo Berglund
to Bo Berglund: On Fri, 8 Jun 2018 10:17:00 -0700 (MST), leledumbo via Lazarus I tried another approach,…
Bo Berglund wrote 5 lines
On every line mentioning CustomSort there is an error: Error: Identifier not found "CustomSort" CustomSort is an identifier in the parent TListView unless I am mistaken. This error never appeared in Delphi...

FYI:
I got off-list help by Werner Pamler to find the problem in the EasyListView component.
It turns out that CustomSort is *not* available in FPC/Lazarus release 3.0.4/1.8.4, it was added to trunk only a month or so back.

With Werner's help I edited the comctrl.pp and comctrl.inc files to include the patches that solves the problem and then rebuilt Lazarus. After this the CustomSort problem disappeared and the EasyListView component compiled without errors.

Now I have problems installing the package instead because when I select install it pops up a warning message saying that the package does not have a Register procedure, which is strange since every constituent component file has a register method.

How do I add a *package* Register method? And will it place the components in the package on an IDE tab?

Bo Berglund Developer in Sweden

Reply by email

Bo Berglund
to Bo Berglund
Bo Berglund wrote 8 lines
On Sun, 10 Jun 2018 09:54:34 +0200, Bo Berglund via Lazarus wrote: >With Werner's help I edited the comctrl.pp and comctrl.inc files to Sorry, typo! I actually edited the comctrls.pp and customlistview.inc files!

I am attaching a zipfile with the patches I applied to the two files lcl/comctrls.pp
lcl/include/customlistview.inc
in the current distribution of Lazarus 1.8.4.

Bo Berglund Developer in Sweden

Reply by email

Bo Berglund
to Bo Berglund: On Sun, 10 Jun 2018 09:54:34 +0200, Bo Berglund via Lazarus Sory, typo! I actually edited…

begin 644 comctrls.pp.patch.zip
(`#U0RDR:L"0LT````&L!```1````8V]M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WGR+6D\#])2,)']+,MS7A;.7LMELE
M!&JC95`?P\4E'*OC)?B5OPO?%97]6'SQ)%G=H^T7(3_I1T<LZ-YEO+%RYCJV M%[O['$&Z0)8W"U_)$Y[D>>>&I1M4"U3F,2!&C'YU*]8A54GWR^<=AG[KC,)Y ML16ER3<F+0]!"Z0>S#955H67>D:]'>H.V:OC4W>NY`9.3Z$0N1V1A',?AET$ MWA13C\GO0'??2)2F7).E2)26K?:0>/FZIM6A?TB+ at .7U_5(6V.;/&>[#-)Z` MGO%'08/?:PW[')MJ9ZKGV=6F%WT0D1DEPA^3RWRAU*PA+
M&3<GMX;/:C)<"7%C?G]ZXV9ODM&=MV'?
M*.1_4$L!`A0`%``")JP)"S0````:P$``!$`)
M`````&-O;6-T<FQS+G!P+G!A=&-H"@@`\&VA39$`U`&`7*!-
MD0#4`8!<H$V1`-0!4$L!`A0`%``"@)```
<W1O;6QI<W1V:65W+FEN8RYP871C:`H`(```````
M`0`8`(#TLQ61`-0!P!^R%9$`U`'`'[("`,T```"5
%!`````#T
`
end

Reply by email

Michael Schnell
to Bo Berglund: As part of an effort to port a Delphi program to FPC/Lazarus I have tried to install a…
Bo Berglund wrote
This Delphi package is a collection of some 20 components and all of them have Register procedures inside of each source file.

Are those really IDE-relevant packages (showing up in the visual component selection ) ?

If not, they might be just Delphi "Runtime Packages" (a special kind of DLLs that can be attached by Delphi executables).

The concept of "Runtime Packages" is not (yet) supported by FPC/Lazarus. That is why the IDE needs to be recompiled when installing a package that provides visual components.

-Michael

Reply by email

Bo Berglund
to Michael Schnell
Michael Schnell wrote 6 lines
On 08.06.2018 19:05, Bo Berglund via Lazarus wrote: > This Delphi package is a collection of some 20 components and all of > them have Register procedures inside of each source file. Are those really IDE-relevant packages (showing up in the visual component selection ) ?

No, not all of them. Some are just implemented as components for ease-of-use a very long time ago. They can then be dropped on a form and by magic the necessary settings to use them are added by the IDE. But they can be used by adding the specific uses clauses and search paths manually and created in code instead of having the IDE do it.

If not, they might be just Delphi "Runtime Packages" (a special kind of DLLs that can be attached by Delphi executables).

No runtimes, we always build everything into our exe files.

Bo Berglund Developer in Sweden

Reply by email