Hi,
In Delphi 2009, In one of my projects, I have a custom frame with some controls on it which I want to use as the base class for some other controls. I want to register this frame as an IDE wizard to be available in New Items list. When I add my newly added item (my custom frame) to a project, I expect it to:
- Show all the properties and events I added to the custom frame in object inspector.
- Derive the newly created frame from my custom frame rather than TFrame.
Ok, to make it show my properties and events in Object Inspector, I register a custom module into IDE. It doesn't work properly for frames. Fortunately somebody mentioned this on StackOverflow, and an answer is given to this:
Then, to make it load DFM of my custom frame, I added InitInheritedComponent to the constructor of my custom frame. Something like this:
constructor TMyFrame.Create(AOwner: TComponent); override;
begin
inerited;
if (ClassType <> TMyFrame) and not (csDesignInstance in ComponentState) then
begin
if not InitInheritedComponent(Self, TMyFrame) then
raise EResNotFound.CreateFmt('Resource %s not found', [ClassName]);
end;
end;
It doesn't work! It still creates an empty frame in designer rather than my own frame. If I don't register custom module into IDE, it shows my frame correctly even without needing InitInheritedComponent, but additional properties are not shown in Object Inspector!
if I change constructor source to this (Replacing TMyFrame with TFrame):
constructor TMyFrame.Create(AOwner: TComponent); override;
begin
inerited;
if (ClassType <> TFrame) and not (csDesignInstance in ComponentState) then
begin
if not InitInheritedComponent(Self, TFrame) then
raise EResNotFound.CreateFmt('Resource %s not found', [ClassName]);
end;
end;
The frame is added to the designer correctly, and additional properties are visible in Object Inspector, but running the application fails, because it complains that the components on the frame already exist.
So, my question is: what is the solution for having a Delphi IDE wizard which creates a derived frame from a custom frame (not form) with DFM, and shows its additional properties in Object Inspector?
BTW, I don't want to build the controls in the frame at runtime, because I need them to be available in design time too.
I hope somebody can make this thing clear to me.
Regards
EDITED:
These frames are actually used as pages for a wizard component. My wizard component creates them at runtime. I want the user to have an option in "New Item" menu to add a wizard page to project, and design its layout in IDE designer, and register it with my wizard component to be shown in the wizard. I am inheriting a base class from TFrame because my wizard pages should have some mandatory controls and some custom properties and events.