ryan_o 0 Posted October 18 So I have this class hierarchy: IBlah = interface procedure Foo; end; TBlahFrame = class(TFrame, IBlah) procedure Foo; virtual; abstract; end; TBlahFrameClass = class of TBlahFrame; and I'm using it like so // frame file TFrame1 = class(TBlahFrame) //... procedure Foo; override; end; // form procedure Inject(FrameClass: TBlahFrameClass); begin FSlot := FrameClass.Create(self); FSlot.Foo; end; And it works perfectly. But the problem is that whenever I close and reopen `TFrame1`'s file, it tries to convert it into being a form. The only way to change it back to being a frame is to switch the frame's superclass back to TFrame and reopen it again. Share this post Link to post
Uwe Raabe 2057 Posted October 18 Can you check the dproj file for the <DCCReference entry for the frame file? It should have a DesignClass sub node with TFrame content like this: <DCCReference Include="Common\RCustomPalette.pas"> <Form>FrCustomPalette</Form> <FormType>dfm</FormType> <DesignClass>TFrame</DesignClass> </DCCReference> Also in the dpr file, the uses reference should also have a TFrame signature like this: RCustomPalette in 'Common\RCustomPalette.pas' {FrCustomPalette: TFrame}, If it has not, you should fix that manually and save the project. Share this post Link to post
ryan_o 0 Posted October 18 21 minutes ago, Uwe Raabe said: Can you check the dproj file for the <DCCReference entry for the frame file? It should have a DesignClass sub node with TFrame content like this: <DCCReference Include="Common\RCustomPalette.pas"> <Form>FrCustomPalette</Form> <FormType>dfm</FormType> <DesignClass>TFrame</DesignClass> </DCCReference> Also in the dpr file, the uses reference should also have a TFrame signature like this: RCustomPalette in 'Common\RCustomPalette.pas' {FrCustomPalette: TFrame}, If it has not, you should fix that manually and save the project. It does have both those things. I'll attach a sample project. It should compile and run, but when opening Frame.pas you will get an error that some properties don't exist and the frame will be converted to a form(it will gain a titlebar). FrameConversionSample.zip Share this post Link to post
Uwe Raabe 2057 Posted October 18 The problem is that TBlahFrame is only a declaration of a TFrame descendant and not a designable TFrame. This way the IDE cannot detect that TFrame1 has to be treated as TFrame by the designer. You either need to make TBlahFrame a proper TFrame with a dfm and the corresponding entries in the dpr and dproj, or you declare an alias for TBlahFrame with the name TFrame and use that as the parent class for TFrame1. TBlahFrame = class(TFrame, IBlah) procedure Foo; virtual; abstract; end; TBlahFrameClass = class of TBlahFrame; type TFrame = TBlahFrame; uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, intf; type TFrame1 = class(TFrame) private 1 1 Share this post Link to post
ryan_o 0 Posted October 18 10 minutes ago, Uwe Raabe said: The problem is that TBlahFrame is only a declaration of a TFrame descendant and not a designable TFrame. This way the IDE cannot detect that TFrame1 has to be treated as TFrame by the designer. You either need to make TBlahFrame a proper TFrame with a dfm and the corresponding entries in the dpr and dproj, or you declare an alias for TBlahFrame with the name TFrame and use that as the parent class for TFrame1. TBlahFrame = class(TFrame, IBlah) procedure Foo; virtual; abstract; end; TBlahFrameClass = class of TBlahFrame; type TFrame = TBlahFrame; uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, intf; type TFrame1 = class(TFrame) private That works perfectly, thanks. Share this post Link to post