我该如何改变Delphi XE6 IDE本身的字体大小?
IDE的对话框没有使用我的Windows字体偏好设置,而且我找不到任何选项来更改IDE使用的字体。
IDE的对话框没有使用我的Windows字体偏好设置,而且我找不到任何选项来更改IDE使用的字体。
你无法更改字体
该字体是硬编码的,您无法更改它。
我尝试过以下方法:
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
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个下拉框。效果不太好。
我将此作为答案发布,希望您可以从这里找到解决方案。
最好的方法是使用Delphi IDE主题编辑器,它非常简单。请尝试在Delphi IDE Theme Editor中预览: