Delphi 窗口控件字体大小批量设置
在 Delphi 中,可以通过遍历当前窗口的所有控件,并设置其 FontSize 属性来改变当前窗口所有控件的字体大小。以下是一个示例代码:
procedure SetFontSize(Control: TControl; FontSize: Integer);
var
i: Integer;
begin
if Control is TWinControl then
begin
for i := 0 to TWinControl(Control).ControlCount - 1 do
SetFontSize(TWinControl(Control).Controls[i], FontSize);
end;
Control.Font.Size := FontSize;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
SetFontSize(Self, 12); // 设置当前窗口所有控件的字体大小为 12
end;
在上面的示例中,SetFontSize 过程用于递归遍历当前窗口的所有控件,并将其字体大小设置为指定的值。在 Button1Click 事件中调用 SetFontSize 过程,并传入 Self 参数表示当前窗口对象,以及要设置的字体大小。
原文地址: https://www.cveoy.top/t/topic/oGN 著作权归作者所有。请勿转载和采集!