BUG: incorrect return value of imagelist_getimagecount in Windows XP (VB)

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.