![]() |
Transparente BMP mit SetMenuItemBitmaps
Hallo!
Ich habe ein kleines Problem mit SetMenuItemBitmaps. Es will einfach nicht klappen das die erzeugten Bilder Transparent sind. Hier mein Code :
Delphi-Quellcode:
Habe schon alles versucht auch ein Umstellen auf pf24/32bit. Zum Testen habe ich auch versucht ein TForm mit einer Imagelist zu erstellen, wo ich dann per GetBitmap(0,bmp) auf das Bild zugreife. Aber auch kein Erfolg :wall:
procedure TToolbar.ShowSearchMain(var Message: TMessage);
var pt: TPOINT; rect: TRect; hPopup: HMENU; BMP: TBitmap; begin SendMessage(hToolbarMain, TB_GETITEMRECT, 3, LPARAM(@Rect)); pt.x := Rect.Right; pt.y := Rect.Bottom - 1; Windows.ClientToScreen(hToolbarMain, pt); if pt.x < 0 then pt.x := 0; begin hPopup := CreatePopupMenu; bmp := TBitmap.Create; bmp.LoadFromResourceID(hinstance, 101); bmp.TransparentColor := rgb(255, 0, 255); bmp.Transparent := true; AppendMenu(hPopup, MF_STRING, IDM_SEARCH1, PChar('SUCHTYPE 1')); SetMenuItemBitmaps(hPopUp, 0, MF_BYPOSITION, Bmp.Handle, Bmp.Handle); AppendMenu(hPopup, MF_SEPARATOR, 0, ''); AppendMenu(hPopup, MF_STRING, IDM_SEARCH2, PChar('SUCHTYPE 2')); TrackPopupMenu(hPopup, TPM_CENTERALIGN or TPM_LEFTBUTTON, pt.x, pt.y, 0, hToolbarMain, nil); DestroyMenu(hPopup); end; end; Achso... Ich versuche das ganze unter Vista. Wäre schön wenn mir da jemand weiterhelfen könnte |
Re: Transparente BMP mit SetMenuItemBitmaps
Mahlzeit!
Hat der transparente Hintergrund deines Bitmaps möglicherweise nicht die Farbe rgb(255,0,255) (Pink)? Ich würde es testweise mal damit versuchen:
Delphi-Quellcode:
Sofern der linke obere Pixel des bmp zum transparenten Hintergrund gehört.
bmp.TransparentColor := bmp.Canvas.Pixels[0,0]
Gruß Bear |
Re: Transparente BMP mit SetMenuItemBitmaps
Hi!
Klappt auch nicht :( Ich habe jetzt eine Notlösung gefunden, aber Perfekt ist die leider nicht weil das Bild nicht wirklich Transparent ist. Ausserdem geht das so nur mit 16 Farben
Delphi-Quellcode:
procedure TToolbar.ShowSearchMain(var Message: TMessage);
var pt: TPOINT; rect: TRect; hPopup: HMENU; hBitmap: THandle ; cm : array[0..3]of TColorMap; begin SendMessage(hToolbarMain, TB_GETITEMRECT, 3, LPARAM(@Rect)); pt.x := Rect.Right; pt.y := Rect.Bottom - 1; Windows.ClientToScreen(hToolbarMain, pt); if pt.x < 0 then pt.x := 0; begin hPopup := CreatePopupMenu; cm[0].cFrom := $00ff00ff; cm[0].cTo := GetSysColor(COLOR_3DFACE); hBitmap := CreateMappedBitmap( hInstance,101,0,@cm[0],length(cm)); AppendMenu(hPopup, MF_STRING, IDM_SEARCH1, PChar('SUCHTYPE 1')); SetMenuItemBitmaps(hPopUp, 0, MF_BYPOSITION, hBitmap, hBitmap); AppendMenu(hPopup, MF_SEPARATOR, 0, ''); AppendMenu(hPopup, MF_STRING, IDM_SEARCH2, PChar('SUCHTYPE 2')); TrackPopupMenu(hPopup, TPM_CENTERALIGN or TPM_LEFTBUTTON, pt.x, pt.y, 0, hToolbarMain, nil); DestroyMenu(hPopup); end; end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 10:30 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz