Environment: XP SP2 and VB6 (no SP6 patch is installed)
Test:
Create a project, add an imagelist control to the form (add several icons to the control in advance), add a button to the form, and add the followingCode:
Private declare function imagelist_getimagecount lib "comctl32 "(_
Byval himl as long) as long
Private sub commandementclick ()
Dim J as long
J = imagelist_getimagecount (imagelist1.himagelist)
Debug. Print J
End sub
No matter how many icons exist in imagelist1, it is found that the return value of imagelist_getimagecount is always 0.
Solution:
The imagecount value of imagelist is stored at the. himagelist offset of 4 bytes. Use copymemory to retrieve it:
Private declare sub copymemory lib "Kernel32" alias "rtlmovememory" (destination as any, source as any, byval length as long)
Private sub commandementclick ()
Dim J as long
Copymemory I, byval me. imagelist1.himagelist + 4, 4
Debug. Print J
End sub