Recent

Author Topic: Converting and installing Corelbutton.pas component  (Read 7045 times)

callo

  • Newbie
  • Posts: 5
Converting and installing Corelbutton.pas component
« on: March 02, 2008, 11:52:29 am »
I believe I read all documents more than once.
I am an old delphi developer.so I believe that should be more easy to port a simple VCL into lazarus.

I tried converters...changed many file names that was in uses section.
renamed some Message functiong result types. etc.

but couldnt achive to convert a simple VCL into lazarus.

let have a look for a simple VCL named corelbutton at:
http://www.torry.net/pages.php?id=77
or
http://www.delphi.int.ru/download/file/9/

I gave 2 days. but couldnt convert it.

I just wantto know. if lazarus is really enough compatible ?
I saw ipro and synedit components ported to lazarus but many components seems removed. because of incompatiblity ?

corelbutton.pas is a very simple VCL. that should be took converting should be take 1-2 minutes. but I lost 2 days.

can someone tell step by step howto convert corelbutton.pas into lazarus ?

I created an empty lazarus component package (lpk) and put corelbutton into it. it gave many errors. I fixed many lines corretctly.
but okay I said
"I lost.I wont attempt to convert too much time"

finally I removed the last error line

DrawItem(Msg.DrawItemStruct)^;

and finally package compiled. but I pressed install" button.
and voila
another problem

"CorelButton.pas(74,12) Fatal: Can't find unit CorelButton used by Package1"

can someone convert it ?
its not a really need VCL. but it was my second attempt.again I couldnt achieved.

I would like to see where I am wrong really. by comparing both VCL and LCL files to see where I am wrong.

instead of referring some general document links to read more and more
can some one help ?please.

thanks in advice

callo

  • Newbie
  • Posts: 5
RE: Converting and installing Corelbutton.pas component
« Reply #1 on: March 02, 2008, 12:49:54 pm »
"Compiling package NewPackage 0.0" completed

I removed the line
DrawItem(Msg.DrawItemStruct)^;  
(to just see a simple VCL can be installed in lazarus by me)

but when I press install for this package.
says CorelButton not found.

CorelButton.pas(74,12) Fatal: Can't find unit CorelButton used by NewPackage

first I put its directory into:
compiler options>other unit files
also
compiler options>other sources

-------------------
same error continued.

than I copied CorelButton.pas to all possible directory (like lcl).

but no chance

where I am wrong ?
maybe pas should be pp ? or filename case sensitive ?

please help...

callo

  • Newbie
  • Posts: 5
RE: Converting and installing Corelbutton.pas component
« Reply #2 on: March 02, 2008, 01:10:16 pm »
okay I canceled install into ide
but when I try

var
A:TCorelButton;
begin
  A:=TCorelButton.Create(Self);
end;


error occuring :

project raises exception class 'External SIGSEGV'

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1927
RE: Converting and installing Corelbutton.pas component
« Reply #3 on: March 02, 2008, 01:24:46 pm »
I had a look at it.
This component is not easy to port, because it's very Win-API specific.
It _might_ work on Win32 but not on other platforms.
You'd better start your own thing. Have a look at the source of TColorButton for example.
You can probably copy parts of the painting code from TCorelButton.

callo

  • Newbie
  • Posts: 5
RE: Converting and installing Corelbutton.pas component
« Reply #4 on: March 02, 2008, 01:38:11 pm »
thanks theo.
thus can we say %90 of VCLs not compatible for lazarus ?

I was trying lazarus in win32 platform.If I see conveting is easy I would use it in linux too instead of KDevelop.

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1927
RE: Converting and installing Corelbutton.pas component
« Reply #5 on: March 02, 2008, 01:52:53 pm »
It depends on how the VCL Component is written.
If it's using the VCL only (like Synedit more or less) , then porting should be possible without too much headache.
If it's relying on a lot of platform specific code (Winapi or Qt Kylix) it's harder and in this case it's probably easier to start from scratch and copy some of the logic.

LuizAmérico

  • Sr. Member
  • ****
  • Posts: 457
