我正在使用Windows公共控件CHOOSECOLOR对话框,但在Win 7上它看起来很突兀,因为它仍然使用“旧”的Tahoma字体。
function EnumChildProc(hWnd: HWND; lParam: LPARAM): LongBool; stdcall;
begin
SendMessage(hWnd, WM_SETFONT, lParam, Integer(true));
result := true;
end;
procedure TForm1.ColorDialogShow(Sender: TObject);
var
dlg: TColorDialog;
begin
if not (Sender is TColorDialog) then Exit;
dlg := TColorDialog(Sender);
SendMessage(dlg.Handle, WM_SETFONT, Self.Font.Handle, Integer(true));
EnumChildWindows(dlg.Handle, @EnumChildProc, Self.Font.Handle);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
with TColorDialog.Create(nil) do
try
OnShow := ColorDialogShow;
Execute(Handle);
finally
Free;
end;
end;
Form1.Font
字体。