Veröffentlicht 26. September 200321 j Hi, weiß hier jemand wie man einem Toolbar Button ein Icon zuweisen kann, ohne dass das Icon in einer ImageList ist, also so das ich z.b. den Namen einer Datei nehme und er das Icon dieser Datei nimmt...? Danke im voraus
26. September 200321 j ... oder ich formuliere mein frage mal etwas um... wie kann ich das Icon aus einer Compilierten EXE datei 'herausholen'... also das machen was man unter den Eigenschaften eines Shortcuts als Change Icon findet?
1. Oktober 200321 j Original geschrieben von LoneGunman Also möchtest Du einem ToolBarButton ein Icon aus einer EXE-Datei zuweisen? richtitsch...
2. Oktober 200321 j Nachtrag: Wenn Du Icons während der Entwicklungszeit in Deine ToolBar hinzufügen möchtest, dann kannst Du die Icons mit Resource Hacker (zu finden als Freeware auf der aktuellen ct) aus den EXE- und DLL-Dateien extrahieren.
8. Oktober 200321 j und per VB kann man das nicht irgendwie machen :confused: mh naja gut ok - Danke für deine Hilfe
4. November 200321 j sollte es jemanden interessieren: Private Declare Function SHGetFileInfo Lib "shell32.dll" Alias _ "SHGetFileInfoA" (ByVal pszPath As Any, ByVal _ dwFileAttributes As Long, psfi As ShellFileInfoType, ByVal _ cbFileInfo As Long, ByVal uFlags As Long) As Long Private Type ShellFileInfoType hIcon As Long iIcon As Long dwAttributes As Long szDisplayName As String * 260 szTypeName As String * 80 End Type Private Declare Function OleCreatePictureIndirect Lib "oleaut32.dll" (pDicDesc As IconType, riid As CLSIdType, ByVal fown As Long, lpUnk As Object) As Long Private Type CLSIdType id(16) As Byte End Type Private Type IconType cbSize As Long picType As PictureTypeConstants hIcon As Long End Type Private Const Small = &H101 Dim i As Integer Private Sub Command1_Click() cd.ShowOpen BuildButton cd.FileName, "test", "i" & i i = i + 1 End Sub Public Function BuildButton(strImageKey As String, strTooltipText As String, intNr As String) 'sollen Buttons in de Toolbar während der Laufzeit erstellt werden, so brauch man diese funktion Dim imgX As ListImage Dim btnX As Button If strImageKey = "tbrSeparator" Then Set btnX = Toolbar1.Buttons.Add(, , , tbrSeparator) Else ImageList2.ListImages.Add , intNr, LoadIcon(Small, cd.FileName) Toolbar1.ImageList = ImageList2 Set btnX = Toolbar1.Buttons.Add(, intNr, , tbrDefault, intNr) btnX.ToolTipText = strTooltipText btnX.Description = btnX.ToolTipText End If End Function Private Function LoadIcon(Size&, File$) As IPictureDisp Dim Result& Dim Unkown As IUnknown Dim Icon As IconType Dim CLSID As CLSIdType Dim ShellInfo As ShellFileInfoType Call SHGetFileInfo(File, 0, ShellInfo, Len(ShellInfo), Size) Icon.cbSize = Len(Icon) Icon.picType = vbPicTypeIcon Icon.hIcon = ShellInfo.hIcon CLSID.id(8) = &HC0 CLSID.id(15) = &H46 Result = OleCreatePictureIndirect(Icon, CLSID, 1, Unkown) Set LoadIcon = Unkown End Function Private Sub Form_Load() i = 1 End Sub [/PHP] ... benötigt wird: Button(Command1), ImageList (ImageList2), Toolbar (Toolbar1), Commondialog (cd)
Archiv
Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.