Initial commit of source code for non-visual example component

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6781 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
gbamber
2019-01-07 10:04:36 +00:00
parent ae0b11dfa8
commit ad3180c2cd
9 changed files with 795 additions and 0 deletions

View File

@ -0,0 +1,51 @@
LazarusResources.Add('texamplecomponent','PNG',[
#137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#24#0#0#0#24#8#2#0#0#0'o'#21#170#175
+#0#0#0',tEXtCreation Time'#0'Sat 31 May 2014 18:57:51 -0000'#138#147'+1'#0#0
+#0#7'tIME'#7#222#5#31#17':'#30#230'85'#27#0#0#0#9'pHYs'#0#0#15#175#0#0#15#175
+#1#214#164'"m'#0#0#0#4'gAMA'#0#0#177#143#11#252'a'#5#0#0#4#29'IDATx'#218'eU'
+#203'n'#28'E'#20#173'['#221'='#239#183'g&'#182'Y'#216#138'e'#28#136#242'@ '
+#133#136#21'B'#145#144#16#27#22','#248#1#22#252#0#202#2#254''''#226'3X'#177
+' '#6';NP'#240'#'#182#231'='#158'G'#143#167#31'U]u'#185#253#154#1'1-uO'#223
+#170':u'#238#169'{O'#195#23#223#253#204#24'G'#134#192#194'[|1`'#12'1'#186'S'
+#12#232#25#254'aQ '#10'F'#183#245']'#19#4'0'#206#146'_'#184'"'#190#226#183'4'
+#22'a'#176'4'#156#194#173'^i'#144#199'\'#162#8#174'VC2'#25'Vk'#195#13'b'#220
+#20#16#210'e'#171#29#204#132'A'#152#192'j%'#198#17'\O'#139'XA'#12#129#8#255
+#218#154#1#167'H'#148#26'K'#152'b:'#24'O'#140#164#130#20#144#175#137#166#143
+'d'#223#4#215'\/J'#20'N'#184#199#219'E'#138#243'$C'#196#255#235#163'!'#153
+#206'#'#20#128'TZ'#218#217'` '#2#156'-'#165'eB'#189'l'#229#178't('#26'S'#18
+'l-'#214'Zlz'#154#201'ht'#17#170#208'z'#226#200#207#31'o>'#251#236#195'F'#181
+#232#251'r0'#186#249#253#232#239#147#211#145#212#150#226'&D'#5#129#171#195
+#193'D'#20#147#165'e'#194#1#150'^'#176#179'Y'#248#233#219'g'#31'?'#216#27#15
+#135'G'#199#175#148#134#172'i'#184#203#185#242'f'#227#137#147'-'#212#10#149
+'FR'''#24#23'Y'#152'='#134'@)'#157#165#31'|'#242'A'#235#199#239#191'jmTG'#195
+#241'//^'#28#31#254'v'#235#216#247#31'|'#202#209'zxo'#187'^'#171#157#189#235
+#158'\'#222'@'#190#137'!{4y'#204'0'#204';I-'#8'pw'#187#252#252#135#175#155
+#245#138#244#133#189#176#219'['#219#173'N'#211#152#242'J'#163#245#229#211''''
+#220'03'#185#188#148#242#229#203#195#222#197#25'h-'#148#209#153'a'#223'/#'#9
+#139#225#169#133'z'#205'='#249#252#155''''#205'f]{B'#8#153#203#230#155#173
+#246#193#163#167#197'R'#185'Z'#173#148'K'#197#229#237'\'#222'.'#152'o'#239'7'
+#220#135#13#152'M'#167'B'#186'RL'#127'}'#179#241'z'#185#143#220#162#212'Pi'
+#182#183']'#249#232#254']F;'#6#194#182#23#253#193#192#178#204#157#221#157#171
+#171'kw'#218#183#187#167#22#15#132#211#181#228'E)'#207'Y'#198#170#215#239'L'
+#186#234#252'mP'#181':'#185#160#225'f'#183'C'#177'E'#160#14'v6'#138#249'\'#16
+'('#215#245#166#211#185'F'#204'Z'#214#219#179#139'Z'#173'Z'#222'j{Br0'#236'q'
+'y'#216#13#138'n'#223#224#162'0'#235#150#134#179#250#200']6'#139#217#172'vPS'
+'j'#24'h'#221'l'#148#13#195#144'R'#184#174#175#181#210'J9'#174#243#222#246
+#214#210'q:'#195#241#209#209#235#227'W'#127#145'p4'#199#172#31#232'L'#163#144
+#203#238'r'#207#7#239#198#169'*'#8#171':dDR'#21#243#25'R'#140' '#226#6#245#5
+#213#147#158'L'''#167#231#151#215#221#254#31#199'o'#2')'#201'-'#138#141#199
+#133#141#187'tL'#136#250#148#229#160'HM'#175#227#182#9'O'#141#220#164'T'#202
+'S5H!#'#179#1#25#200#185'm_'#188#187'<'#252#243#164#215#27'z'#158#199#1#11
+#205'{'#229#141#29'D'#21#213'8'#152'a'#25'aj'#4'`'#166'-L'#13#5'y'#146'Ii)'#4
+'1'#186'u'#220#243#235'~o4'#243#3'M'#195#217'r'#187#186#249'~\'#211#171'N'
+#139#179'Il'#4'W'#238'AX'#28'|'#223#215'Ti'#153#140'Tl0^('#226'g'#154#150'iV'
+'Z'#187'`XQ'#19'C'#4#165'#.'#235#206'3y'#200#21#239'4k'#20#11'4jd'#138#4'@'
+#24#141'g3'#219#181#204#28#231#202#228#4'V'#136#219'3Z'#29'{'#18'&'#172'"'
+#163#9'}'#150#186#172'^-E'#18'2A'#242'h'#156#205#23#151#215'Cb'#24'&M'#206#5
+#144#218'(!'#164'VC:!'#143#147#132#216#176'+'#133'L'#189'R '#26'J'#161'B'#29
+#8'y'#213#25#204#23#203'deD'#0#165#147#26'njG'#255'u.n{'#193#163#253'v'#187
+'QQ'#212'o'#4#21#168#241'd'#210#27#140#28#215'%h'#170'C'#206#13#0'KzK ] n|'#6
+#171#143#4'$'#22#204'o'#28#185#183#219#202'X'#156'r'#10'S'#11#228'u'#167#219
+#235#15#169#229'H'#171#212#252#185#18'.'#211'*'#181'Z'#150'~"b;'#166'\'#241
+#31#149'yJ'#29#233','#195#24#0#0#0#0'IEND'#174'B`'#130
]);

