PDA

View Full Version : Lazarus component nightmare



masonwheeler
11-08-2007, 01:51 PM
I'm trying to port a project from Delphi to Lazarus. Unfortunately, my project uses a handful of custom VCL components, and trying to get them to work is a mess. Once I've gone through the source code and commented out all the properties that Lazarus doesn't support yet, the package will finally compile and install, prompting me to recompile Lazarus to make the components available on the palette. But once I've done the recompile...
...there's nothing new on the component palette, and there are blank spots on my forms where the components are supposed to be. Any idea what's wrong and how to fix it?

Mason

WILL
11-08-2007, 09:05 PM
Hey Mason, you should know that LCL is not fully VCL/.DFM compatible. Though code-wise it usually is.

Lazarus is designed to be an alternative to Delphi, not specifically a 100% compatible clone of it. Usually when one uses VCL in Delphi and wants to convert to LCL in Lazarus, they would be better off redoing the visual components portion and simply copy-paste-ing the code inside each form/component's method over to the new Lazarus version.

This can be a bit of a pain, but it's 100% effective, so long as LCL has what the VCL you used had and used.

There are some conversion tools out there somewhere, but unfortunately I have not worked with them at all. Others might be able to tell you more about them. But I find the above method to work best for me.

Almindor
14-08-2007, 11:27 AM
You can get it done by using the proper registration methods. See some other (simple) Lazarus components for what calls need to be made and what resources need to be prepared.

In short, you need to:
1. make xpm icons for a lazarus resource for the package and name them as the components (eg: TMyComponent.xpm)
2. use "lazres" from Lazarus/tools to "compile" a lazarus resource file for the components, like eg: "lazres file.lrs *.xpm" (not sure if * works in windows, it does in linux)
3. use proper register procedure for your components, as per Lazarus wiki (sorry, am in a hurry here, would look up the URL otherwise)

That should get it going if everything else compiled, it should work (of course some things can still break because of bugs etc. but you're on a good track by this point)