Windows10 + Lazarus.
How can I adjust the font.size and font.name of yhe menu (+ items) via a button.
On Delphi it is as simple as this (for the submenus, not the mainmenu at the top)
procedure TForm1.FormCreate(Sender: TObject);
begin
Screen.MenuFont.Size := 30;
MainMenu1.OwnerDraw := True;
end;
On Lazarus this doesn't work.
On Lazarus you'll need to use the MenuDrawItem and MenuMeasureItem.
But even then... making the font bigger has some side effects (just try it) and will need a lot more work to get working correctly.
For using a different font it works fine.
procedure TForm1.MainMenu1DrawItem(Sender: TObject; ACanvas: TCanvas;
ARect: TRect; AState: TOwnerDrawState);
begin
ACanvas.Font.Name := 'Times New Roman';
ACanvas.Font.Size := 12;
ACanvas.Brush.Style := bsClear;
ACanvas.TextOut(ARect.left, ARect.Top, TMenuItem(Sender).Caption);
end;
procedure TForm1.MainMenu1MeasureItem(Sender: TObject; ACanvas: TCanvas;
var AWidth, AHeight: Integer);
var
NewSize: TSize;
begin
ACanvas.Font.Name := 'Times New Roman';
ACanvas.Font.Size := 12;
AWidth := ACanvas.TextWidth(TMenuItem(Sender).Caption);
AHeight := ACanvas.TextHeight('Tg');
end;