[lazarus] FPC - Help Needed -Dynamic Linking

Michael.VanCanneyt at Wisa.be Michael.VanCanneyt at Wisa.be
Sat Apr 7 04:19:42 EDT 2001




On Fri, 6 Apr 2001, Shane Miller wrote:

> OK, how about this.  What is I change the RegisterComponents procedure in
> creginst.inc to:
>
> If RegisterComponentsProc <> nil then
>   RegisterComponentsProc(Page,ComponentClasses);
>
> Then in the library I will have this code:
>
> Function DoRegistering : TSomerecordstructure;
>
>      procedure registercomponentcallback(const Page : String;
> ComponentClasses : TComponentClasses);
>          begin
>              //Add the PAGE and TComponentClass info to the RESULT of the
> parent function
>          end;
>
> Begin
>    RegisterComponentProc := @RegisterComponentCallback;
>   //call the register methods in each unit;
> end;
>
>
> this way the Lazarus.exe would load the library, call the DoRegistering
> function and take the return value and do the registering.

It would be easier to set a callback and call this for each component to
be registered.

SetRegisterCallback(LazarusCallBack);
RegisterComponents;

The 'LazarusCallBack' is a function in lazarus which registers 1 component.
The registercomponents function in the library registers all components it
knows about with the callback.

>
> The only problem I see with that is that the Lazarus program knows nothing
> about the ComponentClasses that are returned to it.  If, for example, I
> registered a TButtonPlus class, Lazarus would know nothing about it because
> all the information about it is in the library.

Exactly, and this cannot be solved unless we implement package support.

>
> Would this work?

It will work, but you cannot do any 'XXX is YYY' stuff on these registered
components. You could do some extra registering of TComponent VMT's:

Type
  TLibraryComponent = Class of TComponent;

Var
  LibTComponent : TLibraryComponent

  LibTComponent:=GetLibRaryComponentVMT;

Then you could do

  If Instance is LibTComponent then
    ...

But this will require keeping a record for each library with at least the
VMT's of TComponent and TPersistent.

Michael.






More information about the Lazarus mailing list