Sign in Join
Wiki copytemporary

How To Write Lazarus Component/it: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11## Introduzione
22
33Questa è una guida di base su come costruire componenti. È stata testata su Lazarus 0.9.30 eseguito in Windows 7.
44
55## Passo 1: Creare il Package
66
77- Nel menu di Lazarus IDE, click su **Package \> Nuovo Package** per eseguire il Package Manager.
88
9-<figure>
10-<img src="package_menu_it.png" title="package_menu_it.png" />
11-<figcaption>package_menu_it.png</figcaption>
12-</figure>
9+![](/wiki-images/c/c2/Package_menu_it.png)
1310
1411- Apparirà la **finestra di dialog Salva file**. Scegli una cartella e un nome e salva. Se l'IDE propone di utilizzare le minuscole per il nome file, premi 'OK'.
1512
1613- Congratulazioni: hai appena creato il tuo primo Package!
1714
18-<figure>
19-<img src="nuovo_package.png" title="nuovo_package.png" />
20-<figcaption>nuovo_package.png</figcaption>
21-</figure>
15+![](/wiki-images/0/0d/Nuovo_package.png)
2216
2317## Passo 2: Creare la Unit
2418
2519Puoi creare una nuova unit o usare un file esistente.
2620
2721### Crea una Nuova Unit
2822
2923- Usa il pulsante **Aggiungi \> Nuovo componente**.
3024
31-<figure>
32-<img src="nuovo_componente.png" title="nuovo_componente.png" />
33-<figcaption>nuovo_componente.png</figcaption>
34-</figure>
25+![](/wiki-images/6/6e/Nuovo_componente.png)
3526
3627- Scegli un componente come TComboBox.
3728- Scegli *customcontrol1.pas* come mome file.
3829- Clicca OK.
3930
4031``` pascal
4132unit CustomControl1;
4233
4334{$mode objfpc}{$H+}
4435
4536interface
4637
4738uses
4839 Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, StdCtrls;
4940
5041type
5142 TCustomControl1 = class(TComboBox)
5243 private
5344 { Private declarations }
5445 protected
5546 { Protected declarations }
5647 public
5748 { Public declarations }
5849 published
5950 { Published declarations }
6051 end;
6152
6253procedure Register;
6354
6455implementation
6556
6657procedure Register;
6758begin
6859 RegisterComponents('Standard',[TCustomControl1]);
6960end;
7061
7162end.
7263```
7364
7465- Installa il package cliccando il bottone 'install' in alto nel package editor.
7566
76-<figure>
77-<img src="package_install_it.png" title="package_install_it.png" />
78-<figcaption>package_install_it.png</figcaption>
79-</figure>
67+![](/wiki-images/9/93/Package_install_it.png)
8068
8169- Quindi l'IDE chiederà se si vuole che venga fatto il rebuild dell'IDE. Cliccare yes.
8270
83-<figure>
84-<img src="package_rebuild_it.png" title="package_rebuild_it.png" />
85-<figcaption>package_rebuild_it.png</figcaption>
86-</figure>
71+![](/wiki-images/1/16/Package_rebuild_it.png)
8772
8873- Riavviato Lazarus potrete vedere il vostro nuovo componente nella component palette. Congratulazioni: Avete appena installato il vostro primo package con il vostro primo componente.
8974
90-<figure>
91-<img src="componente_installato.png" title="componente_installato.png" />
92-<figcaption>componente_installato.png</figcaption>
93-</figure>
75+![](/wiki-images/d/d1/Componente_installato.png)
9476
9577*Nota:* Se non vedete il vostro nuovo componente nella palette dei componenti, molto probabilmente state eseguendo una versione non ricompilata di Lazarus. Potete impostare dove Lazarus effettua il build in: Strumenti -\> Opzioni -\> File -\> Cartella di Lazarus. Invece di eseguire lazarus direttamente, potete anche usare startlazarus, che esegue lazarus più recentemente compilato, per esempio l'eseguibile di lazarus nella cartella ~/.lazarus, se non avete i diritti di scrittura nella cartella in cui è installato lazarus.
9678
9779### Aggiungi una Unit esistente
9880
9981Se avete già una unit potete aggiungerla al package:
10082
101-<figure>
102-<img src="package_add_unit_it.png" title="package_add_unit_it.png" />
103-<figcaption>package_add_unit_it.png</figcaption>
104-</figure>
83+![](/wiki-images/1/13/Package_add_unit_it.png)
10584
10685- Fate Click sul pulsante **Aggiungi**, andate sul tab **Aggiungi File**. Cliccato il pulsante Esplora, cercate il vostro file. Fate Click su **Aggiungi file al pacchetto**. Se il gestore pacchetti lamenta che la unit non è nella cartella, accettate di aggiungere la directory al percorso nel unit path.
10786- Fate Click ancora su **Aggiungi** , andate sul tab **Aggiungi File** e cercate il file *.lrs*, quindi fate click su OK (Vedete il Passo 3 per creare il file dell'icona ).
10887- Fate Click di nuovo su **Aggiungi**, andate sul tab **Nuovo requisito**, selezionate **LCL** in Nome pacchetto e fate click su OK.
10988
11089Il risultato finale dovrebbe assomigliare a questo:
11190
11291![`Package Maker`](/wiki-images/d/d9/How_to_write_lazarus_component_package_maker_done.png)
11392
11493- Click on under the Files tree in the Package Manager. In the File Properties, make sure *Register unit* is checked.
11594- Click the Options button. Select the IDE Integration tab. At the Package Type make sure Designtime and Runtime is selected.
11695- Click the Compile button to check to see if the files compile without errors.
11796- Click the Install button, Lazarus will rebuild and restart automatically.
11897
11998The component is created and ready to be used:
12099
121100![`Component Created`](/wiki-images/3/3c/How_to_write_lazarus_component_created.png)
122101
123102## Passo 3: Creare Icone Per Il Package
124103
125104La dimensione del file PNG dovrebbe essere 24x24. Il formato icona utilizzato è *.lrs*.
126105
127106### Usa Lazarus Image Editor
128107
129108Puoi usare [[Lazarus Image Editor]] per creare le icons nel formato .lrs.
130109
131110### Usa lazres
132111
133112Potresti aver bisogno di compilare lazres al primo utilizzo. Semplicemente apri *lazres.lpi* nell'IDE e scegli nel menu **run \> build**.
134113
135114**Crea file lrs**
136115
137116Per creare il file lrs esegui:
138117
139118`~/lazarus/tools/lazres samplepackage.lrs TMyCom.png`
140119
141120Dove *samplepackage* è il nome del tuo package e *TMyCom* è il nome del tuo componente.
142121
143122You can add more than one image to the lrs file by appending the image filename at the end. Eg. ~/lazarus/tools/lazres samplepackage.lrs TMyCom.png TMyOtherCom.png ...
144123
145124**Sample**
146125
147126Following is a sample of the resulting *samplepackage.lrs* file.
148127
149128 LazarusResources.Add('TMyCom','PNG',[
150129 #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
151130 +#0#0#0#4'gAMA'#0#0#177#143#11#252'a'#5#0#0#0'|IDAT8O'#237#212#209#10#192' '#8
152131 +#5'P'#247#231#251's'#215#138#133#164#166'\'#220#195'`'#209'c'#157'L'#173#131
153132 +#153#169'd4'#168'dP'#137'r_'#235'5'#136'@Zmk'#16'd9'#144#176#232#164'1'#247
154133 +'I'#8#160'IL'#206'C'#179#144#12#199#140'.'#134#244#141'~'#168#247#209'S~;'#29
155134 +'V+'#196#201'^'#10#15#150'?'#255#18#227#206'NZ>42'#181#159#226#144#15'@'#201
156135 +#148#168'e'#224'7f<@4'#130'u_YD'#23#213#131#134'Q]'#158#188#135#0#0#0#0'IEND'
157136 +#174'B`'#130
158137 ]);
159138
160139## Recompiling Packages
161140
162141You need to rebuild the package everytime you make changes to the *mycom.pas* file. To rebuild the package, open the *samplepackage.lpk* file in the Package Manager and click the Install button.
163142
164143## Removing Packages
165144
166145- To remove installed components, on the IDE menu, click Package \> Configure installed packages. The following image shows the Installed Packages tool.
167146
168147![`Installed Components`](/wiki-images/0/0e/How_to_write_lazarus_component_installed_components.png)
169148
170149- Select the package you want to uninstall and click Uninstall selection.
171150
172151If something goes wrong with a package (e.g. package directory is deleted without first uninstalling it), Lazarus may not allow you to uninstall packages. To fix the problem, at the IDE menu click Tools \> Build Lazarus. Lazarus will rebuild all packages and restart. You should now be able to uninstall problematic packages.
173152
174153## Enhancing mycom.pas
175154
176155- The codes in *mycom.pas* above gives you the basics on what you need to create a component. The following is an enhanced version with some tips on how to write procedures and events for components.
177156- The *OnChange2* shows how to create events
178157- The *OnSample* shows how to create custom events
179158- *MyText* and *MyText2* shows different ways to write properties.
180159- You can use TComboBox instead of TCustomComboBox as the base class, which publishes all properties as TComboBox.
181160- If TCustomComboBox is used as the base class, you'll notice a lot of properties and events will be missing at the Object Inspector in the IDE. To add those properties and events just copy and paste the properties as listed below *// properties from TComboBox*. These list of properties can be got from the TComboBox declaration in the StdCtrls unit. Omit any property which you want to handle yourself.
182161
183162``` pascal
184163unit mycom;
185164
186165{$mode objfpc}{$H+}
187166
188167interface
189168
190169uses
191170 Classes, SysUtils, StdCtrls, Forms, Dialogs,
192171 LCLType,LCLIntf,lresources,LCLProc;
193172
194173type
195174
196175 TSampleEvent = procedure(MyText: String) of Object;
197176
198177 TMyCom = class (TCustomComboBox)
199178 private
200179 FMyText: String;
201180 FOnChange2: TNotifyEvent;
202181 FOnSample: TSampleEvent;
203182 public
204183 constructor Create(TheOwner: TComponent); override;
205184 procedure CreateWnd; override;
206185 procedure Change; override;
207186 protected
208187 function GetMyText2: String;
209188 procedure SetMyText2(MyText: String);
210189 published
211190 property MyText: String read FMyText write FMyText;
212191 property MyText2: String read GetMyText2 write SetMyText2;
213192 property OnChange2: TNotifyEvent read FOnChange2 write FOnChange2;
214193 property OnSample: TSampleEvent read FOnSample write FOnSample;
215194
216195 // properties from TComboBox
217196 property Align;
218197 property Anchors;
219198 property ArrowKeysTraverseList;
220199 property AutoComplete;
221200 property AutoCompleteText;
222201 property AutoDropDown;
223202 property AutoSelect;
224203 property AutoSize;
225204 property BidiMode;
226205 property BorderSpacing;
227206 property CharCase;
228207 property Color;
229208 property Ctl3D;
230209 property Constraints;
231210 property DragCursor;
232211 property DragMode;
233212 property DropDownCount;
234213 property Enabled;
235214 property Font;
236215 property ItemHeight;
237216 property ItemIndex;
238217 property Items;
239218 property ItemWidth;
240219 property MaxLength;
241220 property OnChange;
242221 property OnChangeBounds;
243222 property OnClick;
244223 property OnCloseUp;
245224 property OnContextPopup;
246225 property OnDblClick;
247226 property OnDragDrop;
248227 property OnDragOver;
249228 property OnDrawItem;
250229 property OnEndDrag;
251230 property OnDropDown;
252231 property OnEditingDone;
253232 property OnEnter;
254233 property OnExit;
255234 property OnGetItems;
256235 property OnKeyDown;
257236 property OnKeyPress;
258237 property OnKeyUp;
259238 property OnMeasureItem;
260239 property OnMouseDown;
261240 property OnMouseMove;
262241 property OnMouseUp;
263242 property OnStartDrag;
264243 property OnSelect;
265244 property OnUTF8KeyPress;
266245 property ParentBidiMode;
267246 property ParentColor;
268247 property ParentCtl3D;
269248 property ParentFont;
270249 property ParentShowHint;
271250 property PopupMenu;
272251 property ReadOnly;
273252 property ShowHint;
274253 property Sorted;
275254 property Style;
276255 property TabOrder;
277256 property TabStop;
278257 property Text;
279258 property Visible;
280259 end;
281260
282261procedure Register;
283262
284263implementation
285264
286265procedure Register;
287266begin
288267 RegisterComponents('Sample',[TMyCom]);
289268end;
290269
291270constructor TMyCom.Create(TheOwner: TComponent);
292271begin
293272 inherited Create(TheOwner);
294273 Self.Style := csDropDownList;
295274end;
296275
297276procedure TMyCom.CreateWnd;
298277begin
299278 inherited CreateWnd;
300279 Items.Assign(Screen.Fonts);
301280end;
302281
303282procedure TMyCom.Change;
304283begin
305284 inherited;
306285 if Assigned(FOnChange2) then FOnChange2(Self);
307286 if Assigned(FOnSample) then FOnSample(FMyText);
308287end;
309288
310289function TMyCom.GetMyText2: String;
311290begin
312291 Result:=FMyText;
313292end;
314293
315294procedure TMyCom.SetMyText2(MyText: String);
316295begin
317296 FMyText:=MyText;
318297end;
319298
320299initialization
321300 {$I samplepackage.lrs}
322301
323302end.
324303```
325304
326305## Using embedded (visual) components
327306
328307It's possible to use standard components embedded in your own components (look for example at TLabeledEdit or TButtonPanel). Let's say you want to create a custom panel with a TLabel on it. With the steps described above the base package and source files can be created. Now to add a TLabel to the component, do the following:
329308
330309- Add a private attribute for the label component (FEmbeddedLabel: TLabel;).
331310- Add a published read-only property for the label component (property EmbeddedLabel: TLabel read FEmbeddedLabel;)
332311- Create the label in the component's (overridden) constructor (FEmbeddedLabel := TLabel.Create(self); )
333312- Set the parent of the component (FEmbeddedLabel.Parent := self;)
334313- If the component to be embedded is not a 'subcomponent' by default (like TBoundLabel, TPanelBitBtn etc.) then add the call to SetSubComponent. This is necessary for the IDE so it knows that it has to store the properties of the embedded component as well. TLabel is not a subcomponent by default so the call to the method must be added (FEmbeddedLabel.SetSubComponent(true);).
335314
336315To sum it up you would get something like this (only the essential parts are shown):
337316
338317``` pascal
339318TEnhancedPanel = class(TCustomControl)
340319private
341320 { The new attribute for the embedded label }
342321 FEmbeddedLabel: TLabel;
343322
344323public
345324 { The constructor must be overriden so the label can be created }
346325 constructor Create(AOwner: TComponent); override;
347326
348327published
349328 { Make the label visible in the IDE }
350329 property EmbeddedLabel: TLabel read FEmbeddedLabel;
351330end;
352331
353332implementation
354333
355334constructor TEnhancedPanel.Create(AOwner: TComponent);
356335begin
357336 inherited Create(AOwner);
358337
359338 // Set default width and height
360339 with GetControlClassDefaultSize do
361340 SetInitialBounds(0, 0, CX, CY);
362341
363342 // Add the embedded label
364343 FEmbeddedLabel := TLabel.Create(Self); // Add the embedded label
365344 FEmbeddedLabel.Parent := self; // Show the label in the panel
366345 FEmbeddedLabel.SetSubComponent(true); // Tell the IDE to store the modified properties
367346 FLabel.Name := 'EmbeddedLabel';
368347 FLabel.Caption := 'Howdy World!';
369348
370349 // Make sure the embedded label can not be selected/deleted within the IDE
371350 FLabel.ControlStyle := FLabel.ControlStyle - [csNoDesignSelectable];
372351
373352 // Set other properties if necessary
374353 //...
375354
376355end;
377356```
378357
379358## Using custom paint procedure
380359
381360You can always subclass a component inside your program. For example, this implements a custom Paint procedure to a TLabel:
382361
383362``` pascal
384363type
385364 TMyLabel = class(TLabel)
386365 public
387366 procedure Paint; override;
388367 end;
389368{...}
390369implementation
391370{...}
392371procedure TMyLabel.Paint;
393372begin
394373 // your code to implement Paint, for example
395374 Canvas.TextOut(0,0,Caption);
396375end;
397376```
398377
399378Now you can create a MyLabel inside your program, at run time, with that overridden Paint procedure instead of the standard one.
400379
401380For most components, and for most methods, it would be recommendable to call inherited procedure iniside it:
402381
403382``` pascal
404383procedure TMyLabel.Paint;
405384begin
406385
407386 inherited Paint; /////////////////////
408387
409388 // your code to implement Paint, for example
410389 Canvas.TextOut(0,0,Caption);
411390end;
412391```
413392
414393But inherited behavior is not desirable in this case, since the second writing action would overlap the first (inherited) one.
415394
416395## Integrating the Component with the IDE
417396
418397### Property Editors
419398
420399Property editors provide custom dialogs to edit properties in the object inspector. For most properties, like strings, string lists, images, enumerated types and others, there are already default property editors, but if a custom component has a special kind of property it may require a custom dialog to edit the property. Each property editor is a class, which should descend from TPropertyEditor or one of it's descendents and implement methods from this base class. They should be registered in the 'Register' procedure by using the function RegisterPropertyEditor from the unit PropEdits. It is a standard to name property editors with the property name followed by 'Property', for example TFieldProperty for the property editor of the TField property.
421400
422401``` pascal
423402 TPropertyEditor = class
424403 public
425404 function AllEqual: Boolean; Virtual;
426405 function AutoFill: Boolean; Virtual;
427406 procedure Edit; Virtual; // Activated by double-clicking the property value
428407 procedure ShowValue; Virtual; // Activated by control-clicking the property value
429408 function GetAttributes: TPropertyAttributes; Virtual;
430409 function GetEditLimit: Integer; Virtual;
431410 function GetName: ShortString; Virtual;
432411 procedure GetProperties(Proc: TGetPropEditProc); Virtual;
433412 function GetHint(HintType: TPropEditHint; x, y: integer): String; Virtual;
434413 function GetDefaultValue: AnsiString; Virtual;
435414 procedure GetValues(Proc: TGetStrProc); Virtual;
436415 procedure SetValue(const NewValue: AnsiString); Virtual;
437416 procedure UpdateSubProperties; Virtual;
438417 function SubPropertiesNeedsUpdate: Boolean; Virtual;
439418 function IsDefaultValue: Boolean; Virtual;
440419 function IsNotDefaultValue: Boolean; Virtual;
441420 // ... shortened
442421 end;
443422```
444423
445424A good example for a property editor is the TFont property editor.
446425
447426One of the most common cases for property editors is properties which are classes, because classes have many fields and can have a variety of formats, it's not possible for Lazarus to have the object inspector edit field able to edit it, like is done for strings and numeric types. For classes a convention is to have the value field show permanently the name of the class in parentheses, for example „(TFont)“ and the „...“ button shows a dialog to edit this class. This behavior, except for the dialog, is implemented by a standard property editor for classes called TClassPropertyEditor, which can be inherited from when writing property editors for classes:
448427
449428``` pascal
450429TClassPropertyEditor = class(TPropertyEditor)
451430public
452431 constructor Create(Hook: TPropertyEditorHook; APropCount: Integer); Override;
453432 function GetAttributes: TPropertyAttributes; Override;
454433 procedure GetProperties(Proc: TGetPropEditProc); Override;
455434 function GetValue: AnsiString; Override;
456435 property SubPropsTypeFilter: TTypeKinds Read FSubPropsTypeFilter
457436 Write SetSubPropsTypeFilter
458437 Default tkAny;
459438end;
460439```
461440
462441Going back to the TFont example, inheriting from TClassPropertyEditor already offers part of the desired behavior and then the TFontPropertyEditor class only needs to implement showing the dialog in the Edit method and set the attributes for the editor:
463442
464443``` pascal
465444 TFontPropertyEditor = class(TClassPropertyEditor)
466445 public
467446 procedure Edit; Override;
468447 function GetAttributes: TPropertyAttributes; Override;
469448 end;
470449
471450procedure TFontPropertyEditor.Edit;
472451var
473452 FontDialog: TFontDialog;
474453begin
475454 FontDialog := TFontDialog.Create(NIL);
476455 try
477456 FontDialog.Font := TFont(GetObjectValue(TFont));
478457 FontDialog.Options := FontDialog.Options + [fdShowHelp, fdForceFontExist];
479458 if FontDialog.Execute then SetPtrValue(FontDialog.Font);
480459 finally
481460 FontDialog.Free;
482461 end;
483462end;
484463
485464function TFontPropertyEditor.GetAttributes: TPropertyAttributes;
486465begin
487466 Result := [paMultiSelect, paSubProperties, paDialog, paReadOnly];
488467end;
489468```
490469
491470### Component Editors
492471
493472Component editors control the behavior of right-clicking and double clicking components in the form designer. Each component editor is a class, which should descend from TComponentEditor or one of it's descendents and implement methods from this base class. They should be registered in the 'Register' procedure by using the function RegisterComponentEditor from the unit ComponentEditors. It is a standard to name component editors with the component name followed by 'Editor', for example TStringGridComponentEditor for the property editor of the TStringGrid component. Although user component editors should be based in TComponentEditor, most of it's methods are actually from an ancestor, so it is necessary to also know TBaseComponentEditor:
494473
495474``` pascal
496475 TBaseComponentEditor = class
497476 protected
498477 public
499478 constructor Create(AComponent: TComponent;
500479 ADesigner: TComponentEditorDesigner); Virtual;
501480 procedure Edit; Virtual; Abstract;
502481 procedure ExecuteVerb(Index: Integer); Virtual; Abstract;
503482 function GetVerb(Index: Integer): String; Virtual; Abstract;
504483 function GetVerbCount: Integer; Virtual; Abstract;
505484 procedure PrepareItem(Index: Integer; const AnItem: TMenuItem); Virtual; Abstract;
506485 procedure Copy; Virtual; Abstract;
507486 function IsInInlined: Boolean; Virtual; Abstract;
508487 function GetComponent: TComponent; Virtual; Abstract;
509488 function GetDesigner: TComponentEditorDesigner; Virtual; Abstract;
510489 function GetHook(out Hook: TPropertyEditorHook): Boolean; Virtual; Abstract;
511490 procedure Modified; Virtual; Abstract;
512491 end;
513492```
514493
515494The most important method of a component editor is Edit, which is called when the component is double clicked. When the context menu for the component is invoked the GetVerbCount and GetVerb methods are called to build the menu. If one of the verbs (which means menu items in this case) are selected, ExecuteVerb is called. There is a default component editor (TDefaultEditor) which implements Edit to search the properties of the component for the most appropriate one to be edited. It usually chooses an event, which is edited by adding it's skeleton code in the code editor and setting the cursor to be in place to add code for it.
516495
517496Other important methods from TBasComponentEditor are: ExecuteVerb(Index), which executes one of the extra menu items placed on the right-click popup menu; GetVerb – To return the name of each extra popup menu item. Note that t is the responsibility of the component editor to place special menu item caption characters like & to create a keyboard accelerator and “-” to create a separator; GetVerbCount – Returns the amount of items to be added to the popup menu. The index for the routines GetVerb and ExecuteVerb is zero based, going from 0 to GetVerbCount – 1; PrepareItem – Called for each verb after the menu item was created. Allows the menu item to be customized such as by adding subitems, adding a checkbox or even hiding it by setting Visible to false; Copy - Called when the component is being copied to the clipboard. The component data for use by Lazarus will always be added and cannot be modified. This method is instead for adding a different kind of clipboard information to paste the component in other applications, but which won't affect the Lazarus paste.
518497
519498A simple and interesting example is the TCheckListBox component editor which creates a dialog to edit. More convenient then implementing all methods from TBaseComponentEditor is inheriting from TComponentEditor, and this is what TCheckListBoxEditor does. This base class adds empty implementations for most methods and some default ones for others. For Edit it calls ExecuteVerb(0), so if the first item will be identical to the double-click action, which is a convention for editor, there is no need to implement Edit. This basic action for the double-click and first menu item is often a dialog, and for TCheckListBox this is also done:
520499
521500``` pascal
522501 TCheckListBoxComponentEditor = class(TComponentEditor)
523502 protected
524503 procedure DoShowEditor;
525504 public
526505 procedure ExecuteVerb(Index: Integer); override;
527506 function GetVerb(Index: Integer): String; override;
528507 function GetVerbCount: Integer; override;
529508 end;
530509
531510procedure TCheckGroupComponentEditor.DoShowEditor;
532511var
533512 Dlg: TCheckGroupEditorDlg;
534513begin
535514 Dlg := TCheckGroupEditorDlg.Create(NIL);
536515 try
537516 // .. shortened
538517 Dlg.ShowModal;
539518 // .. shortened
540519 finally
541520 Dlg.Free;
542521 end;
543522end;
544523
545524procedure TCheckGroupComponentEditor.ExecuteVerb(Index: Integer);
546525begin
547526 case Index of
548527 0: DoShowEditor;
549528 end;
550529end;
551530
552531function TCheckGroupComponentEditor.GetVerb(Index: Integer): String;
553532begin
554533 Result := 'CheckBox Editor...';
555534end;
556535
557536function TCheckGroupComponentEditor.GetVerbCount: Integer;
558537begin
559538 Result := 1;
560539end;
561540```
562541
563542## Reference
564543
565544- [[Extending the IDE]]
566545- [[Lazarus Packages]] - A guide for creating a package under Lazarus
567546- [[Components and Code examples]]
568547- [[Lazarus Components]]
569548- [[IDE Window: Add to Package]]
570549
571550You can post questions regarding this page [here](http://forum.lazarus.freepascal.org/index.php/topic,5789.0.html)
572551
573552# Questa pagina
574553
575554Questa pagina è in corso di traduzione dalla [[How To Write Lazarus Component|corrispondente pagina inglese]]
576555
577556## Author
578557
579558[[User talk:Tpglemur|Original Author]]
580559
581560Tradotta da User:JohnCat
582561
583562---
584563*From the Free Pascal wiki, page "How To Write Lazarus Component/it", as it stood on 2020-02-17 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history