View File

@ -0,0 +1,21 @@
{ This file was automatically created by Lazarus. Do not edit!
This source is only used to compile and install the package.
}
unit examplepackage;
interface
uses
MyExampleControl, LazarusPackageIntf;
implementation
procedure Register;
begin
RegisterUnit('MyExampleControl', @MyExampleControl.Register);
end;
initialization
RegisterPackage('ExamplePackage', @Register);
end.

View File

@ -0,0 +1,496 @@
unit myexamplecontrol;
{
= Example of a generic non-graphical component for Lazarus 1.x
= - example code for various types of properties and events to show and act correctly in the Object Inspector
= - including a custom 'About' dialog property editor
=
= Although this unit will compile as written, the purpose is to provide template code
= for various property types and events that can be copy/pasted into your own component
=
= Example Property types:
= 1) Bitmap
= 2) Font
= 3) Icon
= 4) Stringlist
= 5) Options expandable true/false list
= 6) User type drop-down list
= 7) Simple String
= 8) String with pre and post-processing
= 9) String Array with indexed properties
= 10) String with default value
= 11) Integer with default value
= 12) Overridden (custom) Tag property
= 13) Inherited drop-down list of types
= 14) Custom dialog
= 15) Custom events
= 16) Property hidden from the Object Inspector
= 17) Filename property with custom properties for the OpenDialog
=
= Author: minesadorada@charcodelvalle.com
= Date: May 2014
= License: LGPL
=
}
{$mode objfpc}{$H+}
interface
uses
Buttons, Classes, Controls, Forms, Graphics, SysUtils,
LCLIntf, LCLType, LResources,
Dialogs, ExtCtrls, PropEdits, StdCtrls, uMySubComponent;
const
C_VERSION = '1.2'; // Remember to co-ordinate with the Package manager VersionInfo
C_ERRORMESSAGE = '%s error:' + LineEnding + '%s';
// Used with Exception.CreateFmt
type
// Drop-down list in Object Inspector
tmcType = (mcType1, mcType2, mcType3);
// Expandable list of Options in Object Inspector
tOptions = (Opt1, Opt2, Opt3);
tOptionsFlags = set of tOptions;
tAboutString = string; // Unique string type used in 'About' property editor
tFilenameString = string; // Unique string type used in MyFilename property editor
TSampleEvent = procedure(MyText: string) of object; // Custom Event type
TExampleComponent = class(TComponent) // Non-graphical ancestor
private
{ Private declarations }
fAboutString: string; // Dummy string for 'About' property
fFileNameString: tFilenameString; // Filename
fmcType: tmcType; // Type defined above
fSimpleString: string; // Direct read and write (no methods)
fProcessedString: string; // Methods used to read and write the property
fStringWithDefault: string; // Object Inspector shows default
fIntegerWithDefault: integer; // Object Inspector shows default
fTag: string; // Property overrides normal Tag property
fOptions: tOptionsFlags; // Variable of Set type. * If Opt1 IN fOptions then...
fIcon: TIcon; // Assigned to Application Icon by default
fFont: TFont; // Assigned only if MyFont property set
fBitMap: TBitMap; // Assigned only if MyBitmap property set
fSizeConstraints: TSizeConstraintsOptions;
// Built-in set (part of TSizeConstraints object)
fStringArray: array[0..3] of string;
// Stores values of String1,String2,String3 and String4 properties
fStringList: TStrings; // Holds MyStringList property values
fVersion: string; // Holds read-only version property
FOnSample: TSampleEvent; // Custom event
fHiddenString: string; // Hidden property
fOnChangeHiddenString: TNotifyEvent; // Custom event
fsubcomponent: TMySubComponent; // A Subcomponent as a property
{ Private methods }
procedure SetProcessedString(AValue: string);
function GetProcessedString: string;
// Read and Write procedures for property ProcessedString
procedure SetTag(AValue: string); // Write procedure for overridden property 'Tag'
function GetStringValue(const AIndex: integer): string;
// Indexed Get Method
procedure SetStringValue(const AIndex: integer; AValue: string);
// Indexed Set method
procedure SetStrings(const AValue: TStrings);
// Needed to use a TStrings property. FStringList also needs to be created in the Constructor
procedure SetFont(const AValue: TFont);
// Needed to use a Font property. fFont also needs to be created in the Constructor
procedure SetBitMap(const AValue: TBitmap);
// Needed to use a BitMap property. fBitMap also needs to be created in the Constructor
// Sets the HiddenString property
procedure SetHiddenString(const AValue: string);
protected
{ Protected declarations }
// Can be used if you plan to subclass this component
public
{ Public declarations }
constructor Create(AOwner: TComponent); override; // Constructor must be public
destructor Destroy; override; // Destructor must be public
// This public method accesses the Subcomponent's properties
procedure CallDoSomething; // Calls the subcomponent's DoSomething method
{ Public properties }
// This section used for properties you don't want to display in the Object Inspector (or array properties)
property HiddenString: string read fHiddenString write SetHiddenString;
// Public property hidden from the Object Inspector. * SetHiddenString method can trigger custom event OnChangeHiddenString
published
{
Published declarations (Displayed in the Object Inspector)
Note: Comments immediately above the property declarations are displayed in the Lazarus Object Inspector lower pane
}
// The custom property editor TAboutPropertyEditor is used in the Object Inspector
property About: tAboutString read fAboutString; // Example of custom 'About' dialog
// Example of drop-down list in the Object Inspector
// Default is displayed in different font and is set in Constructor
property MyTypeList: tmcType read fmcType write fmcType default mcType2;
// Direct access read + write
property SimpleString: string read fSimpleString write fSimpleString;
// Example of using Read and Write methods
property ProcessedString: string read GetProcessedString write SetProcessedString;
// Example of pseudo-default property of a string (value is set in Constructor)
property StringWithDefault: string read fStringWithDefault write fStringWithDefault;
// Example of an expandable list of booleans in the Object Inspector
property Options: tOptionsFlags read fOptions write fOptions;
// Browse for Icon dialog in the Object Inspector. * No need to Create fIcon in constructor
property MyIcon: TIcon read fIcon write fIcon;
// Browse for Font dialog in the Object Inspector. * fFont needs to be created in Constructor
property MyFont: TFont read fFont write SetFont; // * Note the SetFont method
// * Note the SetBitmap method
// Browse for Bitmap dialog in the Object Inspector. * fBitmap needs to be created in Constructor
property MyBitMap: TBitmap read fBitMap write SetBitmap;
// Showing a built-in list of booleans in the Object Inspector
property MySizeConstraints: TSizeConstraintsOptions
read fSizeConstraints write fSizeConstraints;
// Default is displayed in different font but has to be set to the value 2 in Constructor
property IntegerWithDefault: integer read fIntegerWithDefault
write fIntegerWithDefault default 2; // Example of integer default
// The method is passed the index as a parameter
// Example of using an indexed read and write method to store strings in an array
property String1: string index 1 read GetStringValue write SetStringValue;
// Example of using an indexed read and write method to store strings in an array
property String2: string index 2 read GetStringValue write SetStringValue;
// Example of using an indexed read and write method to store strings in an array
property String3: string index 3 read GetStringValue write SetStringValue;
// Example of using an indexed read and write method to store strings in an array
property String4: string index 4 read GetStringValue write SetStringValue;
// Dialog shows in the Object Inspector. * fStringlist must be Created in the constructor. * Note the SetStrings override
// String list example.
property MyStringList: TStrings read fStringList write SetStrings;
// Example of a file open dialog property
property MyFilename: tFilenameString read fFilenameString write fFilenameString;
// Tag property will now only accept a single alpha character
// Example of overriding an ancestor (TComponent's) Tag property
property Tag: string read fTag write SetTag;
// No need to specify type, read method or write method
// Example of publishing a public property from an ancestor (TComponent)
property ComponentState;
// ReadOnly property
property Version: string read fVersion;
// Example of Custom Event that does nothing
property OnSample: TSampleEvent read FOnSample write FOnSample;
// This custom event is always triggered by a change in the value of HiddenString property
property OnChangeHiddenString: TNotifyEvent
read fOnChangeHiddenString write fOnChangeHiddenString;
// A subcomponent in the Dependencies
property SubComponent: TMySubComponent read fsubcomponent write fsubcomponent;
// Subcomponents need a RegisterPropertyEditor in the Register proc
// You can Get/Set the values of SubComponent's properties and call public methods
// 1) In this unit
// fsubcomponent.Subproperty1:='foo';
// fsubcomponent.DoSomething;
// 2) In an app
// MyCustomControl1.SubComponent.Subproperty1:='foo';
// MyCustomControl1.SubComponent.DoSomething;
end;
// Declaration for the 'About' property editor
TAboutPropertyEditor = class(TClassPropertyEditor)
public
procedure Edit; override;
function GetAttributes: TPropertyAttributes; override;
function GetValue: string; override;
end;
// Declaration for 'MyFilename' property editor
// (See PropEdits unit for a list of property editors to modify)
TMyFileNamePropertyEditor = class(TFileNamePropertyEditor)
public
// Override the Edit method for total control
function GetFilter: string; override;
function GetDialogOptions: TOpenOptions; override;
function GetDialogTitle: string; override;
end;
procedure Register; // Must be declared here just before implementation
implementation
procedure Register;
begin
{$I examplecomponent_icon.lrs}
// Register this component into the IDE on the 'Additional' component palette
RegisterComponents('Additional', [TExampleComponent]);
// Register the custom property editor for the 'About' property
RegisterPropertyEditor(TypeInfo(tAboutString),
TExampleComponent, 'About', TAboutPropertyEditor);
// Register the custom property editor for the 'MyFilename' property
RegisterPropertyEditor(TypeInfo(tFilenameString),
TExampleComponent, 'MyFilename', TMyFileNamePropertyEditor);
// Register a Class-type property editor for any subcomponents
RegisterPropertyEditor(TypeInfo(TMySubComponent),
TExampleComponent, 'Subcomponent', TClassPropertyEditor);
// Note the TypeInfo parameter is made into a unique type
// (defined earlier in this unit)
// so that the regular property editors in other components don't get confused
// You could simply use TypeInfo(String)
end;
constructor TExampleComponent.Create(AOwner: TComponent);
// Called when form is loaded into the IDE
begin
inherited Create(AOwner);
// Initialisation goes here
// Set any properties to their defaults and intialise objects
fmcType := mcType2; // because this was the default value specified
fStringWithDefault := 'Default String'; // Unspecified default
fIntegerWithDefault := 2; // Default value specified
fTag := 'A'; // Unspecified default
fIcon := Application.Icon; // Unspecified default
fFont := TFont.Create; // Needs to be created here for Object Inspector to show options
fBitmap := TBitMap.Create;
// Needs to be created here for Object Inspector to show the bitmap dialog
fStringList := TStringList.Create;
// Needs to be created here for Object Inspector to show dialog
fVersion := C_VERSION;
// Assign read-only property
// Use Tsubcomponent as a subcomponent
fsubcomponent := TMySubComponent.Create(Self);
fsubcomponent.SetSubComponent(True); // Tell the IDE to store the modified properties
fsubcomponent.Name := 'SubComponent1';
end;
destructor TExampleComponent.Destroy;
begin
// Clean-up code goes here
// FreeandNil any user-created objects here
FreeAndNil(fBitmap);
FreeAndNil(fStringList);
FreeAndNil(fFont);
inherited Destroy;
end;
// == START PROPERTY EDITOR CODE ==
procedure TAboutPropertyEditor.Edit;
// Shows a dialog when About property is double-clicked
var
tAboutForm: TForm;
OKbutton: TBitBtn;
lbl_Description: TLabel;
sz: string;
begin
// Make up message string
sz := 'My component for Lazarus' + LineEnding + 'by email@domain.com' +
LineEnding + LineEnding;
sz += 'Methods:' + LineEnding;
sz += 'MyVisualComponent.Method1' + LineEnding;
sz += 'MyVisualComponent.Method2' + LineEnding;
sz += LineEnding + 'Version: ' + C_VERSION + LineEnding;
sz += 'License: LGPL';
// Create a new dialog
tAboutForm := TForm.CreateNew(nil);
try //.. finally FreeAndNil everything
with tAboutForm do
begin
// Set Form properties
position := poScreenCenter;
borderstyle := bsToolWindow;
Caption := 'About My Component';
formstyle := fsSystemStayOnTop;
color := clSkyBlue;
Height := 240;
Width := 320;
// Create a BitBtn button
okbutton := TBitBtn.Create(tAboutForm);
// Set BitBtn properties
okbutton.Kind := bkClose;
okbutton.left := (Width div 2) - okbutton.Width div 2;
okbutton.top := Height - okbutton.Height - 10;
okbutton.parent := tAboutForm;
// Create a label control
lbl_Description := Tlabel.Create(tAboutForm);
// Set label properties
lbl_Description.left := 8;
lbl_Description.Top := 30;
lbl_Description.Width := 304;
lbl_Description.Height := 200;
lbl_Description.Autosize := False;
lbl_Description.Alignment := taCenter;
lbl_Description.Caption := sz;
lbl_Description.parent := tAboutForm;
// Display the dialog modally
ShowModal;
end;
finally
// Free all resources
FreeAndNil(lbl_Description);
FreeAndNil(okbutton);
FreeAndNil(tAboutForm);
end;
end;
function TAboutPropertyEditor.GetAttributes: TPropertyAttributes;
// Show the ellipsis
begin
Result := [paDialog];
end;
function TAboutPropertyEditor.GetValue: string;
// Override standard string read method
begin
Result := '(Double-click)';
end;
function TMyFileNamePropertyEditor.GetFilter: string;
begin
Result := 'All Files|*.*|Bitmaps|*.bmp|JPegs|*.jpg';
end;
function TMyFileNamePropertyEditor.GetDialogOptions: TOpenOptions;
begin
// To see the full list, drop an OpenDialog onto a form and see the Options property
Result := [ofFileMustExist, ofPathMustExist];
end;
function TMyFileNamePropertyEditor.GetDialogTitle: string;
begin
Result := 'My Custom Title';
end;
// == END PROPERTY EDITOR CODE ==
// Public method
procedure TExampleComponent.CallDoSomething;
// You can access the subcomponent's methods and properties
// in this component code
// Note: Changing the subcomponent's property at designtime in the Object Inspector works fine
begin
// Call the subcomponent's method
fsubcomponent.DoSomething;
// Access the Subcomponent's properties (note: not the private member fSubproperty2)
ShowMessageFmt('Procedure TMyVisualComponent.CallDoSomething: Subproperty2 = %s',
[fsubcomponent.Subproperty2]);
end;
// == PROPERTY GET/SETS ==
procedure TExampleComponent.SetProcessedString(AValue: string);
begin
// Check to see if a change is necessary
// Avalue can be amended before it is assigned to fProcessedString
if (fProcessedString <> AValue) then
fProcessedString := UpperCase(AValue);
end;
function TExampleComponent.GetProcessedString: string;
begin
// Do any error-checking or processing of fProcessedString here.
Result := fProcessedString;
end;
procedure TExampleComponent.SetTag(AValue: string);
// Overridden Tag property will only accept letters
// If changed via Object Inspector to a non-alpha string, then show custom error message
begin
if (fTag <> AValue) and (Length(AValue) > 0) then
if AValue[1] in ['A'..'Z'] + ['a'..'z'] then
fTag := AValue[1]
else
if ComponentState = [csDesigning] then
raise Exception.CreateFmt(C_ERRORMESSAGE,
[Name, 'You can only set the tag property to an alpha value']);
// 'Name' is the Name property of this TComponent instance
end;
function TExampleComponent.GetStringValue(const AIndex: integer): string;
begin
// Example of an indexed property Get method
// Retrieve from private string Array
Result := fStringArray[AIndex - 1];
end;
procedure TExampleComponent.SetStringValue(const AIndex: integer; AValue: string);
// Example of an indexed property Set method
// Value is stored in private string array
begin
if (fStringArray[AIndex - 1] <> AValue) then
fStringArray[AIndex - 1] := AValue;
end;
procedure TExampleComponent.SetStrings(const AValue: TStrings);
begin
// this is correct statement
FStringList.Assign(AValue);
// this is not correct
// FStrings := AValue;
end;
procedure TExampleComponent.SetFont(const AValue: TFont);
begin
// this is correct statement
fFont.Assign(AValue);
// this is not correct
// fFont := AValue;
end;
procedure TExampleComponent.SetBitMap(const AValue: TBitmap);
begin
// this is correct statement
fBitmap.Assign(AValue);
// this is not correct
// fBitmap := AValue;
end;
procedure TExampleComponent.SetHiddenString(const AValue: string);
// If value is changed then triggers the custom events OnChangeHiddenString and OnSample
begin
if (fHiddenString <> AValue) then
begin
fHiddenString := AValue;
// Trigger custom events
if Assigned(fOnChangeHiddenString) then
OnChangeHiddenString(Self);
if Assigned(fOnSample) then
OnSample(AValue);
end;
end;
// Sample application code that uses the Custom Events as coded
// Both are triggered by changing the HiddenString property in SetHiddenString
{
procedure TForm1.MyVisualComponent1ChangeHiddenString(Sender: TObject);
begin
ShowMessage('Hidden String was changed to something new');
end;
procedure TForm1.MyVisualComponent1Sample(MyText: String);
begin
ShowMessageFmt('Hidden String was changed to "%s"',[MyText]);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
MyVisualComponent1.HiddenString:='Hello World';
end;
}
end.

