Sign in Join
Wiki copytemporary

Adding an About dialog as a property to a custom component: what changed

Revision 3 to 4. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11## Summary
22
33This article is for writers of Lazarus visual components (descended from TComponent or descendants)
44
55- With the addition of a few lines of code to your component, it can display an 'About' property with an ellipsis button in the IDE Object Inspector
66- When the application programmer using your component clicks the button in the Object Inspector, a customised modal 'About' dialog is displayed with your info on it.
77- As well as an 'OK' button, the dialog can also display a 'License' button
88 - When clicked, this displays one of the standard licenses (GPL, LGPL etc) in a modal window
99
1010This is what the application programmer would see when he drops your component onto a form:
1111
1212#### Object Inspector example screenshot
1313
1414![](/wiki-images/e/ed/Screenshot_MyCustomComponent_ObjectInspector.png)
1515
1616#### About dialog example screenshot
1717
1818- Clicking the ellipse button shows this:
1919
2020![](/wiki-images/1/18/Screenshot_MyCustomComponent_AboutBox.png)
2121
2222#### License screen example screenshot
2323
2424- Clicking the License button shows this:
2525
2626![](/wiki-images/c/c1/Screenshot_MyCustomComponent_LGPL_LicenseScreen.png)
2727
2828## Download example code
2929
3030You can download the full source as described in this article from the lazarus CCR [here](https://sourceforge.net/p/lazarus-ccr/svn/HEAD/tree/components/)
3131
3232## Adding an About property to your new or existing component
3333
3434- Add the files aboutcomponentunit.pas and license.lrs to your component directory
3535
36361. Rename aboutcomponentunit.pas to about\<yourcomponentname\>unit.pas
37372. In the pas file rename the Unit to match (1)
38383. Open the renamed pas file and do Search/Replace to change all instances of "TAboutComponent" to TAbout\<yourcomponentname\>
39394. In the line TAboutComponent = Class(TComponent), change the ancestor to your component's ancestor (if it's not TComponent)
40405. Add the edited pas file to your component's package
41416. In your component's class declaration, change it's ancestor to TAbout\<yourcomponentname\> (from step 3)
42427. Compile, install and see the new clickable 'About' property in your component!
4343
4444### Configuring the About property dialog
4545
4646- In your component's Constructor Create() set some, all or none of the following properties:
4747 - AboutBoxComponentName (string)
4848 - AboutBoxWidth (integer)
4949 - AboutBoxHeight (integer)
5050 - AboutBoxDescription (string - can contain LineEndings)
5151 - AboutBoxBackgroundColor (TColor, like clWhite)
5252 - AboutBoxFontName (string)
5353 - AboutBoxFontSize (integer)
5454 - AboutBoxVersion (string)
5555 - AboutBoxAuthorname (string)
5656 - AboutBoxOrganisation (string)
5757 - AboutBoxAuthorEmail (string)
5858 - AboutBoxLicenseType (string e.g. 'GPL', ModifiedGPL' etc)
5959- You will have to recompile and reinstall your component to see the results.
6060
6161## Example
6262
6363- Using the component [[ScrollText]] (available [here](http://www.charcodelvalle.com/scrollingtext/scrollingtext_component.zip))
6464 - I have already renamed the AboutComponentunit to AboutScrolltextunit, and changed the class name from TAboutComponent to TAboutScrollText
6565- TScrolltext is dereived from TGraphicControl so in the AboutScrollText unit I alter:
6666
67-```
67+```text
6868TAboutScrollText = class(TComponent)
6969```
7070
7171to
7272
73-```
73+```text
7474TAboutScrollText = class(TGraphicControl)
7575```
7676
7777- Then in my scrolltext unit, I change
7878
79-```
79+```text
8080TScrollingText = class(TGraphicControl)
8181```
8282
8383to
8484
85-```
85+```text
8686TScrollingText = class(TAboutScrollText)
8787```
8888
8989- Now the Scrolltext component has an 'About' property, but with default values.
9090- So in my TScrollingText constructor, I now set my own values:
9191
9292``` pascal
9393constructor TScrollingText.Create(AOwner: TComponent);
9494begin
9595 inherited Create(AOwner);
9696..other constructor code..
9797 // About dialog
9898 AboutBoxComponentName:='ScrollingText component';
9999 AboutBoxWidth:=400;
100100 // AboutBoxHeight (integer)
101101 AboutBoxDescription:='Component that shows a scrolling window.' + LineEnding +
102102 'Use Lines property to set text and Active=True' + LineEnding +
103103 'to use the component';
104104 AboutBoxBackgroundColor:=clWindow;
105105 AboutBoxFontName:='Arial';
106106 AboutBoxFontSize:=10;
107107 AboutBoxVersion:=C_VERSION;
108108 AboutBoxAuthorname:='Gordon Bamber';
109109 AboutBoxOrganisation:='Public Domain';
110110 AboutBoxAuthorEmail:='minesadorada@charcodelvalle.com';
111111 AboutBoxLicenseType:='LGPL';
112112end;
113113```
114114
115115- I then compile and install the scroller component to the IDE palette, and the 'About' property is part of the component.
116116
117117## See Also
118118
119119- [[Lazarus Nongraphical Visual Component Example Code]]
120120- [[ScrollText]]
121121
122122---
123123*From the Free Pascal wiki, page "Adding an About dialog as a property to a custom component", as it stood on 2016-07-15 after a change by Arent, 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).*
124124Category: Component Creation
125125Category: Lazarus-CCR

Back to history