Hallo,
Ich versuche die mit der "SysListView32" assoziierte ImageList zu überreden das sie mir
sagt wieviel Bilder sie gespeichert hat!
Ich mach das so:
Option Explicit
Private Const ShellDLL As String = "SHELLDLL_DefView"
Private Const SysListView As String = "SysListView32"
Private Const Program_Manager As String = "Progman"
Private Const LVM_GETIMAGELIST As Long = &H1002
Public Enum iImageListValues
LVSIL_NORMAL
LVSIL_SMALL
LVSIL_STATE
End Enum
Private Declare Function FindWindow _
Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx _
Lib "user32" Alias "FindWindowExA" _
(ByVal hWndParent As Long, _
ByVal hWndChildAfter As Long, _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function SendMessage _
Lib "user32" Alias "SendMessageA" _
(ByVal hWnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long
Private Declare Function LoadLibrary _
Lib "kernel" Alias "LoadLibraryA" _
(ByVal LibraryFilename As String) As Long
Private Declare Function ImageList_GetImageCount _
Lib "comctl32.dll" (ByVal hIml As Long) As Long
Public Function GetLVDesktopHandle() As Long
Dim hWnd As Long
'Classmame is Progman, lpWindowName is NULL therefore every window fits
hWnd = FindWindow(ByVal Program_Manager, vbNullString)
'hWndChildAfter identifies a subwindow the next window given by z-order
If CBool(hWnd) Then hWnd = FindWindowEx(hWnd, 0, ShellDLL, vbNullString)
If CBool(hWnd) Then hWnd = FindWindowEx(hWnd, 0, SysListView, vbNullString)
GetLVDesktopHandle = hWnd
End Function
Public Function GetLVILHandle(ByVal hWnd As Long, ByVal ImageListConstants As _
Long) As Long
GetLVILHandle = SendMessage(hWnd, LVM_GETIMAGELIST, ImageListConstants, ByVal _
0&)
End Function
Public Function CountILImages(ByVal hIml As Long) As Long
CountILImages = ImageList_GetImageCount(ByVal hIml)
End Function
hWnd = GetLVDesktopHandle()
hIml = GetLVILHandle(hWnd, IL_NORMAL)
ImgCnt = CountILImages(hIml)
MsgBox "Handle (LV): " & hWnd & vbCrLf & _
"Handle (IL): " & hIml & vbCrLf & _
"Images : " & ImgCnt Mein Problem ist das ich die Label der Icon auf dem Desktop sehe, die Farben
der Label auch (nicht in diesem gepostenten Code enthalten), aber die Icon sehe ich nicht!!!! Da ImageList_....Funktionen immer 0 zurückgeben sobald ich sie aufrufe!
vorher
himl = SendMessage(hWnd, LVM_GETIMAGELIST, LVSIL_NORMAL, 0&) liefert aber hIml<> 0 (Meiner Meinung also gültig!
z.B.: das altbekannte hIco = ImageList_GetIcon(ByVal himl, ByVal udt.iImage, 0&) liefert immer hIco=0?!
Fehler oder Bug in der comctl32Dll?
Gruss
Franky
Ich weiss nich viel, aber dass weiss ich! |