AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren

TComboboxEx - Icons sind schwarz

Ein Thema von FXL · begonnen am 27. Jul 2012 · letzter Beitrag vom 30. Jul 2012
Antwort Antwort
Benutzerbild von ConnorMcLeod
ConnorMcLeod

Registriert seit: 13. Okt 2010
Ort: Bayern
490 Beiträge
 
Delphi 10.4 Sydney
 
#1

AW: TComboboxEx - Icons sind schwarz

  Alt 27. Jul 2012, 16:12
Das erinnert mich sehr stark an meine Frage von vor zwei Wochen. Es liegt an der Art und Weise, wie die Grafiken der ImageList zugewiesen werden. Ich bin dann den Weg über eine Zwischen-Bitmap (oder TImage) gegangen, dann hat es gepasst.
Nr.1 Delphi-Tool: [F7]
  Mit Zitat antworten Zitat
FXL

Registriert seit: 8. Aug 2011
19 Beiträge
 
Delphi XE2 Professional
 
#2

AW: TComboboxEx - Icons sind schwarz

  Alt 27. Jul 2012, 22:13
@himitsu

zu Punkt 1. - K.A. bin nicht mehr auf Arbeit und kanns nicht mittel Photshop kontrolieren

zu Punkt 2. - Ja, ist an


@ConnorMcLeod

Geladen wird über TBitmap.loadFromFile(....)

und die Bitmaps werden in einer TImageList.add(tBitmap) gesetzt und der Combobx zugewiesen TCombobox.Images := TImageList

kannst du mir evtl. mal ein Codeauszug von deiner Lösung mitteilen


Gruß und Danke für die Unterstützung
  Mit Zitat antworten Zitat
Benutzerbild von himitsu
himitsu
Online

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
44.781 Beiträge
 
Delphi 12 Athens
 
#3

AW: TComboboxEx - Icons sind schwarz

  Alt 27. Jul 2012, 23:10
zu Punkt 2. - Ja, ist an
Das mein ich ja ... schalte es mal aus
Ein Therapeut entspricht 1024 Gigapeut.
  Mit Zitat antworten Zitat
Benutzerbild von ConnorMcLeod
ConnorMcLeod

Registriert seit: 13. Okt 2010
Ort: Bayern
490 Beiträge
 
Delphi 10.4 Sydney
 
#4

AW: TComboboxEx - Icons sind schwarz

  Alt 28. Jul 2012, 05:02
Mit dem Unterschied/Vorbehalt, daß es bei mir um Icons ging:

Delphi-Quellcode:
procedure AddIconToImageList(
        const AFileName : string
      ; var AAddToImageList : TImageList
      );
var
  licnIcon : TIcon;
  lsfiFileInfo: SHFILEINFO;
  limgInter : TImage;
  lsExePath : string;
begin
  // Create a temporary TIcon
  licnIcon := TIcon.Create;
  limgInter := TImage.Create(nil);
  try
    //Get The Icon That Represents The File
    FillChar(lsfiFileInfo, SizeOf(lsfiFileInfo), 0);
    SHGetFileInfo(PChar(AFileName + #0), 0, lsfiFileInfo, SizeOf(lsfiFileInfo), SHGFI_ICON {or SHGFI_LARGEICON});
    licnIcon.Transparent := True;
    licnIcon.Handle := lsfiFileInfo.hIcon;

    // add the icon to the imagelist:
    if Assigned(AAddToImageList) then
    begin
      limgInter.Width := licnIcon.Width;
      limgInter.Height := licnIcon.Height;
      limgInter.Picture.Bitmap.Width := licnIcon.Width;
      limgInter.Picture.Bitmap.Height := licnIcon.Height;
      limgInter.Canvas.FillRect(Rect(0, 0, limgInter.Picture.Bitmap.Width, limgInter.Picture.Bitmap.Height));
      limgInter.Transparent := True;
      limgInter.Picture.Bitmap.TransparentColor := clWhite;

      if DrawIcon(limgInter.Canvas.Handle, 0, 0, licnIcon.Handle) then
      begin
        //
      end
      else
      begin
        licnIcon.ReleaseHandle;
        licnIcon.Handle := GetIconHandleOfExtension(ExtractFileExt(AFileName), lsExePath);
        DrawIcon(limgInter.Canvas.Handle, 0, 0, licnIcon.Handle);
      end;

      AAddToImageList.AddMasked(limgInter.Picture.Bitmap, limgInter.Picture.Bitmap.TransparentColor);
    end;

    DestroyIcon(lsfiFileInfo.hIcon);
  finally
    FreeAndNil(licnIcon);
    FreeAndNil(limgInter);
  end;
end;
HTH
Nr.1 Delphi-Tool: [F7]
  Mit Zitat antworten Zitat
FXL

Registriert seit: 8. Aug 2011
19 Beiträge
 
Delphi XE2 Professional
 
#5

AW: TComboboxEx - Icons sind schwarz

  Alt 28. Jul 2012, 12:09
@ConnorMcLeod

Vielen Dank für den Codeauszug, werd es am Montag gleich probieren.

Meinst du ".ico"?? - wenn ja, kein Problem, dann wandel ich die Bilder um.


Gruß
  Mit Zitat antworten Zitat
Benutzerbild von ConnorMcLeod
ConnorMcLeod

Registriert seit: 13. Okt 2010
Ort: Bayern
490 Beiträge
 
Delphi 10.4 Sydney
 
#6

AW: TComboboxEx - Icons sind schwarz

  Alt 28. Jul 2012, 13:03
Nein, ich musste die Icons für bestimmte Extensions ermitteln. Nicht aus Grafikdateien auslesen, sondern von Windows anfordern.
Nr.1 Delphi-Tool: [F7]
  Mit Zitat antworten Zitat
FXL

Registriert seit: 8. Aug 2011
19 Beiträge
 
Delphi XE2 Professional
 
#7

AW: TComboboxEx - Icons sind schwarz

  Alt 30. Jul 2012, 11:27
So, habs heute hinbekommen, ka was falsch war, hab einfach nochmal neu angefangen und es hat funktioniert.

Hier der Quellcode (wenn noch jemand anders das selbe problem hat)

Code:
procedure TForm5.FormShow(Sender: TObject);
var
  combEx : TComboBoxEx;
  myImages : TImageList;
  image : TBitmap;
begin

  try  
    combEx := TComboBoxEx.Create(Self);
    combEx.Parent := Self;
    combEx.Visible := true;
    combEx.ItemHeight := 20;
    combEx.Style := csExDropDownList;

    combEx.Align := alLeft;
    combEx.DoubleBuffered := true;

    image := TBitmap.Create();

    myImages := TImageList.CreateSize(16, 11);
    image.LoadFromFile('Name.bmp');
    myImages.Add(image,nil);
    image.LoadFromFile('Name2.bmp');
    myImages.Add(image,nil);

    combEx.Images := myImages;

    combEx.ItemsEx.AddItem('1. Eintrag', 0, 0, -1, 0, nil);
    combEx.ItemsEx.AddItem('2. Eintrag', 1, 1, -1, 0, nil);

    combEx.ItemIndex := 0;

  except on E:Exception do begin
    MessageDlg(e.Message, mtWarning, [mbOK], 0);

  end;

  end;
end;

Gruß
  Mit Zitat antworten Zitat
Antwort Antwort

Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 11:44 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