I wrote a TCustomFrame
's child class which has been exactly copied from TFrame
(Forms.pas unit):
TMyFrame = class(TCustomFrame)
private
{ Private declarations }
public
{ Public declarations }
published
property Align;
property Anchors;
property AutoScroll;
property AutoSize;
property BiDiMode;
property Constraints;
property DockSite;
property DragCursor;
property DragKind;
property DragMode;
property Enabled;
property Color nodefault;
property Ctl3D;
property Font;
property Padding;
property ParentBackground default True;
property ParentBiDiMode;
property ParentColor;
property ParentCtl3D;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property ShowHint;
property TabOrder;
property TabStop;
property Visible;
property OnAlignInsertBefore;
property OnAlignPosition;
property OnCanResize;
property OnClick;
property OnConstrainedResize;
property OnContextPopup;
property OnDblClick;
property OnDockDrop;
property OnDockOver;
property OnDragDrop;
property OnDragOver;
property OnEndDock;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnGetSiteInfo;
property OnMouseActivate;
property OnMouseDown;
property OnMouseEnter;
property OnMouseLeave;
property OnMouseMove;
property OnMouseUp;
property OnMouseWheel;
property OnMouseWheelDown;
property OnMouseWheelUp;
property OnResize;
property OnStartDock;
property OnStartDrag;
property OnUnDock;
end;
As described here, I've initially defined a TFrame
's child class, then I've switched to TCustomFrame
and removed the TabOrder
property from the DFM in order to be able to open the file in the IDE and recompile the package.
object MyFrame: TMyFrame
Left = 0
Top = 0
Width = 296
Height = 31
TabOrder = 0 //this line has been deleted
end
Everything seemed to be ok but after opening and saving the source file, there were several new properties in the DFM and a titlebar appears:
object MyFrame: TMyFrame
Left = 0
Top = 0
ClientHeight = 0
ClientWidth = 280
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = True
PixelsPerInch = 96
TextHeight = 13
end
Why is this happened and how should I do it for avoiding these problems?
I believe all you need to do is register your frame class as a custom module.
In your package's register procedure, add something like this :
procedure Register;
begin
[...]
RegisterCustomModule(TMyFrame, TCustomMyFrameModule)
end;
And TCustomMyFrameModule is defined as
TCustomMyFrameModule = class(TCustomModule)
function Nestable: Boolean; override;
end;
function TCustomMyFrameModule.Nestable: Boolean;
begin
Result := True;
end;
EDIT: For it to work, you need to register a custom module for the parent class of the class your are editing in the IDE.
TFrame1 = class(TMyFrame)
end;
RegisterCustomModule(TMyFrame, TCustomMyFrameModule)
If you want to edit your TMyFrame in the IDE, you will need to register a custom module for TCustomFrame.
TMyFrame = class(TCustomFrame)
end;
RegisterCustomModule(TCustomFrame, TCustomMyFrameModule)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With