Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Multimedia (https://www.delphipraxis.net/16-multimedia/)
-   -   Delphi Bitmap in MainMenu mit Canvas zeichnen (https://www.delphipraxis.net/56797-bitmap-mainmenu-mit-canvas-zeichnen.html)

Angel4585 11. Nov 2005 11:45


Bitmap in MainMenu mit Canvas zeichnen
 
Hallo zusammen

Ich möchte mit Canvas das Bitmap links neben einem MenuItem eines MainMenus zeichnen.
Einfach ein Viereck mit irgendweiner Farbe. Kann mir jemand sagen wie das geht?

Danke schonmal

Angel4585 11. Nov 2005 11:57

Re: Bitmap in MainMenu mit Canvas zeichnen
 
Habs selber geschafft... jedenfalls fast:

Delphi-Quellcode:
procedure TtfWV.ZuknftigeWV1DrawItem(Sender: TObject; ACanvas: TCanvas;
  ARect: TRect; Selected: Boolean);
var
 BRect : TRect;
 AColor : TColor;
 AText : String;
begin
AText := (Sender as TMenuItem).Caption;
AText:=Copy(Atext,2,Length(Atext)-2);
AColor:=ACanvas.Brush.Color;
BRect:=Rect(ARect.Left,ARect.Top,ARect.Left+MENUITEMHEIGHT,ARect.Top+MENUITEMHEIGHT);
ACanvas.Brush.Color:=USEDCOLOR;
ACanvas.FillRect(BRect);
ACanvas.Brush.Color:=AColor;
ACanvas.TextOut(ARect.Left+MENUITEMHEIGHT+3,ARect.Top,AText);
ACanvas.Refresh;
end;
allerdings wird mir als Caption die alte Caption mit nem "&" Zeichen gezeigt

EDIT: Text funzt au. Hab im Original einfach en Buchstaben drangehängt, damit die Breite des DropDown Menüs ausreicht.


Alle Zeitangaben in WEZ +1. Es ist jetzt 13:20 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz