我主要是想更改菜单的字体大小。
一般情况下我的代码有效{ 替换所有菜单项的 DrawItem 事件的自编事件 }
procedure TMainForm.MyMenuDrawItem(Sender: TObject; ACanvas: TCanvas;
  ARect: TRect; Selected: Boolean);
var
  ASize: TSize;
  r: TRect;
begin
  GetTextExtentPoint32W(Self.Canvas.Handle, 'W', 1, ASize);  r := ARect;
  Inc(r.Left, ASize.cx);  ACanvas.Font := Self.Font;
  if Selected then
  begin
    ACanvas.Brush.Color := clMenuHighlight;
    ACanvas.Font.Color  := clMenu;
  end
  else
  begin
    if TTntMenuItem(Sender).GetParentComponent is TTntMainMenu then
      ACanvas.Brush.Color := clBtnFace
    else
      ACanvas.Brush.Color := clMenu;
    ACanvas.Font.Color  := clMenuText;
  end;  ACanvas.FillRect(ARect);
  
  SetBkMode(ACanvas.Handle, TRANSPARENT );
  DrawTextW(ACanvas.Handle, PWideChar(TTntMenuItem(Sender).Caption),
    Length(TTntMenuItem(Sender).Caption), r,
    DT_LEFT or DT_VCENTER or DT_SINGLELINE);
end;{ 替换所有菜单项的 MeasureItem 事件的自编事件 }
procedure TMainForm.MyMenuMeasureItem(Sender: TObject; ACanvas: TCanvas;
  var Width, Height: Integer);
var
  ASize: TSize;
  ASize2: TSize;
begin
  GetTextExtentPoint32W(Self.Canvas.Handle,
    PWideChar(TTntMenuItem(Sender).Caption),
    Length(TTntMenuItem(Sender).Caption),
    ASize);  GetTextExtentPoint32W(Self.Canvas.Handle, 'W', 1, ASize2);  Width := ASize.cx + ASize2.cx;
  Height := Round(ASize.cy + ASize.cy * 0.6);
end;
但是现在有一个问题。
窗口中加了一个ToolBar(ToolBar在一个CoolBar中),然后把其Menu属性设置为mmMain(TMainMenu)。 mmMain的AutoMerge属性是True。运行后,菜单可以从ToolBar中单击出来,但是显示的菜单的字体大小没有变化。也就是我的那些代码无效了。请问各位朋友,该如何解决呢?先谢谢大家关注我的帖子!