Recent

Author Topic: Creating own components - some issues  (Read 2206 times)

hy

  • Full Member
  • ***
  • Posts: 221
Creating own components - some issues
« on: November 22, 2014, 02:52:05 pm »
Hi, I am having some derivatives from Standardcontrols and try to include them into lazarus (had them im Delphi b4).
The components are in two units. Each unit contains a register procedure.
I haven't been able to install them in the way recommended here:
http://wiki.lazarus.freepascal.org/How_to_Write_a_Lazarus_Component
Maybe the wiki needs some update.
What I did:
From MainMenu: Package -> New Package
+ named it myComponents.pas
+ Add the two units in question
+ Add New Requirement LCLBase
+ Compile
+ Install
Installing exits with a message:"The package does not have any procedure register..." (or very similar)
+ Save
+ Exit Lazarus
Edit the myComponents.pas-file for the new components:
Insert the following lines into procedure register
Code: [Select]
procedure Register;
begin
  RegisterUnit(myUnit1', @myUnit1.Register);
  RegisterUnit('myUnit2', @myUnit2.Register);
end;
Edit the myComponents.lpk-File and insert
        <HasRegisterProc Value="True"/>
for each used file.
Code: [Select]
<Files Count="2">
      <Item1>
        <Filename Value="myUnit1.pas"/>
        <HasRegisterProc Value="True"/>
        <UnitName Value="myUnit1"/>
      </Item1>
      <Item2>
        <Filename Value="myUnit2.pas"/>
        <HasRegisterProc Value="True"/>
        <UnitName Value="myUnit2"/>
      </Item2>
    </Files>
 
Then restart Lazarus, open the package and compile it. Finally I could install it.
I wonder why those manual steps are required and why lazarus can't find the register-procedure by itself.
Next problem is the icons for the new components.
I have created a *.lrs file using lazres.
Inserting the *.lrs-File into the package didn't get me anywhere.
So again
+exit Lazarus
+manually editing the myComponents.pas-File
+inserting LResources into the uses clause
+inserting {$i myComponents.lrs} in the initialization
+start Lazarus open and compile the component
The last step is undone - i.e. LResources is removed from the uses clause and the {$i myComponents.lrs} is removed as well.
How do I get my icons?
_____
***hy
OS: debian sid(64bit)  [fpc 3.20] Lazarus 2.0.12

Cyrax

  • Hero Member
  • *****
  • Posts: 836
Re: Creating own components - some issues
« Reply #1 on: November 22, 2014, 09:47:17 pm »
You can put tick in the "Register unit" checkbox. It should do same than manually editing your files.

 

TinyPortal © 2005-2018