Forum > General
When does Menu OnDrawItem fire?
seany:
I have already asked a similar question. But, I was wondering, when does the ondrawItem event fire?
Here is my code:
--- 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.MainMenu1DrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect; AState: TOwnerDrawState);begin showMessage('1'); ACanvas.Brush.Color := clBlack; ACanvas.FillRect(ARect); ACanvas.Font.Color := clYellow; ACanvas.TextOut(ARect.Left, ARect.Top, 'TEST');end; procedure TForm1.MenuItem1DrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect; AState: TOwnerDrawState);var s: string;begin showMessage('2'); ACanvas.Brush.Color := clBlack; ACanvas.FillRect(ARect); ACanvas.Font.Color := clYellow; ACanvas.TextOut(ARect.Left, ARect.Top, TMenuItem(Sender).Caption); end;
It never seems to fire. I never quite get the showmessage popups.
I have made the menu ownerdrable in the form designer
I also thought to call the function TForm1.MenuItem1DrawItem from the main form load function. But what arguments can I pass there?
Project attached.
Lazarus 2.2.4 (rev Unknown) FPC 3.2.2 x86_64-linux-qt5
jamie:
a Widget limitation ?
Slawek:
I looked at the source code and no procedure seems to call OnDrawItem, either in TMenu or TMenuItem.
dsiders:
--- Quote from: Slawek on February 07, 2023, 11:38:14 pm ---I looked at the source code and no procedure seems to call OnDrawItem, either in TMenu or TMenuItem.
--- End quote ---
That's not correct. See TMenuItem.DoDrawItem.
Sieben:
Did you try setting OwnerDraw to True for your menu to invoke the item's OnDrawItem?
Navigation
[0] Message Index
[#] Next page