Difference between revisions of "Creating LCL Control From Libraries"

From Lazarus wiki
Jump to navigationJump to search
Line 5: Line 5:
  
 
== LIBRARY EXAMPLE 1 ==
 
== LIBRARY EXAMPLE 1 ==
procedure init;
+
<pre>procedure init;
 
var myobj:TRHandle;
 
var myobj:TRHandle;
 
begin
 
begin
 
   myobj:=RCreate(StrToRstr('TObject'));
 
   myobj:=RCreate(StrToRstr('TObject'));
 
   RSetStrProp(myobj,StrToRstr('MyStringProperty'),StrToRstr('Hello world!'));
 
   RSetStrProp(myobj,StrToRstr('MyStringProperty'),StrToRstr('Hello world!'));
end;
+
end;</pre>
  
 
== LIBRARY EXAMPLE 2 ==
 
== LIBRARY EXAMPLE 2 ==
<code>procedure init;
+
<pre>procedure init;
 
var button:TRButton;
 
var button:TRButton;
 
begin
 
begin
Line 19: Line 19:
 
   button.Caption:='Hello!';
 
   button.Caption:='Hello!';
 
   button.Parent:=RParent;
 
   button.Parent:=RParent;
end;</code>
+
end;</pre>
  
 
== Copyright ==
 
== Copyright ==

Revision as of 00:30, 28 October 2009

About

Due to several problems, LCL components and ansistrings cannot be passed between a library (dll/so/dynlib) and an application (exe/app).

This interface provides a simple API between the library and the application to create LCL UI controls application-side, however controlled by dummies library-side.

LIBRARY EXAMPLE 1

procedure init;
var myobj:TRHandle;
begin
  myobj:=RCreate(StrToRstr('TObject'));
  RSetStrProp(myobj,StrToRstr('MyStringProperty'),StrToRstr('Hello world!'));
end;

LIBRARY EXAMPLE 2

procedure init;
var button:TRButton;
begin
  button:=TRButton.Create(RApplication);
  button.Caption:='Hello!';
  button.Parent:=RParent;
end;

Copyright

Devised and created by Christian Sciberras, with the help of the following people from #lazarus-ide IRC (alphabetical):

  • Andreas '\pub\bash0r' Schneider
  • Dmitry 'skalogryz' Boyarintsev
  • Marc 'giantm' Weustink
  • Vincent 'fpcfan' Snijders

License

© 2009 Covac Software. You may copy, store, modify and sell this software/source as long as you keep copyright comments in the source code intact.