View File

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<Package Version="4">
<PathDelim Value="\"/>
<Name Value="myexamplepackage"/>
<Type Value="RunAndDesignTime"/>
<Author Value="minesadorada"/>
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<SearchPaths>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
</CompilerOptions>
<Description Value="Example component code to demonstrate how to handle many different types of properties"/>
<License Value="LGPL"/>
<Version Major="1" Minor="2"/>
<Files Count="1">
<Item1>
<Filename Value="myexamplecontrol.pas"/>
<HasRegisterProc Value="True"/>
<UnitName Value="MyExampleControl"/>
</Item1>
</Files>
<RequiredPkgs Count="4">
<Item1>
<PackageName Value="subcomponent"/>
</Item1>
<Item2>
<PackageName Value="IDEIntf"/>
</Item2>
<Item3>
<PackageName Value="LCL"/>
</Item3>
<Item4>
<PackageName Value="FCL"/>
</Item4>
</RequiredPkgs>
<UsageOptions>
<UnitPath Value="$(PkgOutDir)"/>
</UsageOptions>
<PublishOptions>
<Version Value="2"/>
</PublishOptions>
</Package>
</CONFIG>

View File

@ -0,0 +1,22 @@
{ This file was automatically created by Lazarus. Do not edit!
This source is only used to compile and install the package.
}
unit myexamplepackage;
{$warn 5023 off : no warning about unused units}
interface
uses
myexamplecontrol, LazarusPackageIntf;
implementation
procedure Register;
begin
RegisterUnit('myexamplecontrol', @myexamplecontrol.Register);
end;
initialization
RegisterPackage('myexamplepackage', @Register);
end.

