I have a form which should have been a frame. I've tried to convert it to a frame, but it seems to stay a form no matter what I do. I've compared the DFM and PAS of a form with a frame and replaced all the uses, changed the inherited class, looked through DFM.
I can't see what is causing it to be a form. What causes a form to be a form? I want to convert it to a frame?
I don't want to create a new frame and copy/paste everything over to the frame. Surely there must be a way to simply convert a form to a frame? or frame to form?
To convert a VCL form to a frame you have to make these changes:
Change the ancestor from TForm
to TFrame
in the .pas
file, eg:
type
TForm2 = class(TForm)
change to
type
TForm2 = class(TFrame)
In the uses
part of your project's .dpr
file, add a : TFrame
next to your frame's name, like this:
Unit2 in 'Unit2.pas' {Form2},
change to
Unit2 in 'Unit2.pas' {Form2: TFrame},
Close and reopen Form2
. The IDE complains about properties that can not be applied to a frame - click on the "Ignore" button.
That's it.
NOTE: You might want to change the class name of your converted frame if the class name gets misleading, but I consider this to be not in the scope of your original question.
NOTE: I've tested this answer on Delphi XE2.