Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Develop Custom forms designer for Delphi IDE

747 views
Skip to first unread message

Miro

unread,
Aug 24, 2010, 11:28:15 AM8/24/10
to
Hello,

I am making my own kind of "Forms" which are derived from TComponent.
The component hierarchy is ready now, I can create forms runtime from
manually written DFM files. Now I start working on next task from the
list - making a designer for that form. After few days of reading
documentation and ToolsAPI.pas, looking examples on the net, googling,
post in forums.embarcadero.com... etc. , I still dont have good
picture how to make my own form designer. I need to develop something
like TDataModule designer, which is also TComponent descendant as my
forms.

I found few comments in DesignIntf.pas about "Custom Module Types". So
for now I am trying to make some implementations of ICustomDesignForm
and class inherited from TCustomModule. I use CreateDesignerForm
method of ICustomDesignForm to create my own implementation of
IHostForm. But there is input parameter of CreateDesignerForm method
of time IDesigner, and till now I cant wind where I can create my own
instance of my own IDesigner implementation. I cant use the already
created IDesigner from Delphi IDE. I think I need my own IDesigner
implementation - but where I can tell to Delphi IDE to create it?

Any ideas? any links? ... while googling I found few articles, but all
of these are very outdated and they are talking about Delphi 3-5, but
nothing more recent about "Custom Module Types" and designers for
these custom modules.

Thanks in advance,

Skybuck Flying

unread,
Aug 25, 2010, 1:14:15 AM8/25/10
to
I have an old book which documents how to do this... it was probably written
for Delphi 3 but might still apply to recent versions of Delphi.

The book says the key step in creating your own form designer in Delphi is
the RegisterCustomModule registration procedure:

procedure RegisterCustomModule( ComponentBaseClass : TComponentClass;
CustomModuleClass : TCustomModuleClass );

It also mentions RegisterLibraryExpert( .. )

Why you want to create your own form designer ;) ?

Bye,
Skybuck =D

Miro

unread,
Aug 25, 2010, 4:36:05 AM8/25/10
to
On Aug 25, 8:14 am, "Skybuck Flying" <IntoTheFut...@hotmail.com>
wrote:

> I have an old book which documents how to do this... it was probably written
> for Delphi 3 but might still apply to recent versions of Delphi.
>
> The book says the key step in creating your own form designer in Delphi is
> the RegisterCustomModule registration procedure:
>

Yes, I come to conclusion reading comments in Delphi source code that
I have to make my own TCustomModule:

TMyFormCustomModule = class(TCustomModule, ICustomDesignForm80)
protected
procedure CreateDesignerForm(const Designer: IDesigner; Root:
TComponent;
out DesignForm: IHostForm; out ComponentContainer: TWinControl);
end;

In that method CreateDesignerForm I create my own IHostForm where I
suppose I have to place my design time view of my form.
But as you can see - the first parameter of that method is already
created instance of IDesigner implementation. Looking at methods in
IDesgner I think that I have to implement it by myself and Delphi IDE
to use my implementation for my forms, but till now - cant find where
I can tell to Delphi IDE that is have to use my own implementation.

I found also that event type in DesignIntf.pas:

TGetDesignerEvent = procedure(Sender: TObject; out ADesigner:
IDesigner) of object;

but looks like no one on Earth is using it or know why that one
exists :) ... or at least Google dont know anything about it.

> procedure RegisterCustomModule( ComponentBaseClass : TComponentClass;
> CustomModuleClass : TCustomModuleClass );
>
> It also mentions RegisterLibraryExpert( .. )
>
> Why you want to create your own form designer ;) ?
>

Because my forms are descendant from TComponent (as TDataModule for
example), not from TCustomForm or TWinControl, not even from TControl
- so I am pretty sure standard Delphi form designer cant handle my
forms - I actually try that and the IDE open them using TDataModule
designer, but that designer isnt working for me because mine forms are
true visual forms, not just component containers (as TDataModule) and
I want to be able to WYSIWYG editing of my forms.

Cheers,

Miro

unread,
Aug 25, 2010, 4:40:20 AM8/25/10
to
Maybe I have to create custom component editor for my form class and
register it with RegisterComponentEditor? But such case is not
described in component editors...

Arivald

unread,
Aug 25, 2010, 7:00:40 AM8/25/10
to
W dniu 2010-08-25 10:36, Miro pisze:

> On Aug 25, 8:14 am, "Skybuck Flying"<IntoTheFut...@hotmail.com>
> wrote:
>> I have an old book which documents how to do this... it was probably written
>> for Delphi 3 but might still apply to recent versions of Delphi.
>>
>> The book says the key step in creating your own form designer in Delphi is
>> the RegisterCustomModule registration procedure:
>>
>
> Yes, I come to conclusion reading comments in Delphi source code that
> I have to make my own TCustomModule:
>
> TMyFormCustomModule = class(TCustomModule, ICustomDesignForm80)
> protected
> procedure CreateDesignerForm(const Designer: IDesigner; Root:
> TComponent;
> out DesignForm: IHostForm; out ComponentContainer: TWinControl);
> end;
>
> In that method CreateDesignerForm I create my own IHostForm where I
> suppose I have to place my design time view of my form.
> But as you can see - the first parameter of that method is already
> created instance of IDesigner implementation. Looking at methods in
> IDesgner I think that I have to implement it by myself and Delphi IDE
> to use my implementation for my forms, but till now - cant find where
> I can tell to Delphi IDE that is have to use my own implementation.
>

AFAIK there is only one Designer. And You can access designer only by
its interface.

And, as You can see IDesigner works only with TCustomForm.

