Delphi-PRAXiS

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 16:14


WinXP Icons 32 Bit
 
Hi Leute,

würde gerne die 32 Bit Icons von Windows in meinem Programm einbinden.
Natürlich nicht das Icon selbst einbinden (wegen Linzenrechten geht das glaub ich nicht), sondern es eben bei FormCreate aus Windows rausholen.

Dazu gibts ja diesen Code,
allerdings erhalte ich dann immer das 4 Bit Icon, nicht das 32 Bit XP-Icon...

Mystic 16. Mai 2006 16:53

Re: WinXP Icons 32 Bit
 
Also ich extrahier die Icons so:

Delphi-Quellcode:
uses
  ShellApi;

var
  h: HICON;
  hi: TIcon;

hi := TIcon.Create;
h := ExtractIcon(HINSTANCE, 'shell32.dll', 3); // Extrahiert das 3. Icon
hi.Handle := h;

Martin K 16. Mai 2006 16:55

Re: WinXP Icons 32 Bit
 
Ja, aber in der shell32.dll gibts nicht die Icons die ich brauche:

Delete, Cut, Copy, Paste, FileOpen, FileClose...

...sind da alle nicht drin!

SirThornberry 16. Mai 2006 16:56

Re: WinXP Icons 32 Bit
 
@Mystic: Als ersten Parameter solltest du aber nicht das Handle von Application übergeben sondern "hinstance".

Mystic 16. Mai 2006 16:57

Re: WinXP Icons 32 Bit
 
Oops, stimmt. :oops:

Die Icons die du suchst Martin gibt es nur in 16 Farben (siehe z.B. wordpad.exe).

Icons mit mehr Farben musst du von einer anderen Quelle beziehen. GlyFX hat ein nettes kostenloses "Common Toolbar Set".

Martin K 16. Mai 2006 17:02

Re: WinXP Icons 32 Bit
 
Liste der Anhänge anzeigen (Anzahl: 1)
Copy und Delete hab ich gefunden...

Die anderen sind aber definitiv nicht drin.

Zum Anhang:
Die müssen doch irgendwo in Windows drin sein???

Mystic 16. Mai 2006 17:03

Re: WinXP Icons 32 Bit
 
Ach ja, der Explorer hat ja auch noch die Toolbar-Icons...

Daniel G 16. Mai 2006 17:04

Re: WinXP Icons 32 Bit
 
Hmm... weiß jemand, was der Unterschied zwischen diesen Konstanten ist?

IDB_STD_SMALL_COLOR <> IDB_VIEW_SMALL_COLOR

Sonst hätte ich ihm die "_VIEW_" - Konstante mal vorgeschlagen...

Mystic 16. Mai 2006 17:05

Re: WinXP Icons 32 Bit
 
Die View-Konstante ist für die View-Bilder.
PSDK:
VIEW_DETAILS Specifies the view details image.
VIEW_LARGEICONS Specifies the view large icons image.
VIEW_LIST Specifies the view list image.
VIEW_SMALLICONS Specifies the view small icons image.
VIEW_SORTDATE Specifies the sort by date image.
VIEW_SORTNAME Specifies the sort by name image.
VIEW_SORTSIZE Specifies the sort by size image.
VIEW_SORTTYPE Specifies the sort by type image.

Martin K 16. Mai 2006 17:07

Re: WinXP Icons 32 Bit
 
Ja, wo holt sie der Explorer eigentlich her :gruebel:

@Daniel G:
gleich mal ausprobieren...
//Edit: Auch nur 4 Bit Icons...

Zitat:

Zitat von Mystic
Die View-Konstante ist für die View-Bilder.
PSDK:
VIEW_DETAILS Specifies the view details image.
VIEW_LARGEICONS Specifies the view large icons image.
VIEW_LIST Specifies the view list image.
VIEW_SMALLICONS Specifies the view small icons image.
VIEW_SORTDATE Specifies the sort by date image.
VIEW_SORTNAME Specifies the sort by name image.
VIEW_SORTSIZE Specifies the sort by size image.
VIEW_SORTTYPE Specifies the sort by type image.

