In development mode, you can change this change by manually editing the .dfm file. Make sure the form is saved with the Scaled property set to True .
Then close your project in Delphi or completely close Delphi. Then open the .dfm file in a text editor and set the TextHeight property. For example, if you want to scale from 7pt to 8pt and TextHeight is 13 , you should change it to 11 . Then reload the project and open the form in the designer, and your form will be scaled. This will not be ideal scaling since for TextHeight you are not allowed floating point values. But that may be enough.
At run time, you can call ChangeScale :
ChangeScale(NewFont.Size, OldFont.Size);
Please note that ChangeScale is a protected member. Thus, depending on where you call it, you may need to use a secure member hack.
Then one of the options would be to invoke a performance save structure at run time to create a scaled version of the .dfm file. This allows you more control than playing tricks with TextHeight
For example, you can attach the following to the OnShow event of your form:
procedure TMyForm.FormShow(Sender: TObject); var BinaryStream, TextStream: TStream; begin BinaryStream := TMemoryStream.Create; Try BinaryStream.WriteComponent(Self); BinaryStream.Position := 0; TextStream := TFileStream.Create('MyForm.dfm', fmCreate); Try ObjectBinaryToText(BinaryStream, TextStream); Finally TextStream.Free; End; Finally BinaryStream.Free; End; end;
This will create a new runtime .dfm file. You can then compare this with the version of the .dfm file that is in your version control system. There will be a few changes that you do not want to accept, but basically the changes will be the changes in location and size that you want.
source share