> I found also that event type in DesignIntf.pas:
>
> TGetDesignerEvent = procedure(Sender: TObject; out ADesigner:
> IDesigner) of object;
>
> but looks like no one on Earth is using it or know why that one
> exists :) ... or at least Google dont know anything about it.
>
>> procedure RegisterCustomModule( ComponentBaseClass : TComponentClass;
>> CustomModuleClass : TCustomModuleClass );
>>
>> It also mentions RegisterLibraryExpert( .. )
>>
>> Why you want to create your own form designer ;) ?
>>
>
> Because my forms are descendant from TComponent (as TDataModule for
> example), not from TCustomForm or TWinControl, not even from TControl
> - so I am pretty sure standard Delphi form designer cant handle my
> forms - I actually try that and the IDE open them using TDataModule
> designer, but that designer isnt working for me because mine forms are
> true visual forms, not just component containers (as TDataModule) and
> I want to be able to WYSIWYG editing of my forms.

You need to have some TCustomForm "container" for Your very custom forms.

For designing, put Your pseudo-TForm on this container.
Do not use TCustomForm.Create(), but TCustomForm.CreateNew() in this
container, to skip reading DFM, then You manually create Your
pseudo-TForm and read its DFM.


--
Arivald


Miro

unread,
Aug 25, 2010, 9:30:13 AM8/25/10
to
On 25 Авг, 14:00, Arivald <arivald_@AT_interia_DOT_.pl> wrote:
>
> > Because my forms are descendant from TComponent (as TDataModule for
> > example), not from TCustomForm or TWinControl, not even from TControl
> > - so I am pretty sure standard Delphi form designer cant handle my
> > forms - I actually try that and the IDE open them using TDataModule
> > designer, but that designer isnt working for me because mine forms are
> > true visual forms, not just component containers (as TDataModule) and
> > I want to be able to WYSIWYG editing of my forms.
>
> You need to have some TCustomForm "container" for Your very custom forms.
>
> For designing, put Your pseudo-TForm on this container.
> Do not use TCustomForm.Create(), but TCustomForm.CreateNew() in this
> container, to skip reading DFM, then You manually create Your
> pseudo-TForm and read its DFM.

Yes, I have such TCustomForm container which implement IHostForm as
required by CreateDesignerForm method of ICustomDesignForm. And I am
creating my custom type form inside that container. And your idea is
that I have to use methods of created from Delphi IDE IDesigner
instance. For example when user select a child control inside my form
I have to call SelectComponent method of given IDesigner so that
control properties to be displayed in Objects Inspector.
Interesting... that will be first approach to try tomorrow. Thanks for
that idea.

Skybuck Flying

unread,
Aug 25, 2010, 9:39:58 AM8/25/10
to
Here is some more code that might help:

(TCustomModule) seems to be missing so code doesn't compile...

There is a ICustomModule... I am not sure what some things changed
to I instead of T.

The book mentioned something about a compounded design editor...

it would use a Tpanel and display some form but it wouldn't be saved etc.

My Delphi environment is currently malfunctioning... it can't open units at
file cursor
kinda weird... so I am gonna try a reboot to see if that helps...

For now here is some code from the book's cd:

uses
Classes, Forms, Windows, Dialogs, ExptIntf, ToolIntf,
FileCtrl, SysUtils, EditIntf, DesignIntf;

type
TPanelEditExpert = class (TIExpert)
public
function GetStyle: TExpertStyle; override;
function GetName: string; override;
function GetAuthor: string; override;
function GetComment: string; override;
function GetPage: string; override;
function GetGlyph: HICON; override;
function GetState: TExpertState; override;
function GetIDString: string; override;
function GetMenuText: string; override;
procedure Execute; override;
end;

// custom module for the panel
type
TPanelModule = class (TCustomModule)
public
procedure ExecuteVerb(Index: Integer); override;
function GetVerb(Index: Integer): string; override;
function GetVerbCount: Integer; override;
procedure ValidateComponent(Component: TComponent); override;
end;


procedure TPanelEditExpert.Execute;
var
ModuleName, FormName, FileName: string;
ModIntf: TIModuleInterface;
begin
ToolServices.GetNewModuleAndClassName (
'Panel', ModuleName, FormName, FileName);
ModIntf := ToolServices.CreateModuleEx (FileName, FormName,
'Panel', '', nil, nil,
[cmNewForm, cmAddToProject, cmUnNamed]);
ModIntf.ShowSource;
ModIntf.ShowForm;
ModIntf.Release;
end;

procedure Register;
begin
RegisterCustomModule (TPanel, TPanelModule);
RegisterLibraryExpert(TPanelEditExpert.Create);
end;

Bye,
Skybuck.


Miro

unread,
Sep 8, 2010, 4:27:12 AM9/8/10
to
I have some progress with my custom forms designer, but now I come to
next troubles. I am implementing the link between my forms and
CustomModule where is located created IDesgner. I have to call
appropriate IDesginer methods as result of user actions when designing
my forms. Some of IDesigner methods have descriptive names, but I am
sure very soon I will come to some very hard to solve confusion with
use of IDesigner methods. And testing is not very easy and fast
because I have to debug second instance of Delphi IDE.

Does anyone knows some good explanation of IDesigner methods? It even
doesnt have comments in DesignIntf.pas

Thanks,

Miro

unread,
Sep 8, 2010, 8:18:46 AM9/8/10
to
Hm, looks like I found such documentation online on http://docs.embarcadero.com

The full link to IDesigner is:
http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/delphivclwin32/!!MEMBEROVERVIEW_DesignIntf_IDesigner.html

Strange that this is not included in Help installed with Delphi IDE.

0 new messages