Discussion:
[Lazarus] Converting a component package Delphi->Lazarus using built-in converter?
Bo Berglund via Lazarus
2018-06-08 17:05:46 UTC
Permalink
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

--
leledumbo via Lazarus
2018-06-08 17:17:00 UTC
Permalink
Post by Bo Berglund via Lazarus
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.



--
Sent from: http://free-pascal-lazarus.989080.n3.nabble.com/
--
Bo Berglund via Lazarus
2018-06-08 18:08:02 UTC
Permalink
On Fri, 8 Jun 2018 10:17:00 -0700 (MST), leledumbo via Lazarus
Post by leledumbo via Lazarus
Post by Bo Berglund via Lazarus
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"

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

--
Werner Pamler via Lazarus
2018-06-09 09:27:11 UTC
Permalink
Post by Bo Berglund via Lazarus
On Fri, 8 Jun 2018 10:17:00 -0700 (MST), leledumbo via Lazarus
Post by leledumbo via Lazarus
Post by Bo Berglund via Lazarus
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.
{$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.
procedure TEasyListView.DoColumnSort;
var
SortStyle: TColumnSortStyle;
begin
if ViewStyle <> vsReport then Exit;
if not FColumnSorting then Exit;
case ColumnSortStyle[ActiveSortColumn] of
ssCustom: begin
if Assigned(FOnColumnSortCompare) then
begin
UColumnSortCompare := FOnColumnSortCompare;
UColumnSortCompare := nil;
end;
end;
ssNone: ; // Do nothing
end;
end;
Error: Identifier not found "CustomSort"
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.

--
Bo Berglund via Lazarus
2018-06-09 15:21:10 UTC
Permalink
On Sat, 9 Jun 2018 11:27:11 +0200, Werner Pamler via Lazarus
Post by Werner Pamler via Lazarus
Post by Bo Berglund via Lazarus
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

--
Werner Pamler via Lazarus
2018-06-09 17:08:23 UTC
Permalink
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?
--
Bo Berglund via Lazarus
2018-06-09 19:43:20 UTC
Permalink
On Sat, 9 Jun 2018 19:08:23 +0200, Werner Pamler via Lazarus
Post by Werner Pamler via Lazarus
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

--
Mattias Gaertner via Lazarus
2018-06-09 09:39:28 UTC
Permalink
On Fri, 08 Jun 2018 20:08:02 +0200
Post by Bo Berglund via Lazarus
[...]
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.
{$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
--
Bo Berglund via Lazarus
2018-06-09 15:19:01 UTC
Permalink
On Sat, 9 Jun 2018 11:39:28 +0200, Mattias Gaertner via Lazarus
Post by Mattias Gaertner via Lazarus
On Fri, 08 Jun 2018 20:08:02 +0200
Post by Bo Berglund via Lazarus
[...]
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.
{$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

--
Bo Berglund via Lazarus
2018-06-09 15:47:53 UTC
Permalink
On Sat, 09 Jun 2018 17:19:01 +0200, Bo Berglund via Lazarus
Post by Bo Berglund via Lazarus
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

--
Mattias Gaertner via Lazarus
2018-06-09 15:50:43 UTC
Permalink
On Fri, 08 Jun 2018 20:08:02 +0200
Post by Bo Berglund via Lazarus
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
ssCustom: begin
if Assigned(FOnColumnSortCompare) then
begin
UColumnSortCompare := FOnColumnSortCompare;
UColumnSortCompare := nil;
end;
end;
ssNone: ; // Do nothing
end;
end;
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
--
Bo Berglund via Lazarus
2018-06-09 16:18:21 UTC
Permalink
On Sat, 9 Jun 2018 17:50:43 +0200, Mattias Gaertner via Lazarus
Post by Mattias Gaertner via Lazarus
TCustomListView.CustomSort exists in LCL as well.
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

--
Bo Berglund via Lazarus
2018-06-10 07:54:34 UTC
Permalink
On Fri, 08 Jun 2018 20:08:02 +0200, Bo Berglund via Lazarus
Post by Bo Berglund via Lazarus
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

--
Bo Berglund via Lazarus
2018-06-10 07:56:48 UTC
Permalink
On Sun, 10 Jun 2018 09:54:34 +0200, Bo Berglund via Lazarus
Post by Bo Berglund via Lazarus
With Werner's help I edited the comctrl.pp and comctrl.inc files to
Sory, typo!
I actually edited the comctrls.pp and customlistview.inc files!
--
Bo Berglund
Developer in Sweden

--
Bo Berglund via Lazarus
2018-06-10 08:08:31 UTC
Permalink
On Sun, 10 Jun 2018 09:56:48 +0200, Bo Berglund via Lazarus
Post by Bo Berglund via Lazarus
On Sun, 10 Jun 2018 09:54:34 +0200, Bo Berglund via Lazarus
Post by Bo Berglund via Lazarus
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

--
Bo Berglund via Lazarus
2018-06-10 08:08:32 UTC
Permalink
begin 644 comctrls.pp.patch.zip
M4$L#!!0``@`(`#U0RDR:L"0LT````&L!```1````8V]M8W1R;',N<'`N<&%T
M8VAUD%L+@D`0A=\#_\,\*OC0FI=4"DP0A""AJ,=8;"M!75G'_]]L91>HE[/+
M<O9\9X8Y0<B9,Y\:DR4`[-;[5#8=5P(6<![:$BO9FCF*AMF@#R<B3]6COL>0
M;#IMX'7!%6\B*%#E+5H1D(J+4-#CJ>1U'1L3-IL3:!8RF\1YT`"R=.A1-ENI
M\)@1+OIH$/\R?8%TK.L%G+D^&\V=DJ4X#32`]A\JO-Z_]&;RC!TQ-(1V/%\M
MG>7YE.4%KW;C`N!=P$RT%@3YJOI_$RLI:\%;BK\!4$L#!!0``@`(``Q0RDQ9
M)MT38`,``!D+```8````8W5S=&]M;&ES='9I97<N:6YC+G!A=&-HK5;;;MI`
M$'VOU'^81RPY!$BK%)Q&I;16D=*""DH>JBAR\4!66M9HO<[E[SN[Z\***@20/
MY0';Z[F<.3-G8'C6"X<?SM+A8/C^W06L"[%2+!-P-\FVNT3B%<O5-</'J<)M
M?C<I<I5M%YE4'7W0#T%?!B.89TPHE,$(IG3=H(QTM(=$***@M`%64$2QNB.C!F
M?W'#A#7\C7G!%8P^0R_R7?794C_HC#9[T)T]"I3VVYA;%[:&<9ZSC<"T4[EW
MXP;[74Q5!J#NL<SJYCWJT&EG#UMX!G1RT'N>R&0;V%3(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```&-U<W1O;6QI<W1V:65W+FEN8RYP871C:`H`(```````
M`0`8`(#TLQ61`-0!P!^R%9$`U`'`'[(5D0#4`5!+!08``````@`"`,T```"5
%!`````#T
`
end

--
Mattias Gaertner via Lazarus
2018-06-10 08:28:07 UTC
Permalink
On Sun, 10 Jun 2018 09:54:34 +0200
Post by Bo Berglund via Lazarus
[...]
How do I add a *package* Register method? And will it place the
components in the package on an IDE tab?
http://wiki.lazarus.freepascal.org/IDE_Window:_Package_Editor

Click for each such unit 'Register unit'

Mattias
--
Michael Schnell via Lazarus
2018-06-11 08:13:21 UTC
Permalink
Post by Bo Berglund via Lazarus
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

--
Bo Berglund via Lazarus
2018-06-20 05:59:59 UTC
Permalink
On Mon, 11 Jun 2018 10:13:21 +0200, Michael Schnell via Lazarus
Post by Michael Schnell via Lazarus
Post by Bo Berglund via Lazarus
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.
Post by Michael Schnell via Lazarus
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

--
Loading...