Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 08-30-2018, 04:55 AM
Marsheng Marsheng is offline
Senior Member
 
Join Date: Nov 2008
Posts: 313
Default Set form default font and size.

Spent a few hours looking to see how I can set all forms in a project to the same font and size. I was hoping there was a setting for a default form designer font and size but nothing. Found some registry tweaks for this but only for later versions.

Any idea on how to set it in Ver 6 ?
Reply With Quote
  #2  
Old 08-30-2018, 08:36 AM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,303
Default

Internet says that there could be a delphi.ini file
http://www.scalabium.com/faq/dct0103.htm

I don't have a prehistoric Delphi anymore, so I cannot validate.

And my guess for the size should be:
[FormDesign]
DefaultHeight=600
DefaultWidth=800

But note that all of this is for new forms, existing forms could have that information already stored. If so you should modify the .dfm (viewAsText) for the existing forms
Reply With Quote
  #3  
Old 08-30-2018, 09:21 PM
Marsheng Marsheng is offline
Senior Member
 
Join Date: Nov 2008
Posts: 313
Default

http://www.scalabium.com/faq/dct0103.htm

Looked at that before but must be an even earlier version than 6

The default font is MS Sans Serif so I searched through the registry to see if I could find it under a Delphi Key - Nil.

I tried AstroGrep, to look through all the files in the Delphi directory for MS Sans Serif and nothing obvious.

One file ActnRes.dfm looks like a possibility

it contains
Dialog.Font.Color = clWindowText
Dialog.Font.Height = -11
Dialog.Font.Name = 'MS Sans Serif'
Dialog.Font.Style = []
Dialog.MinFontSize = 0

The other files that contain MS Sans Serif are *.bpl in the bin directory.
Reply With Quote
  #4  
Old 08-31-2018, 03:29 AM
Glenn1234 Glenn1234 is offline
Senior Member
 
Join Date: Aug 2009
Posts: 130
Default

You can try doing it programmatically by iterating the components. Below is kind of a rough try at it. I'm sure there's more component types you could set, but the basic idea of what you'd need to do is below.



Code:
procedure AppForceFont(Application: TApplication; Name: String; Size: Integer);
// forces all forms in an application object to the same font name and size.
var
  i, j: integer;
begin
  for i := 0 to (Application.ComponentCount - 1) do
    begin
      if Application.Components[i] is TForm then
        With TForm(Application.Components[i]) do
          begin
            Font.Name := Name;
            Font.Size := Size;
            for j := 0 to (ComponentCount - 1) do
              begin
                if Components[j] is TLabel then
                  with TLabel(Components[j]) Do
                    begin
                      Font.Name := Name;
                      Font.Size := Size;
                    end;
                if Components[j] is TEdit then
                  with TEdit(Components[j]) Do
                    begin
                      Font.Name := Name;
                      Font.Size := Size;
                    end;
                if Components[j] is TMemo then
                  with TMemo(Components[j]) Do
                    begin
                      Font.Name := Name;
                      Font.Size := Size;
                    end;
              end;
          end;
    end;
end;
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 01:48 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2018, vBulletin Solutions, Inc.