[DUG] descending from TWebModule

David Brennan dugdavid at dbsolutions.co.nz
Wed Jun 8 11:55:12 NZST 2005


Phil,

It's frustrating isn't it. Took me quite a while to work out how to set
things up.

The following code is taken from our registration procedure and demonstrates
how to install designers for your own VCL level DataModules, Forms and
Frames. I have hacked it to remove other unrelated code so it might not
compile but it should give you the idea.

David.

unit DbbRegDesigners;

interface

uses
	Classes, DsgnIntf,
  DmDesigner, // Contains TDataModuleDesignerCustomModule
  WctlForm; // Contains TWinControlCustomModule
  
  procedure Register;

implementation

type
  TDbbFormCustomModule = class(TCustomModule)
  end;

  TDbbFrameCustomModule = class(TWinControlCustomModule)
  public
    class function Nestable: Boolean; override;
  end;

{ TDbbWinControlCustomModule }

class function TDbbFrameCustomModule.Nestable: Boolean;
begin
  // Necessary for TDbbFrame descendents to appear in the create Frame
  // list.
  Result := True;
end;

procedure Register;
begin
  RegisterNoIcon([TDbbDataModule]);
  RegisterCustomModule(TDbbDataModule, TDataModuleDesignerCustomModule);
  RegisterNoIcon([TDbbForm]);
  RegisterCustomModule(TDbbForm, TDbbFormCustomModule);

  // Note: DON'T call RegisterNoIcon for TDbbFrame. This will disable copy
and
  // paste of TDbbFrame descendents and make it impossible to place a new
  // TDbbFrame descendent on a form.
  RegisterCustomModule(TDbbFrame, TDbbFrameCustomModule);

end;

end.

-----Original Message-----
From: delphi-bounces at ns3.123.co.nz [mailto:delphi-bounces at ns3.123.co.nz] On
Behalf Of Phil Middlemiss
Sent: Wednesday, 8 June 2005 8:22 a.m.
To: NZ Borland Developers Group - Delphi List
Subject: [DUG] descending from TWebModule

I have defined a class that descends from TWebModule and adds a couple 
of extra methods that we will commonly use. There is no attached dfm 
with it. When I create a new TWebModule and then change it's definition to:

TBrandNewModule = class(TMyWebModule)
etc

it compiles fine, but if I close the BrandNewModule unit and reopen it, 
the IDE thinks that the {$R *.dfm}should be a TForm descendant and not a 
TWebModule descendant, and therefore anything in the saved dfm unit that 
doesn't belong on a TForm is lost and the created window is a TForm, not 
a TWebModule.

Is there some trick here? It doesn't quite seem a job for the 
repository, and I tried registering the TMyWebModule class aswell 
without any joy.

Phil.
_______________________________________________
Delphi mailing list
Delphi at ns3.123.co.nz
http://ns3.123.co.nz/mailman/listinfo/delphi



More information about the Delphi mailing list