View File

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<Package Version="4">
<PathDelim Value="\"/>
<Name Value="subcomponent"/>
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<SearchPaths>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Other>
<CompilerMessages>
<MsgFileName Value=""/>
</CompilerMessages>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
<Files Count="1">
<Item1>
<Filename Value="umysubcomponent.pas"/>
<HasRegisterProc Value="True"/>
<UnitName Value="uMySubComponent"/>
</Item1>
</Files>
<RequiredPkgs Count="1">
<Item1>
<PackageName Value="IDEIntf"/>
</Item1>
</RequiredPkgs>
<UsageOptions>
<UnitPath Value="$(PkgOutDir)"/>
</UsageOptions>
<PublishOptions>
<Version Value="2"/>
</PublishOptions>
</Package>
</CONFIG>

View File

@ -0,0 +1,14 @@
{ This file was automatically created by Lazarus. Do not edit!
This source is only used to compile and install the package.
}
unit subcomponent;
interface
uses
uMySubComponent;
implementation
end.

View File

@ -0,0 +1,56 @@
unit uMySubComponent;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs;
type
TMySubComponent = class(TComponent)
private
{ Private declarations }
fSubproperty1,fSubproperty2,fSubproperty3,fSubproperty4:String;
protected
{ Protected declarations }
public
{ Public declarations }
constructor Create(AOwner: TComponent); override; // Constructor must be public
destructor Destroy; override; // Destructor must be public
procedure DoSomething;
published
{ Published declarations }
property Subproperty1:String read fSubproperty1 write fSubproperty1;
property Subproperty2:String read fSubproperty2 write fSubproperty2;
property Subproperty3:String read fSubproperty3 write fSubproperty3;
property Subproperty4:String read fSubproperty4 write fSubproperty4;
end;
procedure Register;
implementation
procedure TMySubComponent.DoSomething;
begin
ShowMessageFmt('TMySubComponent.DoSomething called: Subproperty1=%s',[fSubproperty1]);
end;
Constructor TMySubComponent.Create(AOwner:TComponent);
begin
inherited Create(AOwner);
fSubproperty1:='One';
fSubproperty2:='Two';
end;
destructor TMySubComponent.Destroy;
begin
// Clean-up code goes here
// FreeandNil any user-created objects here
inherited Destroy;
end;
procedure Register;
begin
{$I umysubcomponent_icon.lrs}
RegisterComponents('Additional',[TMySubComponent]);
end;
end.

