开发者

Changing font in CHOOSECOLOR dialog

I'm using the Windows common c开发者_Go百科ontrols CHOOSECOLOR dialog, but on Win 7 it sticks out like a sore thumb as it still uses the 'old' Tahoma font.

Changing font in CHOOSECOLOR dialog

Is there a fairly easy way of getting it to use Segoe UI or some other font?

If it matters, I'm using Delphi/C++Builder...


I don't think it is a good idea to alter the default font, but sure, it's doable:

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;

This will use the Form1.Font font.

Changing font in CHOOSECOLOR dialog

Still, in this case, I might just find it acceptable:

Changing font in CHOOSECOLOR dialog

Changing font in CHOOSECOLOR dialog

Tahoma (Default) vs. Segoe UI

But! There are issues involved:

Changing font in CHOOSECOLOR dialog

Changing font in CHOOSECOLOR dialog

The safest thing to do, I think, is not to alter the default (intended) appearance of the dialog. Then, at least, you can blame Microsoft for any scaling issues...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