Forum > Graphics
2023: How to change TMenu or TPopup properties like font size or color?
(1/1)
Awesome Programmer:
Hi,
I need to change the font size or the font color of a popup menu on my form. I have gone up and down on the Internet and on this forum and I can't seem to find any working solution for my problem... I can't get the Popup Menu font size or its font name changed.
I set the OwnerDraw :=true and then assign handlers as follows.
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.PopupMenu1DrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect; AState: TOwnerDrawState);var s: string;begin // change font ACanvas.Font.Name := 'Times'; ACanvas.Font.Size := 20; ACanvas.Font.Style := [fsBold]; ACanvas.Font.Color := clYellow; // change background ACanvas.Brush.Color := clBlack; ACanvas.Rectangle(ARect); // write caption/text s := (Sender as TMenuItem).Caption; ACanvas.TextOut(ARect.Left + 2, ARect.Top + 2 , s);end;
And I see NO CHANGES AT ALL. Besides, I noticed that drawitem and measureitem handler is not EXECUTING at all.
Any idea.
fpc 3.2.0
laz 2.0.10
Blaazen:
It probably does not work on all widgetsets. It does nothing on Qt4 and GTk2.
Navigation
[0] Message Index