I have already asked a
similar question. But, I was wondering, when does the ondrawItem event fire?
Here is my code:
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