Registriert seit: 16. Jan 2004
Ort: Bendorf
5.219 Beiträge
Delphi 10.2 Tokyo Professional
|
Re: Popupmenü: unerklärlicher Fehler
9. Aug 2006, 14:32
Delphi-Quellcode:
procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
for i:= 0 to PopUpMenu1.Items.Count-1 do begin
PopUpMenu1.Items[i].OnDrawItem := MyDraw;
end;
for i:= 0 to Popupmenu1.Items[3].Count-1 do
begin
PopUpMenu1.Items[3].Items[i].OnDrawItem := MyDraw;
end;
end;
procedure TForm1.MyDraw(Sender: TObject; ACanvas: TCanvas; ARect: TRect;
Selected: Boolean);
var ACaption: TCaption;
begin
ACaption := TMenuItem(Sender).Caption;
with ACanvas do
begin
if Selected then
begin
Brush.Color := $00DDEEFF;
Font.Color := clblack;
end
else
begin
Brush.Color := clblack;
Font.Color := $00DDEEFF;
end;
FillRect(ARect);
ARect.Left := ARect.Left + 5;
DrawText( Handle, PChar(acaption), Length(acaption),
aRect, DT_SINGLELINE or DT_VCENTER);
end;
end;
So müsstes gehn
Gruß
Neutral General
Michael "Programmers talk about software development on weekends, vacations, and over meals not because they lack imagination,
but because their imagination reveals worlds that others cannot see."
|
|
Zitat
|