VCL.PropEdit Sample
From RAD Studio XE2 Code Examples
Language:
This sample demonstrates how to create a property editor for a custom VCL component.
Contents |
Location
You can find the PropEdit sample project at:
- Start > Programs > Embarcadero RAD Studio > Samples > Delphi > VCL > PropEdit
- Subversion Repository for Delphi: http://radstudiodemos.svn.sourceforge.net/viewvc/radstudiodemos/branches/RadStudio_XE2/Delphi/VCL/PropEdit/
Description
This sample installs a custom pie chart component. The component has a property editor attached from which the angles of the pie can be adjusted at design time. The editor can be invoked either by double-clicking the pie on the form or by double-clicking the Angles property.
How to Use the Sample
- Navigate to Start > Programs > Embarcadero RAD Studio > Samples > Delphi > VCL > PropEdit and open pielib.dproj.
- Build and install pielib.bpl.
Files
| File | Contains |
|---|---|
|
Pies |
Contains the TPie component class and TAngles class. |
|
PieReg |
The classes and procedure necessary to create and register the property editor. |
Classes
- TPie is the class for the pie chart custom component.
- TAngles implements the helper class designed to handle angle information for a pie chart.
- TAngleEditorDlg is class for the form that represents the angles property editor.
- TAnglesProperty, derived from TClassProperty, implements the Angles property for the pie component.
- TPieEditor is the pie component editor, which is implemented to bring up the angle editor.
Implementation
- TPieEditor.EditProperty overrides EditProperty to choose the angles property editor to be brought up when the component is double-clicked.
- GetVerbCount, GetVerb, and ExecuteVerb are used to build the context menu for that component.
- The Edit method of TAnglesProperty is responsible for bringing up the angles editor form.
- Beside the Angles property, the pie component also has properties necessary for drawing itself on the form, like the brush and pen.
Uses
- TClassProperty
- TPropertyEditor
- TComponentEditor
- TComponentEditor.GetVerbCount
- TComponentEditor.GetVerb
- TComponentEditor.ExecuteVerb
- TDefaultEditor.EditProperty