Possible Duplicate:
How to invoke a property editor at design time
I'm creating a non-visual component, and I want the user to be able to double click on my component at design-time and have that open a design-time editor.
How can I do it?
Possible Duplicate:
How to invoke a property editor at design time
I'm creating a non-visual component, and I want the user to be able to double click on my component at design-time and have that open a design-time editor.
How can I do it?
Double-clicking a component at design time invokes a component editor. The default component editor is one that looks for event properties with certain names and creates a handler for what it finds. You can write your own component editor that does whatever you want.
Create a descendant of TComponentEditor
(from the DesignEditors unit) and override the Edit
method to handle double-clicks. You can also override the GetVerbCount
, GetVerb
, and ExecuteVerb
methods to add context-menu items to your component. To get a reference to the component your editor is being asked to edit, check the Component
property. Call Designer.Modified
if your editor modifies the component.
Tell the IDE that your editor should be used with your component by calling RegisterComponentEditor
(from DesignIntf) in your Register
procedure.
You should put this code in a design-time package, separate from your component's code. Put your run-time package on the "requires" list of the design-time package. If you put everything in a single package, then consumers of your component won't be able to use run-time packages in their projects; they're not allowed to distribute the dependencies of your design-time package, which are only for use by the IDE.