Ja, aber mit VIEW_32 Bit ist da nix dabei, oder ?

Daniel G 16. Mai 2006 17:08

Re: WinXP Icons 32 Bit
 
@Mystic: Jepp, danke... Jetzt hab' ich's auch gelesen... :wall:

Mystic 16. Mai 2006 17:14

Re: WinXP Icons 32 Bit
 
Ich hab sie...

shell32.dll
32x32 Normal: Bitmap 215
32x32 Hover: Bitmap 214
16x16 Normal: Bitmap 217
16x16 Hover: Bitmap 216

Martin K 16. Mai 2006 17:23

Re: WinXP Icons 32 Bit
 
Liste der Anhänge anzeigen (Anzahl: 1)
Zitat:

Zitat von Mystic
Ich hab sie...

shell32.dll
32x32 Normal: Bitmap 215
32x32 Hover: Bitmap 214
16x16 Normal: Bitmap 217
16x16 Hover: Bitmap 216

Hmm....

Da bekomme ich diese hier...
:gruebel:

Hab Deinen Code aus Beitrag #2 verwendet.

Mystic 16. Mai 2006 17:29

Re: WinXP Icons 32 Bit
 
Nicht Icons, Bitmaps ;)

Delphi-Quellcode:
var
  h: HMODULE;
  b: TBitmap;

b := TBitmap.Create;
try
  h := LoadLibrary('shell32.dll');
  if h <> 0 then
    try
      b.LoadFromResourceID(h, 215); // Bitmap 215
      // Mach was mit b
    finally
      FreeLibrary(h);
    end;
finally
  b.Free;
end;

Martin K 16. Mai 2006 17:33

Re: WinXP Icons 32 Bit
 
Liste der Anhänge anzeigen (Anzahl: 1)
Hääää????
Da kommt das bei raus...
(Bild im Anhang).


//Edit:
Probelm gelöst.
Hatte nur mein TImage zu schmal gemacht :wall:

Mystic 16. Mai 2006 17:35

Re: WinXP Icons 32 Bit
 
Die Bitmaps sind 32bit-Bitmaps (Alphakanal!), die jeweils 45 Icons nebeneinander beinhalten.

Martin K 16. Mai 2006 17:36

Re: WinXP Icons 32 Bit
 
Hm...
Und wie kann ich die in eine ToolBar (mit ImageList oder so) laden?

Mystic 16. Mai 2006 17:42

Re: WinXP Icons 32 Bit
 
Keine Ahnung. Aber ich würde mal probieren, den Alphakanal in ein zweites Bitmap (Graustufen) zu kopieren und dies als Maske für das Original zu nehmen. Dann müsstest du das Bitmap und die Maske zur ImageList (Masked true) per ImageList.Add(bitmap, maske) hinzufügen können.

Martin K 16. Mai 2006 17:56

Re: WinXP Icons 32 Bit
 
Liste der Anhänge anzeigen (Anzahl: 1)
Hab jetzt einfach mal als Bitmap gespeichert und in eine ImageList geladen.
Dabei hat er mich auch gleich gefragt:
Zitat:

---------------------------
Bestätigung
---------------------------
Die Dimensionen für Bitmap test.bmp sind größer als die der Bilderliste. In 47 verschiedene Bitmaps aufteilen?
---------------------------
Ja Nein
---------------------------
Perfekt!!

Jetzt hab ich die Bitmaps alle einzeln in der ImageList!!!
Probleme gibts nur mit dem Alpha Kanal:
Sieht dann in einer ToolBar doch etwas bescheiden aus...

Gibt es vielleicht eine Komponente wie ImageList, die Alpha-Kanal unterstützt?

Mystic 16. Mai 2006 17:59

Re: WinXP Icons 32 Bit
 
Hab was gefunden:

http://qc.borland.com/qc/wc/qcmain.aspx?d=4653
Run the following procedure *before* adding any icons to the image list (add Consts and CommCtrl units to the uses clause; also add XP manifest to your project):
Delphi-Quellcode:
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;

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 02:33 Uhr.

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