![]() |
Form-Icon wird invers angezeigt
Hallo zusammen!
Ich versuche, die Bitmaps, die auf meinen ToolButtons angezeigt werden, auch als Icon der zugehörigen Forms anzeigen zu lassen. Im Netz hab ich dazu folgendes gefunden:
Delphi-Quellcode:
Ich setze das Icon dann im FormCreate des Forms z.B. mit
function CreateIconFromBitmap(Bitmap:TBitmap):TIcon;
begin with TImageList.CreateSize(Bitmap.Width, Bitmap.Height) do begin try AllocBy := 1; {$IFDEF VER90} with Bmp do AddMasked(Bitmap, Canvas.Pixels[Width-1, Height-1]); {$ELSE} AddMasked(Bitmap, Bitmap.TransparentColor); {$ENDIF} Result := TIcon.Create; try GetIcon(0, Result); except Result.Free; raise; end; finally Free; end; end; end; function GetIcon(Index:Word):TIcon; var Image: TBitmap; begin Image := TBitmap.Create; ImageList1.GetBitmap(Index,Image); Result := CreateIconFromBitmap(Image); Image.Free; end;
Delphi-Quellcode:
Angezeigt wird es auch - allerdings invers und farblos!
Ic := GetIcon(18);
Icon.Handle := IC.Handle; IC.Free; Wie kann ich das korrigieren!? Danke für Eure Hilfe ... |
AW: Form-Icon wird invers angezeigt
ich könnte folgendes anbieten
Delphi-Quellcode:
procedure Bitmap2Icon(BMP: TBitmap; Ico: TIcon);
var IconInfo : TIconInfo; begin BMP.PixelFormat := pf24bit; IconInfo.fIcon := true; IconInfo.xHotspot := 0; IconInfo.yHotspot := 0; IconInfo.hbmMask := BMP.Handle; IconInfo.hbmColor := BMP.Handle; Ico.Handle := CreateIconIndirect(IconInfo); end; procedure TForm2.Button1Click(Sender: TObject); begin Bitmap2Icon(Image1.Picture.Bitmap,Icon); end; |
AW: Form-Icon wird invers angezeigt
Würde das hier nicht auch genügen?
Delphi-Quellcode:
procedure TForm1.IconFromList(Index: integer);
begin ImageList1.GetIcon(Index, self.Icon); end; |
AW: Form-Icon wird invers angezeigt
@Bummi: Icon ist nun bunt, dafür ist der Hintergrund orange!
@DeddyH: Top - funktioniert einwandfrei. Manchmal ist es doch ganz einfach! Danke, Euch beiden ... |
Alle Zeitangaben in WEZ +1. Es ist jetzt 06:26 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