View File

@ -0,0 +1,51 @@
LazarusResources.Add('TMySubComponent','PNG',[
#137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#24#0#0#0#24#8#2#0#0#0'o'#21#170#175
+#0#0#0',tEXtCreation Time'#0'Sat 31 May 2014 18:57:51 -0000'#138#147'+1'#0#0
+#0#7'tIME'#7#222#5#31#17':'#30#230'85'#27#0#0#0#9'pHYs'#0#0#15#175#0#0#15#175
+#1#214#164'"m'#0#0#0#4'gAMA'#0#0#177#143#11#252'a'#5#0#0#4#29'IDATx'#218'eU'
+#203'n'#28'E'#20#173'['#221'='#239#183'g&'#182'Y'#216#138'e'#28#136#242'@ '
+#133#136#21'B'#145#144#16#27#22','#248#1#22#252#0#202#2#254''''#226'3X'#177
+' '#6';NP'#240'#'#182#231'='#158'G'#143#167#31'U]u'#185#253#154#1'1-uO'#223
+#170':u'#238#169'{O'#195#23#223#253#204#24'G'#134#192#194'[|1`'#12'1'#186'S'
+#12#232#25#254'aQ '#10'F'#183#245']'#19#4'0'#206#146'_'#184'"'#190#226#183'4'
+#22'a'#176'4'#156#194#173'^i'#144#199'\'#162#8#174'VC2'#25'Vk'#195#13'b'#220
+#20#16#210'e'#171#29#204#132'A'#152#192'j%'#198#17'\O'#139'XA'#12#129#8#255
+#218#154#1#167'H'#148#26'K'#152'b:'#24'O'#140#164#130#20#144#175#137#166#143
+'d'#223#4#215'\/J'#20'N'#184#199#219'E'#138#243'$C'#196#255#235#163'!'#153
+#206'#'#20#128'TZ'#218#217'` '#2#156'-'#165'eB'#189'l'#229#178't('#26'S'#18
+'l-'#214'Zlz'#154#201'ht'#17#170#208'z'#226#200#207#31'o>'#251#236#195'F'#181
+#232#251'r0'#186#249#253#232#239#147#211#145#212#150#226'&D'#5#129#171#195
+#193'D'#20#147#165'e'#194#1#150'^'#176#179'Y'#248#233#219'g'#31'?'#216#27#15
+#135'G'#199#175#148#134#172'i'#184#203#185#242'f'#227#137#147'-'#212#10#149
+'FR'''#24#23'Y'#152'='#134'@)'#157#165#31'|'#242'A'#235#199#239#191'jmTG'#195
+#241'//^'#28#31#254'v'#235#216#247#31'|'#202#209'zxo'#187'^'#171#157#189#235
+#158'\'#222'@'#190#137'!{4y'#204'0'#204';I-'#8'pw'#187#252#252#135#175#155
+#245#138#244#133#189#176#219'['#219#173'N'#211#152#242'J'#163#245#229#211''''
+#220'03'#185#188#148#242#229#203#195#222#197#25'h-'#148#209#153'a'#223'/#'#9
+#139#225#169#133'z'#205'='#249#252#155''''#205'f]{B'#8#153#203#230#155#173
+#246#193#163#167#197'R'#185'Z'#173#148'K'#197#229#237'\'#222'.'#152'o'#239'7'
+#220#135#13#152'M'#167'B'#186'RL'#127'}'#179#241'z'#185#143#220#162#212'Pi'
+#182#183']'#249#232#254']F;'#6#194#182#23#253#193#192#178#204#157#221#157#171
+#171'kw'#218#183#187#167#22#15#132#211#181#228'E)'#207'Y'#198#170#215#239'L'
+#186#234#252'mP'#181':'#185#160#225'f'#183'C'#177'E'#160#14'v6'#138#249'\'#16
+'('#215#245#166#211#185'F'#204'Z'#214#219#179#139'Z'#173'Z'#222'j{Br0'#236'q'
+'y'#216#13#138'n'#223#224#162'0'#235#150#134#179#250#200']6'#139#217#172'vPS'
+'j'#24'h'#221'l'#148#13#195#144'R'#184#174#175#181#210'J9'#174#243#222#246
+#214#210'q:'#195#241#209#209#235#227'W'#127#145'p4'#199#172#31#232'L'#163#144
+#203#238'r'#207#7#239#198#169'*'#8#171':dDR'#21#243#25'R'#140' '#226#6#245#5
+#213#147#158'L'''#167#231#151#215#221#254#31#199'o'#2')'#201'-'#138#141#199
+#133#141#187'tL'#136#250#148#229#160'HM'#175#227#182#9'O'#141#220#164'T'#202
+'S5H!#'#179#1#25#200#185'm_'#188#187'<'#252#243#164#215#27'z'#158#199#1#11
+#205'{'#229#141#29'D'#21#213'8'#152'a'#25'aj'#4'`'#166'-L'#13#5'y'#146'Ii)'#4
+'1'#186'u'#220#243#235'~o4'#243#3'M'#195#217'r'#187#186#249'~\'#211#171'N'
+#139#179'Il'#4'W'#238'AX'#28'|'#223#215'Ti'#153#140'Tl0^('#226'g'#154#150'iV'
+'Z'#187'`XQ'#19'C'#4#165'#.'#235#206'3y'#200#21#239'4k'#20#11'4jd'#138#4'@'
+#24#141'g3'#219#181#204#28#231#202#228#4'V'#136#219'3Z'#29'{'#18'&'#172'"'
+#163#9'}'#150#186#172'^-E'#18'2A'#242'h'#156#205#23#151#215'Cb'#24'&M'#206#5
+#144#218'(!'#164'VC:!'#143#147#132#216#176'+'#133'L'#189'R '#26'J'#161'B'#29
+#8'y'#213#25#204#23#203'deD'#0#165#147#26'njG'#255'u.n{'#193#163#253'v'#187
+'QQ'#212'o'#4#21#168#241'd'#210#27#140#28#215'%h'#170'C'#206#13#0'KzK ] n|'#6
+#171#143#4'$'#22#204'o'#28#185#183#219#202'X'#156'r'#10'S'#11#228'u'#167#219
+#235#15#169#229'H'#171#212#252#185#18'.'#211'*'#181'Z'#150'~"b;'#166'\'#241
+#31#149'yJ'#29#233','#195#24#0#0#0#0'IEND'#174'B`'#130
]);