Converting and installing Corelbutton.pas component
« Reply #6 on: March 02, 2008, 03:52:25 pm »
I managed to port it to LCL/Lazarus, but as Theo said this control uses specific win32 behavior so it's not easy and may not work under Linux (not tested).

To the issues:

1) LCL ignores the style set in CreateParams (BS_OWNERDRAW) and LCL also does not provides another way of setting to owner draw (like combobox does). The effect: the control does not receives WM_DRAWITEM.

2) TCorelButton overrides SetButtonStyle to avoid the default implementation (that removes the BS_OWNERDRAW style). LCL does not has this method so the default implementation is always called, killing the BS_OWNERDRAW.

I modified LCL to workaround both issues.

Give me a mail and i will send to you the converted component and the LCL patch.

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: RE: Converting and installing Corelbutton.pas component
« Reply #7 on: March 02, 2008, 10:48:53 pm »
Quote from: "callo"
thanks theo.
thus can we say %90 of VCLs not compatible for lazarus ?

I was trying lazarus in win32 platform.If I see conveting is easy I would use it in linux too instead of KDevelop.


Hi callo,

Your frustration is understandable, but don't feel too bad or think that you wasted your 2 days. Porting a VCL component can be very challenging and requires that you learn a great deal about Lazarus and its LCL all at once. Plunging in is a good way to start learning all the things you will need to know, but don't think that initial failure is a reflection on you!

You might want to take a look at the OrphPort project:

http://wiki.lazarus.freepascal.org/OrphPort

This project includes some notes on "porting philosophy". One thing that I've found useful is to create a compatibility unit and include it in all the ported units. This compatibility unit is a place where you can put anything that the LCL lacks or to work around differences between VCL and LCL. It's also possible through the use of IFDEF's to port a component so that it retains full Delphi compatibility. That way, if you improve it later, both Delphi and Lazarus benefit. If you do a one-way port, then you would have to make the improvements to two different code bases.

Porting to Windows is a good first step since you can include the Windows unit just like you do with Delphi. Once you have that working, then you can worry about Linux and OS X, where the Windows unit doesn't exist. The LclIntf unit has a lot of commonly used Win API functions implemented cross-platform, but you'll invariably find some Win API functions that aren't in LclIntf.

Believe me, porting a VCL component is a lot easier now than it was 2.5 years ago when I took the same frustrating plunge that you've taken. Many of the holes in the LCL have been filled and lots of bugs have been fixed.

Also, note how helpful others have already been on this forum! You can usually get an answer here, even if it's "I don't know."

Thanks.

-Phil

Paul Ishenin

  • Sr. Member
  • ****
  • Posts: 274
RE: Re: RE: Converting and installing Corelbutton.pas compon
« Reply #8 on: March 03, 2008, 03:20:49 am »
Luiz, send me your patch and I'll check if at least some parts of it can be applied.

LuizAmérico

  • Sr. Member
  • ****
  • Posts: 457
RE: Re: RE: Converting and installing Corelbutton.pas compon
« Reply #9 on: March 04, 2008, 01:19:59 am »
I'll send. It's pretty simple.

I did not propose because there are some issues to be resolved before enabling owner draw buttons in LCL:

1) I don't know if other widget sets allows owner draw buttons.

2) Under LCL/win32 the draw of button is done in response to a LM_DRAWITEM message. The other widget sets can do this? Or should the win32 response be moved to a LM_PAINT message?

3) Under LCL/win32 the owner draw property is done through a flag (Params.Style). Should continue this way or add an specific property.


To be clear: i'm not requesting this feature. I'm not convinced the work is worth. What advantages provides over a TSpeedButton descendant?.
I just did it for the fun and to help the Lazarus user.

Paul Ishenin

  • Sr. Member
  • ****
  • Posts: 274
RE: Re: RE: Converting and installing Corelbutton.pas compon
« Reply #10 on: March 04, 2008, 02:19:21 am »
1) I dont know too about all widgetsets. Any needs a research.
2) LM_DRAWITEM is ok, but other widgetsets need to pass it too.
3) Params.Style should be used in future by the widgetset code.

At moment I dont want to research all that problems, but can apply patch if it will work without consequences to LCL :)

 

TinyPortal © 2005-2018