Delphi-PRAXiS
Seite 3 von 3     123   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi WinXP Icons 32 Bit (https://www.delphipraxis.net/69530-winxp-icons-32-bit.html)

Martin K 16. Mai 2006 18:12

Re: WinXP Icons 32 Bit
 
Perfekt!!! :thumb:

Danke, das isses !!!

Wie kann ich denn nur einzelne Bitmaps in die ImageList laden?
Ich will ja nicht immer die komplette Sammlung als ToolBar...

Mystic 16. Mai 2006 18:13

Re: WinXP Icons 32 Bit
 
Entweder du schneidest sie vorher aus oder du löschst alle unbrauchbaren Images aus der Imagelist.

Martin K 16. Mai 2006 18:22

Re: WinXP Icons 32 Bit
 
Also, erstmal hier der Code:
So klappts prima zur Laufzeit!

Vorraussetzung:
ToolBar mit genügend ToolButtons.
ImageList1 enthält die normalen Bitmaps,
ImageList2 für den Hover-Effekt.
Beiden ImageList müssen leer sein.

Delphi-Quellcode:
uses
  XPMan, CommCtrl, Consts;
{...}

procedure ConvertTo32BitImageList(const ImageList: TImageList);
const Mask: array[Boolean] of Longint = (0, ILC_MASK);
var TempList: TImageList;
begin
  if Assigned(ImageList) then
  begin
    TempList := TImageList.Create(nil);
    try
      TempList.Assign(ImageList);
      with ImageList do
      begin
        Handle := ImageList_Create(Width, Height, ILC_COLOR32 or Mask[Masked], 0, AllocBy);
        if not HandleAllocated then
          raise EInvalidOperation.Create(SInvalidImageList);
      end;
      Imagelist.AddImages(TempList);
    finally
      FreeAndNil(TempList);
    end;
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
var b: TBitmap; h: HModule;
begin
  ConvertTo32BitImageList(ImageList1);
  ConvertTo32BitImageList(ImageList2);
  b := TBitmap.Create;
  try
    h := LoadLibrary('shell32.dll');
    if h <> 0 then
      try

        { normal }
        b.LoadFromResourceID(h, 216);
        ImageList1.Add(b, b);
        ToolBar1.Images := ImageList1;

        { hover }
        b.LoadFromResourceID(h, 217);
        ImageList2.Add(b, b);
        ToolBar1.HotImages := ImageList2;

      finally
        FreeLibrary(h);
      end;
  finally
    b.Free;
  end;
  ToolBar1.Flat := True; // für den Hover-Effekt
end;

Martin K 16. Mai 2006 18:39

Re: WinXP Icons 32 Bit
 
Also mit:
Delphi-Quellcode:
  ImageList1.Delete(Index);
lösche ich dann einfach die Bitmaps, die ich nicht brauche...

Kann man den Code eigentlich noch verbessern ?

Ich wusste halt nicht, wie ich das schreiben soll:
ImageList1.Add(b, b);

Die Funktion wollte halt zwei Bitmaps haben...

Oder soll ich Image1.AddMasked nehmen?
Was ist hier besser?

Mystic 16. Mai 2006 19:21

Re: WinXP Icons 32 Bit
 
.Add(b, nil) schätze ich, jedenfalls solange Masked false ist.

Martin K 16. Mai 2006 19:57

Re: WinXP Icons 32 Bit
 
Hab mal zum Testen meine Systemfarbtiefe auf 16 Bit gestellt (sollte ja auch damit möglichst kompatibel sein).
Wollte mal gucken, was mit dem Alpha-Kanal passiert...

Dabei habe ich folgendes festgestellt:
bei ImageList1.Add(b, nil) oder ImageList1.Add(b, b) haben die Symbole einen schwarzen Hintergrund
(sieht besch... aus).

Wenn ich dagegen:
Delphi-Quellcode:
  ImageList1.AddMasked(b, clBlack);
schreibe, so ist die Transparenz wie auf dem Bild von Beitrag #19.
Das ist für 16 Bit ja ganz in Ordnung...


Alle Zeitangaben in WEZ +1. Es ist jetzt 11:07 Uhr.
Seite 3 von 3     123   

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