Sign in Join
Wiki copytemporary

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

Revision 1 to 2. 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
14-<figure>
15-<img src="Screenshot_MyCustomComponent_ObjectInspector.png" title="Screenshot_MyCustomComponent_ObjectInspector.png" />
16-<figcaption>Screenshot_MyCustomComponent_ObjectInspector.png</figcaption>
17-</figure>
14+![](/wiki-images/e/ed/Screenshot_MyCustomComponent_ObjectInspector.png)
1815
1916#### About dialog example screenshot
2017
2118- Clicking the ellipse button shows this:
2219
23-<figure>
24-<img src="Screenshot_MyCustomComponent_AboutBox.png" title="Screenshot_MyCustomComponent_AboutBox.png" />
25-<figcaption>Screenshot_MyCustomComponent_AboutBox.png</figcaption>
26-</figure>
20+![](/wiki-images/1/18/Screenshot_MyCustomComponent_AboutBox.png)
2721
2822#### License screen example screenshot
2923
3024- Clicking the License button shows this:
3125
32-<figure>
33-<img src="Screenshot_MyCustomComponent_LGPL_LicenseScreen.png" title="Screenshot_MyCustomComponent_LGPL_LicenseScreen.png" />
34-<figcaption>Screenshot_MyCustomComponent_LGPL_LicenseScreen.png</figcaption>
35-</figure>
26+![](/wiki-images/c/c1/Screenshot_MyCustomComponent_LGPL_LicenseScreen.png)
3627
3728## Download example code
3829
3930You 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/)
4031
4132## Adding an About property to your new or existing component
4233
4334- Add the files aboutcomponentunit.pas and license.lrs to your component directory
4435
45361. Rename aboutcomponentunit.pas to about\<yourcomponentname\>unit.pas
46372. In the pas file rename the Unit to match (1)
47383. Open the renamed pas file and do Search/Replace to change all instances of "TAboutComponent" to TAbout\<yourcomponentname\>
48394. In the line TAboutComponent = Class(TComponent), change the ancestor to your component's ancestor (if it's not TComponent)
49405. Add the edited pas file to your component's package
50416. In your component's class declaration, change it's ancestor to TAbout\<yourcomponentname\> (from step 3)
51427. Compile, install and see the new clickable 'About' property in your component!
5243
5344### Configuring the About property dialog
5445
5546- In your component's Constructor Create() set some, all or none of the following properties:
5647 - AboutBoxComponentName (string)
5748 - AboutBoxWidth (integer)
5849 - AboutBoxHeight (integer)
5950 - AboutBoxDescription (string - can contain LineEndings)
6051 - AboutBoxBackgroundColor (TColor, like clWhite)
6152 - AboutBoxFontName (string)
6253 - AboutBoxFontSize (integer)
6354 - AboutBoxVersion (string)
6455 - AboutBoxAuthorname (string)
6556 - AboutBoxOrganisation (string)
6657 - AboutBoxAuthorEmail (string)
6758 - AboutBoxLicenseType (string e.g. 'GPL', ModifiedGPL' etc)
6859- You will have to recompile and reinstall your component to see the results.
6960
7061## Example
7162
7263- Using the component [[ScrollText]] (available [here](http://www.charcodelvalle.com/scrollingtext/scrollingtext_component.zip))
7364 - I have already renamed the AboutComponentunit to AboutScrolltextunit, and changed the class name from TAboutComponent to TAboutScrollText
7465- TScrolltext is dereived from TGraphicControl so in the AboutScrollText unit I alter:
7566
7667`TAboutScrollText = class(TComponent) `
7768
7869to
7970
8071`TAboutScrollText = class(TGraphicControl) `
8172
8273- Then in my scrolltext unit, I change
8374
8475`TScrollingText = class(TGraphicControl) `
8576
8677to
8778
8879`TScrollingText = class(TAboutScrollText) `
8980
9081- Now the Scrolltext component has an 'About' property, but with default values.
9182- So in my TScrollingText constructor, I now set my own values:
9283
9384`constructor TScrollingText.Create(AOwner: TComponent);`\
9485`begin`\
9586` inherited Create(AOwner);  `\
9687`..other constructor code..`\
9788`   // About dialog`\
9889` AboutBoxComponentName:='ScrollingText component';`\
9990` AboutBoxWidth:=400;`\
10091` // AboutBoxHeight (integer)`\
10192` AboutBoxDescription:='Component that shows a scrolling window.' + LineEnding +`\
10293` 'Use Lines property to set text and Active=True' + LineEnding +`\
10394` 'to use the component';`\
10495` AboutBoxBackgroundColor:=clWindow;`\
10596` AboutBoxFontName:='Arial';`\
10697` AboutBoxFontSize:=10;`\
10798` AboutBoxVersion:=C_VERSION;`\
10899` AboutBoxAuthorname:='Gordon Bamber';`\
109100` AboutBoxOrganisation:='Public Domain';`\
110101` AboutBoxAuthorEmail:='minesadorada@charcodelvalle.com';`\
111102` AboutBoxLicenseType:='LGPL';`\
112103`end;`
113104
114105- I then compile and install the scroller component to the IDE palette, and the 'About' property is part of the component.
115106
116107## See Also
117108
118109- [[Lazarus Nongraphical Visual Component Example Code]]
119110- [[ScrollText]]
120111
121112---
122113*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).*
123114Category: Component Creation
124115Category: Lazarus-CCR

Back to history