你不能
字体是硬编码的。你不能改变它。
这是我尝试过的方法
1 - 使用 HEX 编辑器更改 BDS.EXE
如果您在 HEX 编辑器中打开 BDS.EXE,查找 TextHeight 并将值从 $0D (13) 更改为更大的值,那么更改后的 bds.exe 将看起来完全一样。
2 - 使用 EnumChildWindows 向 Delphi IDE 发送带有 WM_SETFONT 消息的垃圾邮件
您可以向正在运行的 Delphi 主窗口发送WM_SETFONT 消息。
您必须使用FindWindow API 调用找到窗口。
发件人:http://msdn.microsoft.com/en-us/library/windows/desktop/ms632642%28v=vs.85%29.aspx
wParam
字体句柄 (HFONT)。如果此参数为 NULL,则控件使用默认系统字体来绘制文本。
lParam
lParam 的低位字指定是否应在设置字体后立即重绘控件。如果此参数为 TRUE,则控件重绘自身。
因为你希望 Delphi 使用默认字体,所以消息非常简单。
Delphi XE6 主窗口称为TAppBuilder,因此您必须使用FindWindow 获取该窗口的句柄。
我试过了,但是没有用。
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.
我没有尝试过默认字体,因为我的系统上的Delphi字体和默认字体是一样的。而且我不想更改默认字体。
这样做改变了我的 Delphi 上的 2 个 dropdown_boxes。不是很好的表现。
我将此作为答案发布,希望您能从这里找到解决方案。