chkaufmann 17 Posted November 7, 2019 When I create a new form (File - New - VCL Form) font and size is always like this: Font.Height = -11 Font.Name = 'Tahoma' but I would like to have it like this: Font.Height = -12 Font.Name = 'Segoe UI' Is there a simple way to achieve this? I remember, that I saw a sample with an IDE expert for this, but is there no way to set this default in the IDE or "per project"? Christian Share this post Link to post
Attila Kovacs 629 Posted November 7, 2019 Create a form you like, right click on it, add to repository.... Share this post Link to post
Der schöne Günther 316 Posted November 7, 2019 Always have a base class for your forms/frames. When adding a new form/frame to your project, do not inherit from TForm/TFrame, inherit from TMyForm/TMyFrame. 3 Share this post Link to post
Remy Lebeau 1398 Posted November 7, 2019 9 hours ago, chkaufmann said: When I create a new form (File - New - VCL Form) font and size is always like this: Font.Height = -11 Font.Name = 'Tahoma' Those are the defaults that are established by the Vcl.Graphics.pas unit (see the InitDefFontData() function) during unit initialization, and then applied to the global DefFontData variable, which is used to initialize every TFont object at runtime. 9 hours ago, chkaufmann said: but I would like to have it like this: Font.Height = -12 Font.Name = 'Segoe UI' Is there a simple way to achieve this? I remember, that I saw a sample with an IDE expert for this, but is there no way to set this default in the IDE or "per project"? Not in the IDE, no. However, the DefFontData variable is publicly accessible, so you can modify it at runtime before creating any of your TForm objects. 1 Share this post Link to post
David Heffernan 2345 Posted November 7, 2019 43 minutes ago, Remy Lebeau said: Not in the IDE, no. However, the DefFontData variable is publicly accessible, so you can modify it at runtime before creating any of your TForm objects. I guess you could modify DefFontData in a design time package 1 Share this post Link to post
dummzeuch 1505 Posted November 9, 2019 There is some testing code for setting DefFontData in GExperts: https://sourceforge.net/p/gexperts/code/2844/ Just in case somebody wants to test it. For now these controls are hidden and the settings are not persistent. It seems to work, but has some undesired side effects. Share this post Link to post
Anders Melander 1784 Posted November 9, 2019 On 11/7/2019 at 9:55 AM, chkaufmann said: Font.Height = -12 Font.Name = 'Segoe UI' Is there a simple way to achieve this? In the project file (the DPR file) I do this before the first form is created: if (CheckWin32Version(6, 0)) then begin // Application.DefaultFont is the font used when TForm.ParentFont=True. // It is Tahoma by default but should be Segoe UI on Vista and later (according to MS UI guide lines). // See InitDefFontData() in graphics.pas Application.DefaultFont.Assign(Screen.MessageFont); // DefFontData.Name specifies the default font for everything that doesn't specify a specific font. // For now we leave it as is (Tahoma). At some point it should follow the system default like above: // DefFontData.Name := Screen.MessageFont.Name; end; And then I just make sure to set all forms ParentFont=True at design time. 3 1 Share this post Link to post
chkaufmann 17 Posted November 13, 2019 On 11/9/2019 at 11:00 PM, Anders Melander said: And then I just make sure to set all forms ParentFont=True at design time. I looked at the problem again and this seems the most reasonable solution for me. The only question that remains, how can I set the IDE font used during designing to "Segoe UI, 9pt" because right now, when I choose "ParentFont = True" then I still get "Tahoma 8pt". Christian Share this post Link to post
Anders Melander 1784 Posted November 13, 2019 7 hours ago, chkaufmann said: The only question that remains, how can I set the IDE font used during designing to "Segoe UI, 9pt" because right now, when I choose "ParentFont = True" then I still get "Tahoma 8pt". I'm afraid I can't answer that. Supposedly there used to be a registry key that could do the trick (HKCU\Software\Embarcadero\BDS\19.0\FormDesign\DefaultFont) but that didn't work with the embedded form designer and as far as I can tell it no longer work with the detached designer either. I guess you could create an IDE plugin that modifies the form designer but that's probably more work than it's worth. Maybe just a design time package that modifies Application.DefaultFont like above will do the trick, but that will affect the whole IDE. FWIW I understand the OCD in you that wants the form to use SegoeUI at design time but it shouldn't really matter. If you have designed it "properly" then the form should be able to display correctly with both SegoeUI and Tahoma. After all you don't know what font the end-user will be using. Share this post Link to post
chkaufmann 17 Posted November 13, 2019 Thanks for your answer. You are right regarding "properly" designed forms. Unfortunately I deal with old applications, that are not perfect and I thought, if I see it with the most common font/size used today, I could just fix the major problems. Mainly fix "Top" and "Height" problem are an issue because all labels and controls are higher. Christian Share this post Link to post
Guest Posted November 15, 2019 Regarding legacy problems, i had a project with a lot of visual levels and (before high DPI) for each level the "ExplicitHeight/Width" properties messed things up. Utterly annoying to keep track of those. But that was not my point. What i ended up with was a small exe of my own that i ran before each build that went trough the dfm's and changed that. The notion might be useful. Share this post Link to post
zed 14 Posted September 15, 2022 In Delphi 11 they changes default font to "Segoe UI". Share this post Link to post