Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change font size of Delphi XE6 IDE

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?

like image 636
Ian Boyd Avatar asked Jul 21 '14 19:07

Ian Boyd


People also ask

How do I increase font size in IDE?

If you need to quickly change the font size while in the editor, press Ctrl+Alt+S to open the IDE settings, go to Editor | General, and select Change font size with Command+Mouse Wheel or Change font size with Control+Mouse depending on your operating system.

How do you zoom in code on Delphi?

If you load some text in the richedit and click left mouse button + move the mouse wheel, the text will zoom in or out, without loosing the text size formatting.

How do I change the font of a label in Delphi?

To change label text sizes for already existing labels, follow these steps: Select all labels that you want to change. Select the (Change Text Attributes) tool. Opens the Change Text Attributes dialog. Here you can select different fonts as well as height and width for the selected labels.

How do you change the font on Pyscripter?

Pyscripter Tools menu > Options > Editor Options. Display tab > click Font. Select "Source Code Pro" from list of fonts. Select Style and Size if desired.


1 Answers

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.

like image 51
Johan Avatar answered Sep 25 '22 20:09

Johan