How to change font size of Delphi XE6 IDE
Asked Answered
I

2

9

How can i change the font size of the IDE itself of Delphi XE6.

The IDE's dialogs are not using my Windows font preference, and i cannot find any option to change the font used by the IDE.

enter image description here

Alternatively, how do i get Delphi XE6 to honor the user's font preferences?

Islam answered 21/7, 2014 at 19:33 Comment(4)
AFAIK, you can't change the font. It is hardcoded.Francoise
Are you one of those guys (like me) with eye problems?Phoebephoebus
@Rigel. Yes, but it's more than that. 8pt font was fine in 1991 when we were running 640x480 on a 14" monitor (43 ppi). Now we're running 1920x1080 on 22" monitor (58 ppi). Everything has gotten 26% smaller. 16px toolbar images may have been fine in 1991, but it's too small today. For 30 years developers have been laying out things in pixels rather than dialog units. If they're going to design it wrong, it's time to update their wrong design: Toolbars images must now be 24 px, fonts must be 11 pt, buttons must be 31px tall. Or they can do the right thing: follow the user's preference.Islam
I started to add an option in my programs (Settings panel) to allow user to change font size for the form.Phoebephoebus
V
1

You can't
The font is hardcoded. You cannot change it.

Here's what I've tried

1 - Change BDS.EXE with a HEX editor

If you open up BDS.EXE in a HEX-editor, look for TextHeight and change the values from $0D (13) to something bigger, then the altered bds.exe will look exactly the same.

2 - Use EnumChildWindows to spam the Delphi IDE with WM_SETFONT messages

You can send a WM_SETFONT message to the running Delphi main window.
You have to find the window using the FindWindow API call.

From: http://msdn.microsoft.com/en-us/library/windows/desktop/ms632642%28v=vs.85%29.aspx

wParam
A handle to the font (HFONT). If this parameter is NULL, the control uses the default system font to draw text.
lParam
The low-order word of lParam specifies whether the control should be redrawn immediately upon setting the font. If this parameter is TRUE, the control redraws itself.

Because you want Delphi to use the default font, the message is really simple.

The Delphi XE6 main window is called TAppBuilder, so you'll have to get the handle to that Window using FindWindow.

I tried this, but it did not work.

unit Unit4;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;

type
  TForm4 = class(TForm)
    FontDialog1: TFontDialog;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  end;

var
  Form4: TForm4;

implementation

{$R *.dfm}

const
  DelphiWindows: array [1 .. 1] of PWideChar = ('TAppBuilder');

function EnumChildProc(const hWindow: hWnd; const hFont: LParam): boolean; stdcall;
begin
  SendMessage(hWindow, WM_SETFONT, hFont, 1);
  Result:= True;
end;

procedure TForm4.Button1Click(Sender: TObject);
var
  BDSWindow: HWND;
  ChildWindow: HWnd;
  Font: HFONT;
  i: Integer;
begin
  if FontDialog1.Execute then begin
    BDSWindow:= FindWindow(DelphiWindows[1], nil);
    Font:= FontDialog1.Font.Handle;
    EnumChildWindows(BDSWindow, @EnumChildProc, Font);
    ShowMessage('Done');
  end;
end;

end.

I have not tried the default font, because the Delphi font and the default font are the same on my system. And I don't want to change the default font.

Doing this changed 2 dropdown_boxes on my Delphi. Not a very good showing.

I posted this as an answer in the hope that you can get to a solution from here.

Vatican answered 24/7, 2014 at 22:17 Comment(4)
It's probably worth noting that even if you did manage to change the font size, the IDE was designed with the current font size, so it probably won't work well with the new size (and you may even render it unusable). It's hard work sometimes to accommodate font sizes and scaling in a UI, and the Delphi IDE has a lot of complex UI to content with in that regard. (Which, BTW, is probably the reason that there's no built-in capability to change the font size.)Tommi
You can't send a font handle to another process, it wouldn't work: "Handles to GDI objects are private to a process. That is, only the process that created the GDI object can use the object handle." (GDI Objects)Pulsatory
@SertacAkyuz, Yes you're right, but you can send a hFont of null, which tells the Window to use the system default font. I suspect however that DBS.EXE ignores the WM_SETFONT messages.Vatican
Curiously, Raymond Chen just posted about WM_SETFONT and WM_GETFONT, and why they may not work. See When I send a WM_GETFONT message to a window, why don't I get a font?.Tommi
T
0

The best way to do that is using Delphi IDE Theme Editor, it's very simple. Try in Delphi IDE Theme Editor, preview:

enter image description here

Tsunami answered 1/4, 2016 at 3:57 Comment(1)
This will change the size of the font in the editor not in the whole IDE environment. Please read the question again, this time carefully :)Phoebephoebus

© 2022 - 2024 — McMap. All rights reserved.