Seite 1 von 1

Icons aus DLL holen

Verfasst: 05.08.2017 18:53
von hjbremer
Gibt es, aber wenn man es braucht nicht zu finden oder macht nicht das was man braucht

Hier ein weiterer Beitrag von mir zu dem Thema,
außerdem wollte ich mal den Form-Designer ausprobieren. nun ja, brauchbar aaaaber ...

Code: Alles auswählen

; 05.08.2017 HJBremer - PB 5.60 x64 Windows 10

EnableExplicit
Enumeration FormGadget
  #Window_0
  #ListIcon_Main
  #Combo_DLL
  #Button_Copy
  #ListIcon_Wahl
  #Button_Kill
  #Editor_Befehle
  #Option_16
  #Option_32
  #Image_Show
EndEnumeration

LoadFont(0, "Consolas", 11)
SetGadgetFont(#PB_Default, FontID(0))

Procedure FillListe(file$)
   Protected j, icon, anz = ExtractIconEx_(file$, -1, #Null, #Null, #Null) - 1
   Protected iconinfo.ICONINFO, bitmap.BITMAP
   
   ClearGadgetItems(#ListIcon_Main)   
   HideGadget(#ListIcon_Main, 1)   
   For j = 0 To anz      
      If GetGadgetState(#Option_16)
         ExtractIconEx_(file$, j, #Null, @icon, 1)    ;16x16         
      Else
         ExtractIconEx_(file$, j, @icon, #Null, 1)    ;32x32
      EndIf
      GetIconInfo_(icon, iconinfo)
      GetObject_(iconinfo\hbmMask, SizeOf(BITMAP), bitmap)
      AddGadgetItem(#ListIcon_Main, j, "Nr " + Str(j) + " " + Str(bitmap\bmWidth) + "x" + Str(bitmap\bmHeight), icon)
      DestroyIcon_(icon)
   Next   
   HideGadget(#ListIcon_Main, 0)
EndProcedure

Procedure OpenWindow_0(x = 0, y = 0, width = 1360, height = 750)
  OpenWindow(#Window_0, x, y, width, height, "Icon", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_ScreenCentered | #PB_Window_WindowCentered)
  ListIconGadget(#ListIcon_Main, 10, 10, 950, 730, "Column 1", 100)
  ComboBoxGadget(#Combo_DLL, 980, 510, 190, 25, #PB_ComboBox_Editable)
  ButtonGadget(#Button_Copy, 980, 550, 190, 25, "Copy to Clipboard")
  ListIconGadget(#ListIcon_Wahl, 970, 10, 380, 480, "Column 1", 150, #PB_ListIcon_MultiSelect | #PB_ListIcon_AlwaysShowSelection)
  SetGadgetFont(#ListIcon_Wahl, #PB_Default)
  ButtonGadget(#Button_Kill, 1180, 550, 170, 25, "Auswahl Löschen")
  EditorGadget(#Editor_Befehle, 980, 590, 370, 150)
  ImageGadget(#Image_Show, 1180, 510, 0, 0, 0, #PB_Image_Raised)
  OptionGadget(#Option_16, 1225, 510, 60, 20, "16x16")
  OptionGadget(#Option_32, 1290, 510, 60, 20, "32x32")
  SetGadgetState(#Option_32, 1)
  SetGadgetAttribute(#ListIcon_Main, #PB_ListIcon_DisplayMode, #PB_ListIcon_LargeIcon)
  SetGadgetAttribute(#ListIcon_Wahl, #PB_ListIcon_DisplayMode, #PB_ListIcon_LargeIcon)  
EndProcedure

Procedure Window_0_Events(event)
  Protected file$, icon, item, info$ 
  Select event    
    Case #PB_Event_Gadget
      Select EventGadget()
        Case #ListIcon_Main
           If EventType() = #PB_EventType_LeftClick              
              file$ = GetGadgetText(#Combo_DLL)
              item = GetGadgetState(#ListIcon_Main)              
              If item > -1
                 If GetGadgetState(#Option_16)
                    ExtractIconEx_(file$, item, #Null, @icon, 1): info$ = "16" 
                 Else
                    ExtractIconEx_(file$, item, @icon, #Null, 1): info$ = "32"
                    ;oder icon = ExtractIcon_(0, file$, item) nur 32                     
                 EndIf
                 SetGadgetState(#Image_Show, icon)
                 AddGadgetItem(#ListIcon_Wahl, -1, file$ + "-" + Str(item) + "-" + info$, icon)
                 DestroyIcon_(icon)
              EndIf
           EndIf
                      
        Case #Combo_DLL
           If EventType() = #PB_EventType_Change
             FillLIste(GetGadgetText(#Combo_DLL)) 
           EndIf           
           
        Case #Button_Copy
           Protected anz = CountGadgetItems(#ListIcon_Wahl) - 1
           Protected befehl$, befehl0$ = "", befehl1$ = "", befehl2$ = "", nr = 0
           Protected j, x$, item$, form$, name$
           
           For j = 0 To anz
              x$ = GetGadgetItemText(#ListIcon_Wahl, j)
              file$ = #DOUBLEQUOTE$ + StringField(x$, 1, "-") + #DOUBLEQUOTE$   ;DLL Name
              item$ = RSet(StringField(x$, 2, "-"), 3)      ;nr in der DLL
              form$ = StringField(x$, 3, "-")               ;16 oder 32              
              nr + 1: name$ = "icon" + RSet(Str(nr), 3, "0")              
              If form$ = "32"
                 befehl0$ + "Define " + name$ + " = ExtractIcon_(0, " + file$ +  ", " + item$ + ")  ;32x32" + #CRLF$
              Else
                 befehl0$ + "Define " + name$ + #CRLF$                  
                 befehl1$ + "ExtractIconEx_(" + file$ + ", " + item$ + ", #Null, @" + name$ + ", 1)  ;16x16" + #CRLF$                  
              EndIf                            
              befehl2$ + "DestroyIcon_(" + name$ + ")" + #CRLF$               
           Next
           befehl$ = befehl0$ + #CRLF$ + befehl1$ + #CRLF$ + befehl2$           
           SetClipboardText(befehl$)
           SetGadgetText(#Editor_Befehle, befehl$)
           
        Case #Button_Kill
           item = GetGadgetState(#ListIcon_Wahl)
           If item > -1
              RemoveGadgetItem(#ListIcon_Wahl, item)
              SetGadgetState(#ListIcon_Wahl, item)
           EndIf
           
        Case #Option_16
           SetGadgetAttribute(#ListIcon_Main, #PB_ListIcon_DisplayMode, #PB_ListIcon_SmallIcon) 
           FillLIste(GetGadgetText(#Combo_DLL)) 
           SetGadgetState(#Image_Show, 0)  
           
        Case #Option_32
           SetGadgetAttribute(#ListIcon_Main, #PB_ListIcon_DisplayMode, #PB_ListIcon_LargeIcon) 
           FillLIste(GetGadgetText(#Combo_DLL))
           SetGadgetState(#Image_Show, 0)            
     EndSelect  
     
  EndSelect
EndProcedure

OpenWindow_0()
AddGadgetItem(#Combo_DLL, -1, "shell32.dll")
AddGadgetItem(#Combo_DLL, -1, "moricons.dll")
AddGadgetItem(#Combo_DLL, -1, "DDORes.dll")
AddGadgetItem(#Combo_DLL, -1, "ieframe.dll")
AddGadgetItem(#Combo_DLL, -1, "imageres.dll")
AddGadgetItem(#Combo_DLL, -1, "wmploc.dll")
AddGadgetItem(#Combo_DLL, -1, "compstui.dll")
AddGadgetItem(#Combo_DLL, -1, "mmcndmgr.dll")
AddGadgetItem(#Combo_DLL, -1, "pifmgr.dll")

SetGadgetState(#Combo_DLL, 0) 
FillLIste(GetGadgetText(#Combo_DLL)) 

Repeat
    Define Event = WaitWindowEvent()    
    Select EventWindow()
      Case #Window_0
        Window_0_Events(Event)            
    EndSelect    
 Until Event = #PB_Event_CloseWindow 
 
Da über das Thema Lizenz in einem anderen Thread gesprochen wird. Jeder darf obigen Code oder Teile daraus benutzen und weiter verbreiten.

PS: wird weiter verbreiten zusammen geschrieben oder auseinander ?

Re: Icons aus DLL holen

Verfasst: 05.08.2017 18:57
von Mijikai
Nice :allright:

Re: Icons aus DLL holen

Verfasst: 09.08.2017 00:32
von TheCube
Sehr nützlich :allright:

Wenn du Lust auf Erweiterungen hast:
- Neben der grossen Vorauswahl trotzdem noch ein Filerequester um andere DLLs/Files einzuladen
- Möglichkeit, die Auswahl auch als .ico-File zu speichern
- Auswahl grösserer Icons (z.B. 48x48 wenn vorhanden), ich weiss dank Google, mit ExtractIconEx_ ist es da nicht getan.

Aber auch so kann ich schon jetzt die meisten meine Hilfs-code-Schnipsel zum Thema nun einmotten.

Re: Icons aus DLL holen

Verfasst: 09.08.2017 08:39
von RSBasic
Alternativ kann man auch den Dialog von Windows verwenden, wenn man einen Iconauswahl-Requester braucht: http://www.rsbasic.de/aktualisierung/wi ... -Dialog.pb

Re: Icons aus DLL holen

Verfasst: 09.08.2017 12:27
von hjbremer
hier die Version mit Dateiauswahl, zwar noch nicht ausgiebig getestet, aber sollte ok sein.

die anderen Vorschläge werde ich nicht einbauen, da ich diese nicht brauche.

nur zur Info für SaveIcon, kenne ich 2 Beiträge
; http://www.purearea.net/pb/CodeArchiv/G ... Creator.pb
;SaveIcon von http://www.purebasic.fr/english/viewtopic.php?t=23387

Code: Alles auswählen

; 06.08.2017 HJBremer - PB 5.60 x64 Windows 10

EnableExplicit
Enumeration FormGadget
   #Window_0
   #ListIcon_Main
   #Combo_DLL
   #Button_Copy
   #ListIcon_Wahl
   #Explorer_Cont
   #Explorer_List
   #Explorer_Info
   #Button_Kill
   #Button_File
   #Editor_Befehle
   #Option_16
   #Option_32
   #Image_Show16
   #Image_Show32  
EndEnumeration

LoadFont(0, "Consolas", 11)
SetGadgetFont(#PB_Default, FontID(0))

Global icondatei$

Procedure FillListe(file$)
   
   icondatei$ = file$   ; global: wird bei Leftclick in #ListIcon_Main gebraucht und bei #Option..
   
   Protected j, icon, anz = ExtractIconEx_(file$, -1, #Null, #Null, #Null) - 1
   Protected iconinfo.ICONINFO, bitmap.BITMAP
   
   ClearGadgetItems(#ListIcon_Main)   
   HideGadget(#ListIcon_Main, 1)   
   For j = 0 To anz      
      If GetGadgetState(#Option_16)
         ExtractIconEx_(file$, j, #Null, @icon, 1)    ;16x16         
      Else
         ExtractIconEx_(file$, j, @icon, #Null, 1)    ;32x32
      EndIf
      GetIconInfo_(icon, iconinfo)
      GetObject_(iconinfo\hbmMask, SizeOf(BITMAP), bitmap)
      AddGadgetItem(#ListIcon_Main, j, "Nr " + Str(j) + " " + Str(bitmap\bmWidth) + "x" + Str(bitmap\bmHeight), icon)
      DestroyIcon_(icon)
   Next   
   HideGadget(#ListIcon_Main, 0)
EndProcedure

Procedure OpenWindow_0(x = 0, y = 0, width = 1360, height = 750)
   ;mit Formdesigner erstellt
   OpenWindow(#Window_0, x, y, width, height, "Icon", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_ScreenCentered | #PB_Window_WindowCentered)
   ListIconGadget(#ListIcon_Main, 10, 10, 950, 730, "Column 1", 100)
   ComboBoxGadget(#Combo_DLL, 970, 510, 170, 25, #PB_ComboBox_Editable)
   ButtonGadget(#Button_Copy, 970, 550, 170, 25, "Copy to Clipboard")
   ListIconGadget(#ListIcon_Wahl, 970, 10, 380, 480, "Column 1", 150, #PB_ListIcon_MultiSelect | #PB_ListIcon_AlwaysShowSelection)
   SetGadgetFont(#ListIcon_Wahl, #PB_Default)  
   ButtonGadget(#Button_File, 1150, 510, 95, 25, "Files")
   ButtonGadget(#Button_Kill, 1255, 510, 95, 25, "Löschen")
   EditorGadget(#Editor_Befehle, 970, 590, 380, 150)
   ImageGadget(#Image_Show16, 1160, 550, 0, 0, 0, #PB_Image_Raised): HideGadget(#Image_Show16, 1)
   ImageGadget(#Image_Show32, 1160, 544, 0, 0, 0, #PB_Image_Raised)
   OptionGadget(#Option_16, 1210, 550, 60, 20, "16x16")
   OptionGadget(#Option_32, 1275, 550, 60, 20, "32x32")
   SetGadgetState(#Option_32, 1)
   SetGadgetAttribute(#ListIcon_Main, #PB_ListIcon_DisplayMode, #PB_ListIcon_LargeIcon)
   SetGadgetAttribute(#ListIcon_Wahl, #PB_ListIcon_DisplayMode, #PB_ListIcon_LargeIcon)  
EndProcedure

Procedure Thread(x)
   ;nur für schöneren Programmstart, da es etwas dauert das Verzeichnis zu lesen
   SetGadgetText(#Explorer_List, "c:\windows\system32\*.dll;*.exe")
   SetGadgetText(#Explorer_Info, GetGadgetText(#Explorer_List))
EndProcedure

Procedure ExplorerListe()
   Protected info$, br
   
   ContainerGadget(#Explorer_Cont, 0, 0, 0, 0)
   HideGadget(#Explorer_Cont, 1)
   TextGadget(#Explorer_Info, 0, 0, 380, 20, "")
   ExplorerListGadget(#Explorer_List, 0, 20, 380, 460, "", #PB_Explorer_GridLines|#PB_Explorer_AlwaysShowSelection)   
   CloseGadgetList()
   
   RemoveGadgetColumn(#Explorer_List, 3)
   RemoveGadgetColumn(#Explorer_List, 2)
   
   br = GetGadgetItemAttribute(#Explorer_List, 0, #PB_Explorer_ColumnWidth, 1)
   br - 10
   SetGadgetItemAttribute(#Explorer_List, 0, #PB_Explorer_ColumnWidth, br, 1)
   
   br = 380 - br - 25
   SetGadgetItemAttribute(#Explorer_List, 0, #PB_Explorer_ColumnWidth, br, 0)
   
   SetGadgetFont(#Explorer_List, #PB_Default)  
   SetGadgetFont(#Explorer_Info, #PB_Default)
   
   CreateThread(@Thread(), br)
   
   ResizeGadget(#Explorer_Cont, 970, 10, 380, 480)
   
EndProcedure

Procedure Window_0_Events(event)   
   Protected file$, icon, item, info$
   Static flag
   
   Select event    
      Case #PB_Event_Gadget
         Select EventGadget()
            Case #ListIcon_Main
               If EventType() = #PB_EventType_LeftClick              
                  file$ = icondatei$
                  If GetPathPart(file$) = "C:\windows\system32\"
                     ; Files aus system32 findet Windows auch ohne Path
                     file$ = GetFilePart(file$) 
                  EndIf
                  item = GetGadgetState(#ListIcon_Main)              
                  If item > -1
                     If GetGadgetState(#Option_16)
                        ExtractIconEx_(file$, item, #Null, @icon, 1): info$ = "16" 
                        SetGadgetState(#Image_Show16, icon)                 
                     Else
                        ExtractIconEx_(file$, item, @icon, #Null, 1): info$ = "32"
                        ;oder icon = ExtractIcon_(0, file$, item) nur 32  
                        SetGadgetState(#Image_Show32, icon)                 
                     EndIf
                     AddGadgetItem(#ListIcon_Wahl, -1, file$ + "-" + Str(item) + "-" + info$, icon)
                     DestroyIcon_(icon)
                  EndIf
               EndIf
               
            Case #Combo_DLL
               If EventType() = #PB_EventType_Change
                  FillListe(GetGadgetText(#Combo_DLL)) 
               EndIf
               
            Case #Button_Copy
               Protected anz = CountGadgetItems(#ListIcon_Wahl) - 1
               Protected befehl$, befehl0$ = "", befehl1$ = "", befehl2$ = "", nr = 0
               Protected j, x$, item$, form$, name$
               
               For j = 0 To anz
                  x$ = GetGadgetItemText(#ListIcon_Wahl, j)
                  file$ = #DOUBLEQUOTE$ + StringField(x$, 1, "-") + #DOUBLEQUOTE$   ;DLL Name
                  item$ = RSet(StringField(x$, 2, "-"), 3)                          ;nr in der DLL
                  form$ = StringField(x$, 3, "-")                                   ;16 oder 32              
                  nr + 1: name$ = "icon" + RSet(Str(nr), 3, "0")              
                  If form$ = "32"
                     befehl0$ + "Define " + name$ + " = ExtractIcon_(0, " + file$ +  ", " + item$ + ")  ;32x32" + #CRLF$
                  Else
                     befehl0$ + "Define " + name$ + #CRLF$                  
                     befehl1$ + "ExtractIconEx_(" + file$ + ", " + item$ + ", #Null, @" + name$ + ", 1)  ;16x16" + #CRLF$                  
                  EndIf                            
                  befehl2$ + "DestroyIcon_(" + name$ + ")" + #CRLF$               
               Next
               befehl$ = befehl0$ + #CRLF$ + befehl1$ + #CRLF$ + befehl2$           
               SetClipboardText(befehl$)
               SetGadgetText(#Editor_Befehle, befehl$)
               
            Case #Button_Kill
               item = GetGadgetState(#ListIcon_Wahl)
               If item > -1
                  RemoveGadgetItem(#ListIcon_Wahl, item)
                  SetGadgetState(#ListIcon_Wahl, item)
               EndIf
               
            Case #Option_16
               SetGadgetAttribute(#ListIcon_Main, #PB_ListIcon_DisplayMode, #PB_ListIcon_SmallIcon) 
               FillListe(icondatei$) 
               SetGadgetState(#Image_Show16, 0)  
               HideGadget(#Image_Show16, 0): HideGadget(#Image_Show32, 1)
               
            Case #Option_32
               SetGadgetAttribute(#ListIcon_Main, #PB_ListIcon_DisplayMode, #PB_ListIcon_LargeIcon) 
               FillListe(icondatei$)
               SetGadgetState(#Image_Show32, 0)
               HideGadget(#Image_Show16, 1): HideGadget(#Image_Show32, 0)
               
            Case #Button_File  
               If flag = 0
                  flag = 1
                  SetGadgetText(#Button_File, "Auswahl")
                  HideGadget(#ListIcon_Wahl, 1): HideGadget(#Explorer_Cont, 0)
                  item = GetGadgetState(#Explorer_List)
                  file$ = GetGadgetText(#Explorer_List) + GetGadgetItemText(#Explorer_List, item)
                  If GetGadgetItemState(#Explorer_List, item) & #PB_Explorer_File = #PB_Explorer_File              
                     FillListe(file$)              
                  EndIf
                  SetActiveGadget(#Explorer_List)
               Else
                  flag = 0
                  SetGadgetText(#Button_File, "Files")
                  HideGadget(#ListIcon_Wahl, 0): HideGadget(#Explorer_Cont, 1)
                  FillListe(GetGadgetText(#Combo_DLL)) 
               EndIf
               
            Case #Explorer_List
               info$ = GetGadgetText(#Explorer_List): SetGadgetText(#Explorer_Info, info$)               
               Select EventType() 
                  Case #PB_EventType_LeftClick
                     
                  Case #PB_EventType_Change 
                     item = GetGadgetState(#Explorer_List)
                     file$ = GetGadgetText(#Explorer_List) + GetGadgetItemText(#Explorer_List, item)
                     If GetGadgetItemState(#Explorer_List, item) & #PB_Explorer_File = #PB_Explorer_File              
                        FillListe(file$)              
                     EndIf
               EndSelect
               
         EndSelect  
         
   EndSelect
EndProcedure

OpenWindow_0()
ExplorerListe()

AddGadgetItem(#Combo_DLL, -1, "shell32.dll")
AddGadgetItem(#Combo_DLL, -1, "moricons.dll")
AddGadgetItem(#Combo_DLL, -1, "imageres.dll")
AddGadgetItem(#Combo_DLL, -1, "DDORes.dll")
AddGadgetItem(#Combo_DLL, -1, "ieframe.dll")
AddGadgetItem(#Combo_DLL, -1, "wmploc.dll")
AddGadgetItem(#Combo_DLL, -1, "compstui.dll")
AddGadgetItem(#Combo_DLL, -1, "mmcndmgr.dll")
AddGadgetItem(#Combo_DLL, -1, "pifmgr.dll")
AddGadgetItem(#Combo_DLL, -1, "cryptui.dll")

SetGadgetState(#Combo_DLL, 0) 
FillListe(GetGadgetText(#Combo_DLL)) 

Repeat
   Define Event = WaitWindowEvent()    
   Select EventWindow()
      Case #Window_0
         Window_0_Events(Event)            
   EndSelect    
Until Event = #PB_Event_CloseWindow 

Re: Icons aus DLL holen

Verfasst: 09.08.2017 20:06
von TheCube
Danke, bin begeistert. Das mit der Fileauswahl ist ja noch besser als erhofft.
Einfach mit den Cursor Up/Down-Tasten im z.B. System32-Verzeichnis wandern,
und direkt sehen ob da auch noch andere "Schätzchen" versteckt sind. <)

Und dann halt mit ResourceHacker o.ä. das rausholen, was und wie man es braucht, soweit dort vorhanden.
(Betreffend als .ico-File speichern, Farbtiefe, 16x16 bis 128x128, usw.)

@RSBasic: Bzgl. Iconauswahl-Requester per Dialog von Windows:
Kannte ich zwar flüchtig, ist schon oft ganz brauchbar. Aber man bekommt dieses Minifenster nicht größer gezogen !?
-> Bei einer shell32.dll ist das leider sehr unübersichtlich.

Re: Icons aus DLL holen

Verfasst: 09.08.2017 21:42
von ts-soft
Und dann halt mit ResourceHacker o.ä. das rausholen, was und wie man es braucht, soweit dort vorhanden.
Dabei aber unbedingt das Copyright beachten! Gegen das benutzen vorhandener Icons wird wohl kaum einer was haben, aber
beim Extrahieren und Kopieren könnte es einschränkungen geben!

Re: Icons aus DLL holen

Verfasst: 09.08.2017 22:12
von RSBasic
TheCube hat geschrieben:@RSBasic: Bzgl. Iconauswahl-Requester per Dialog von Windows:
Kannte ich zwar flüchtig, ist schon oft ganz brauchbar. Aber man bekommt dieses Minifenster nicht größer gezogen !?
-> Bei einer shell32.dll ist das leider sehr unübersichtlich.

Code: Alles auswählen

EnableExplicit

Define IcoLibPath$ = "C:\Windows\System32\shell32.dll"
Define DlgResult
Define hWnd=0
Define DefaultIconID = 5

#IDOK = 1
#IDCANCEL = 2
#IDABORT = 3
#IDRETRY = 4
#IDIGNORE = 5
#IDYES = 6
#IDNO = 7
#IDPROMPT = $FFFF
#StringSpace = 100

Global PickIconDlgHook

Procedure PickIconDlgHook(uMsg, wParam, lParam)
  Protected Handle
  Protected RECT.RECT
  
  Select uMsg
    Case #HCBT_ACTIVATE
      ;Fenster
      MoveWindow_(wParam, 100, 100, 800, 600, 1)
      ;TextGadget
      Handle = GetWindow_(wParam, #GW_CHILD)
      SetWindowPos_(Handle, 0, 0, 0, 770, 20, #SWP_SHOWWINDOW | #SWP_NOZORDER | #SWP_NOMOVE | #SWP_FRAMECHANGED)
      ;StringGadget
      Handle = GetWindow_(Handle, #GW_HWNDNEXT)
      SetWindowPos_(Handle, 0, 0, 0, 670, 20, #SWP_SHOWWINDOW | #SWP_NOZORDER | #SWP_NOMOVE | #SWP_FRAMECHANGED)
      ;ButtonGadget
      Handle = GetWindow_(Handle, #GW_HWNDNEXT)
      GetWindowRect_(Handle, RECT)
      SetWindowPos_(Handle, 0, 690, 28, 0, 0, #SWP_SHOWWINDOW | #SWP_NOZORDER | #SWP_NOSIZE | #SWP_FRAMECHANGED)
      ;TextGadget
      Handle = GetWindow_(Handle, #GW_HWNDNEXT)
      GetWindowRect_(Handle, RECT)
      SetWindowPos_(Handle, 0, 0, 0, 770, 20, #SWP_SHOWWINDOW | #SWP_NOZORDER | #SWP_NOMOVE | #SWP_FRAMECHANGED)
      ;ListViewGadget
      Handle = GetWindow_(Handle, #GW_HWNDNEXT)
      GetWindowRect_(Handle, RECT)
      SetWindowPos_(Handle, 0, 0, 0, 770, 440, #SWP_SHOWWINDOW | #SWP_NOZORDER | #SWP_NOMOVE | #SWP_FRAMECHANGED)
      ;ButtonGadget
      Handle = GetWindow_(Handle, #GW_HWNDNEXT)
      ;ButtonGadget
      Handle = GetWindow_(Handle, #GW_HWNDNEXT)
      GetWindowRect_(Handle, RECT)
      SetWindowPos_(Handle, 0, 620, 540, 0, 0, #SWP_SHOWWINDOW | #SWP_NOZORDER | #SWP_NOSIZE | #SWP_FRAMECHANGED)
      ;ButtonGadget
      Handle = GetWindow_(Handle, #GW_HWNDNEXT)
      GetWindowRect_(Handle, RECT)
      SetWindowPos_(Handle, 0, 705, 540, 0, 0, #SWP_SHOWWINDOW | #SWP_NOZORDER | #SWP_NOSIZE | #SWP_FRAMECHANGED)
      
      UnhookWindowsHookEx_(PickIconDlgHook)
  EndSelect
  
  ProcedureReturn #False
EndProcedure

If OpenLibrary(0, "Shell32.dll")
  Prototype.l PickIconDlg(hwnd, pszIconPath.p-unicode, cchIconPath, piIconIndex)
  Define PickIconDlg.PickIconDlg = GetFunction(0, "PickIconDlg")   
  
  PickIconDlgHook = SetWindowsHookEx_(#WH_CBT, @PickIconDlgHook(), GetModuleHandle_(0), GetCurrentThreadId_())
  
  DlgResult = PickIconDlg(hWnd, IcoLibPath$, Len(IcoLibPath$), @DefaultIconID)
  If DlgResult = 0
    MessageRequester("", "Kein Icon ausgewählt.", 0)
  Else
    MessageRequester("", "Icon wurde ausgewählt und kann nun z.B. mit ExtractIcon_() extrahiert werden. Icon-Nummer: " + Str(DefaultIconID), 0)
  EndIf
EndIf

Re: Icons aus DLL holen

Verfasst: 10.08.2017 00:48
von TheCube
@RSBasic: Hatte ja gehofft, das du bzgl. Minifenster einen Workaround präsentierst. :allright:

@ts-soft: Ich behalte es im Hinterkopf, wenn es nichts privates, sondern wieder mal ein
Test-/Hilfs-Tool für die Firma ist. Möchte halt nur von WinXP bis Win10 sicherstellen,
dass das gewählte Icon für'n Button o.ä. immer gleich ausschaut. Deshalb bevorzug(t)e
ich ein .ico-File in der Datasection statt dem Auslesen der z.B. shell32.dll 'on the fly'.