PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Listview, Imagelists and DPI Scaling  (Read 1619 times)

Richard Kelly

  • Senior Member
  • ***
  • Posts: 332
Listview, Imagelists and DPI Scaling
« on: December 09, 2012, 07:41:57 AM »

I have a listview that I've attached an imagelist to and when I load the listview I have logic that puts the image on a row if one is needed.

What technique is recommended so that my images scale to the current DPI setting?

This is what I'm currently doing, although the icon color as it's being shown on the listview is not correct and I've still to figure that one out.

Code: [Select]
        gImageList = ImageList_Create (32, 32, %ILC_MASK Or %ILC_COLOR32, 1, 0)
        ImageList_SetBkColor gImageList, %CLR_NONE
        hImage = LoadImage(app.hInstance,"IMAGE_LOCK", %IMAGE_ICON, 32, 32, 0)
        ImageList_ReplaceIcon gImageList, -1, hImage
        DeleteObject hImage

I have, for now, temporarily patched things up by having a 16, 24 and 32x32 size of listview image and used the following kludge:

Code: [Select]
        pWindow = Class "CWindow"

        If IsObject(pWindow) Then
       
            Select Case pWindow.DPI
           
                Case < 120
           
                    gImageList = ImageList_Create (16, 16, %ILC_MASK Or %ILC_COLOR32, 1, 0)
                    ImageList_SetBkColor gImageList, %CLR_NONE
                    hImage = LoadImage(app.hInstance,"IMAGE_LOCK16", %IMAGE_BITMAP, 16, 16, %LR_DEFAULTCOLOR)
                    ImageList_Add gImageList, hImage, 0
                   
                Case <  144
           
                    gImageList = ImageList_Create (24, 24, %ILC_MASK Or %ILC_COLOR32, 1, 0)
                    ImageList_SetBkColor gImageList, %CLR_NONE
                    hImage = LoadImage(app.hInstance,"IMAGE_LOCK24", %IMAGE_BITMAP, 24, 24, %LR_DEFAULTCOLOR)
                    ImageList_Add gImageList, hImage, 0
                   
                Case Else
               
                    gImageList = ImageList_Create (32, 32, %ILC_MASK Or %ILC_COLOR32, 1, 0)
                    ImageList_SetBkColor gImageList, %CLR_NONE
                    hImage = LoadImage(app.hInstance,"IMAGE_LOCK32", %IMAGE_BITMAP, 32, 32, %LR_DEFAULTCOLOR)
                    ImageList_Add gImageList, hImage, 0
           
            End Select
           
            pWindow = Nothing
            DeleteObject hImage
           
        End If

Rick Kelly
« Last Edit: December 09, 2012, 11:45:06 PM by Richard Kelly »
Logged