Einzelnen Beitrag anzeigen

marcibaer

Registriert seit: 27. Sep 2006
Ort: Inden
74 Beiträge
 
Delphi XE2 Professional
 
#1

Form-Icon wird invers angezeigt

  Alt 21. Nov 2011, 15:34
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:
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;
Ich setze das Icon dann im FormCreate des Forms z.B. mit
Delphi-Quellcode:
  Ic := GetIcon(18);
  Icon.Handle := IC.Handle;
  IC.Free;
Angezeigt wird es auch - allerdings invers und farblos!

Wie kann ich das korrigieren!?

Danke für Eure Hilfe ...
Marc
  Mit Zitat antworten Zitat