Results 1 to 15 of 15

Thread: [VB6] Dynamic Resize: Use a slider to change ListView icon/thumbnail size on the fly

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,651

    Post [VB6] Dynamic Resize: Use a slider to change ListView icon/thumbnail size on the fly


    One of the features of the Vista and newer Explorer views is the icon size slider; you can do more than just pick between a couple sizes- you can set it to any value in the icon range. Previously to do this in VB was quite a lot of work; you'd have to manually resize each image and rebuild each ImageList since you can't scale up without quality loss... so it's not something that could be rapidly changed without any lag. This project, however, takes advantage of a feature of the new IImageList2 COM interface: it has a .Resize command that can scale down the entire ImageList at once with the speed of Windows API. To avoid quality loss, we load the maximum size images into a primary ImageList, then we dynamically generate the API-made duplicate in the smaller size that the user is looking for, always scaling down instead of up.

    Right now this project is focused on standard image file thumbnails; really small images that need to be grey-boxed and standard file icons will be addressed in a future version of this demo.

    Here's the key function:
    Code:
    Private Sub ResizeThumbView(cxNew As Long)
    ImageList_Destroy himl
    himl = ImageList_Duplicate(himlMax)
    HIMAGELIST_QueryInterface himl, IID_IImageList2, pIML
    If (pIML Is Nothing) = False Then
        pIML.Resize cxNew, cxNew
    End If
    himl = ObjPtr(pIML)
    bSetIML = True
    ListView_SetImageList hLVS, himl, LVSIL_NORMAL
    bSetIML = False
    ListView1.Refresh
    End Sub
    While it's certainly possible to forgo the standard HIMAGELIST and entirely use IImageList, I wanted to retain some (hopefully) more familiar territory by using that and the 5.0 VB ListView control. As the API HIMAGELIST_QueryInterface indicates, they're pretty much interchangable anyway, as the ObjPtr returns the same handle as when we made it with ImageList_Create.

    Requirements
    -Windows Vista or newer
    -Common Controls 6.0 Manifest - The demo project has a manifest built into its resource file. Your IDE may have to be manifested to run it from there. If you need to manifest your IDE or a new project, see LaVolpe's Manifest Creator
    -oleexp.tlb v4.0 or newer - Only needed in the IDE; not needed once compiled.
    -oleexp addon mIID.bas - Included in the oleexp download. Must be added to the demo project the first time you open it.

    Scrolling
    To make it truly like Explorer, where it sizes while you move the mouse, you can move the code in Slider1_Change over to Slider1_Scroll:
    Code:
    Private Sub Slider1_Change()
    'cxThumb = Slider1.Value
    'Label1.Caption = cxThumb & "x" & cxThumb
    'ResizeThumbView cxThumb
    End Sub
    
    Private Sub Slider1_Scroll()
    cxThumb = Slider1.Value
    Label1.Caption = cxThumb & "x" & cxThumb
    ResizeThumbView cxThumb
    End Sub
    It works perfectly with the small number of images currently there, but I'm hesitant to trust the stability if there's hundreds or thousands of list items, at least without it being a virtual ListView. I'll take a look at it for future versions; if anyone experiments with it before then let me know!
    Attached Files Attached Files
    Last edited by fafalone; Aug 16th, 2017 at 02:51 AM.

  2. #2

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,651

    Arrow Re: [VB6] Dynamic Resize: Use a slider to change ListView icon/thumbnail size on the

    High Performance Version
    API-Created ListView in Virtual Mode

    This version is set to resize while moving the mouse (as discussed above). To hopefully keep the performance good and stable, I've converted the ListView into an API-based one (made with CreateWindowEx) running in virtual mode (LVS_OWNERDATA). The idea is to only have to load/draw images for the items that are displayed, instead of redrawing the entire imagelist like the original version. There's also Unicode support, which isn't possible with the normal VB controls.

    This version is actually a good way to learn those approaches too, because unlike the other projects posted by me and others, this one is very simple, just a barebones thumbnail display.

    The requirements are identical to the original version.

    Use this version if you expect to have more than a few items at a time.
    Attached Files Attached Files
    Last edited by fafalone; Aug 16th, 2017 at 04:49 AM.

  3. #3
    Lively Member
    Join Date
    Mar 2015
    Posts
    104

    Re: [VB6] Dynamic Resize: Use a slider to change ListView icon/thumbnail size on the

    I want to try use this for a small 25 student school class attendance program, in which pictures of students are supplied (with the students names as names of the picture files). Looks nice. Hopefully its fairly stable. A great many thanks for the virtual mode update.

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,651

    Re: [VB6] Dynamic Resize: Use a slider to change ListView icon/thumbnail size on the

    That would be pretty cool. Let me know if any questions come up adding/customizing things, would be happy to help.

  5. #5
    New Member
    Join Date
    Sep 2020
    Posts
    4

    Re: [VB6] Dynamic Resize: Use a slider to change ListView icon/thumbnail size on the

    I cant get it to work, still says runtime error 453 cant find dll entry point HIMAGELIST_QueryInterface in comctl32.dll

    is anyone know how to fix this ?

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,651

    Re: [VB6] Dynamic Resize: Use a slider to change ListView icon/thumbnail size on the

    Two possibilities:

    First, your project, and the IDE if you're running from there, need to have a manifest for Common Controls 6.0. See this project for information on how to create one.

    Second, Windows XP would result in that error; it's not possible to run this type of project on XP because it doesn't include the IImageList interface.

  7. #7
    New Member
    Join Date
    Sep 2020
    Posts
    4

    Re: [VB6] Dynamic Resize: Use a slider to change ListView icon/thumbnail size on the

    Quote Originally Posted by fafalone View Post
    Two possibilities:

    First, your project, and the IDE if you're running from there, need to have a manifest for Common Controls 6.0. See this project for information on how to create one.

    Second, Windows XP would result in that error; it's not possible to run this type of project on XP because it doesn't include the IImageList interface.
    Created new manifest and imported to project resources still error, System WIndows 7
    Attachment 178684

    Last edited by Pax345; Sep 12th, 2020 at 02:45 AM.

  8. #8
    New Member
    Join Date
    Sep 2020
    Posts
    4

    Re: [VB6] Dynamic Resize: Use a slider to change ListView icon/thumbnail size on the

    I gave up, thank you for reply fafalone i didnt expected to get reply in this old thread.
    This app doesnt work. If anyone are looking for anything similar go for this :

    https://www.vbforums.com/showthread....d-small-images

    its another app from fafalone and it is working

  9. #9

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,651

    Re: [VB6] Dynamic Resize: Use a slider to change ListView icon/thumbnail size on the

    Does the demo work?

    (Also note that adding the resource file in the IDE means it will work when compiled, you need to insert a manifest into VB6.EXE if you want it to work running from the IDE)

  10. #10
    New Member
    Join Date
    Sep 2020
    Posts
    4

    Re: [VB6] Dynamic Resize: Use a slider to change ListView icon/thumbnail size on the

    Damn you are right it is working when compiled... but not working in IDE, how to insert manifest in vb6.exe???? i have tryed to run vb6 in compatibiliy mode with winxp sp2 and i have put manifest created in manifest creator into vb6.exe folder "VB6.EXE.manifest.res" but still it didnt solved the problem.

  11. #11

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,651

    Re: [VB6] Dynamic Resize: Use a slider to change ListView icon/thumbnail size on the

    Just VB6.EXE.manifest; where that file is just the manifest text, not a resource file.

    That may or may not work depending on your system settings.

    If it's not working, you have two options:

    1) Try changing the registry setting to prefer external manifests:

    Set the 'PreferExternalManifest' key to '1' in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide, and reboot.

    2) Some Windows builds will simply flat out refuse to use external manifests no matter what that key is set to. So if the above is still not working, or you would prefer to just go straight to the sure bet, you need to modify VB6.EXE.

    FIRST, make a back up copy of the original EXE. You never want to not have a backup.

    Now, get the ResHacker program here. It's free, no ads, nothing funky.

    1) Open VB6.EXE in it.

    2) Go to the Action menu, and select 'Add using script template'

    3) Select MANIFEST from the dropdown, and click Add Resource

    4) Replace the text with the manifest you want. I use the following to just add CC6.0 and not mess around with anything else (I'm also on Windows 7):
    Code:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
    <assemblyIdentity
       version="1.0.0.0"
       processorArchitecture="X86"
       name="Microsoft.VB6.VBnetStyles"
       type="win32"
    />
    <description>VBnet Manifest for VB6 IDE</description>
    <dependency>
       <dependentAssembly>
         <assemblyIdentity
           type="win32"
           name="Microsoft.Windows.Common-Controls"
           version="6.0.0.0"
           processorArchitecture="X86"
           publicKeyToken="6595b64144ccf1df"
           language="*"
         />
       </dependentAssembly>
    </dependency>
    </assembly>
    5) Go to Action, select Compile

    6) File -> Save
    --
    Manifesting the vb6 exe has a number of benefits, obviously this project will work, and you'll see the 6.0 common controls in the form designer.

    PS- You'll still want VB6.EXE to run in Compatibility Mode for Windows XP Service Pack 3.
    Last edited by fafalone; Sep 15th, 2020 at 08:56 PM.

  12. #12
    Lively Member
    Join Date
    Jan 2008
    Posts
    67

    Re: [VB6] Dynamic Resize: Use a slider to change ListView icon/thumbnail size on the

    Many complex, not exists mIID.bas in oleexp, may complex for test

  13. #13

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,651

    Re: [VB6] Dynamic Resize: Use a slider to change ListView icon/thumbnail size on the

    I apologize; I forgot to include it in the most recent release. I've now updated the attachment to include it, and for convenience I'm attaching the current version here as well.
    Last edited by fafalone; Jun 22nd, 2023 at 09:00 AM. Reason: Removed outdated attachment

  14. #14
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,746

    Re: [VB6] Dynamic Resize: Use a slider to change ListView icon/thumbnail size on the

    ERR:453, DLL entry point HIMAGELIST_QueryInterface in comctl32.dll not found
    VERSION IS 5.82
    now it's ok,need compile To EXE

    does it not need ocx?
    Object={6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.5#0; comctl32.Ocx
    Last edited by xiaoyao; Jun 22nd, 2023 at 04:05 AM.

  15. #15

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,651

    Re: [VB6] Dynamic Resize: Use a slider to change ListView icon/thumbnail size on the

    The version in post #2 does not need an ocx.

    You need a manifest for Common Controls 6.0. To modify the VB6 IDE to have one like the compiled exe, see post #11.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width