How to do volume-conversion of a form into a frame in Delphi?

I have a form with aprox with 200 visual components on it, with a lot of events assigned, and I need to change it now to frame.I don’t have enough time to copy all components, reinstall all visual components and reassign all events, align, etc. . So, I copied pas and dfm, opened and started editing them in a text editor (changing TForm to Tframe, etc.), but it seems that this does not give the expected results.

Does anyone know how to solve this?

+4
source share
3 answers

Pay attention to the differences in form and frame in your project.

First, the source of project.dpr:

program Project1; uses Forms, Unit1 in 'Unit1.pas' {Form1}, Unit3 in 'Unit3.pas' {Frame3: TFrame}; {$R *.res} begin Application.Initialize; Application.MainFormOnTaskbar := True; Application.CreateForm(TForm1, Form1); Application.Run; end. 

Differences:

  • Frame as a more detailed commentary to tell the IDE which designer should use
  • The form can be autocreated.

Dfm Files:

 object Form1: TForm1 Left = 0 Top = 0 Caption = 'Form1' ClientHeight = 348 ClientWidth = 643 Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = 'Tahoma' Font.Style = [] OldCreateOrder = False PixelsPerInch = 96 TextHeight = 13 end 

and

 object Frame3: TFrame3 Left = 0 Top = 0 Width = 320 Height = 240 TabOrder = 0 end 

A frame does not have these properties:

  • Title
  • Clientheight
  • ClientWidth
  • Color
  • Font.charset
  • Font.color
  • Font.height
  • Font.name
  • Font.Style
  • OldCreateOrder
  • PixelsPerInch
  • Textheight

Sidenote: Frame does not have these events:

  • Oncreate
  • Ondestroy

There is no global variable in the frame:

 var Form1: TForm1; 

And the frame goes down from TFrame , while the form goes down from TForm .

Note: with Frame / Form inheritance, your steps get a little longer.

- Jeroen

+7
source

TForm will have additional properties and events that do not have TFrame. You need to remove these properties and events manually in order to change the form to a frame.

Be sure to follow these steps:

  • Change the base class type to TFrame, i.e. change TForm1 = class(TForm) to TForm1 = class(TFrame) .
  • In the form, right-click and select View as Text .
  • Remove properties and events that TFrame does not have, and then select View as Form .
  • You should now be able to view the form as a frame.
+2
source

Take the time to develop once and for all an IDE expert performing a mass operation if there is no work from the window (proprietary / open source) and you are done.

0
source

Source: https://habr.com/ru/post/1337290/


All Articles