ListIcon questions

Windows specific forum
Everything
Enthusiast
Enthusiast
Posts: 225
Joined: Sat Jul 07, 2018 6:50 pm

ListIcon questions

Post by Everything »

  1. Solved Icons doesn't show
  2. Solved How to display (not display) an icon for an item by condition?
  3. Is there a simple implementation so that when there is no icon there is no indentation (emptiness in place of the icon)?
  4. How to correctly display icons with high dpi? (if we load a 16x16 image, it will most likely get blurry on hight dpi)
    ILC_HIGHQUALITYSCALE ? Or maybe it will be done automatically?

Code: Select all

itemcount.i = 100
Global Dim myItems.s(0)
#LVSICF_NOINVALIDATEALL = 1
#LVN_ODCACHEHINT = #LVN_FIRST - 13

Procedure WinCallback(hwnd, msg, wParam, lParam)
  result = #PB_ProcessPureBasicEvents
  Static field.s
  Select msg
    Case #WM_NOTIFY
      *pnmh.NMHDR = lParam
      Select *pnmh\code
        Case #LVN_ODCACHEHINT
          result = 0
        Case #LVN_GETDISPINFO
          *pnmlvdi.NMLVDISPINFO = lParam
          If *pnmlvdi\item\mask & #LVIF_TEXT
            If *pnmlvdi\item\iItem & 1  
                If Not *pnmlvdi\item\mask & #LVIF_IMAGE :  *pnmlvdi\item\mask | #LVIF_IMAGE : EndIf
                *pnmlvdi\item\iImage = 0
            EndIf    
            line.s = myItems(*pnmlvdi\item\iItem)
            
            *pnmlvdi\item\pszText = @line
            
            ;
          EndIf         
      EndSelect
  EndSelect
  ProcedureReturn result
EndProcedure

If OpenWindow(0, 0, 0, 800, 500, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  SetWindowCallback(@WinCallback())
  ListIconGadget(0, 1, 1, 799, 499, "", 780,#LVS_OWNERDATA|#LVS_NOCOLUMNHEADER|#LVS_SHAREIMAGELISTS) 
  SendMessage_(GadgetID(0), #LVM_SETITEMCOUNT, 0, #LVSICF_NOINVALIDATEALL)
  
  himlSmall = ImageList_Create_(16, 16, #ILC_COLOR|#ILC_COLOR32, 0, 2)
  hIcon     = LoadIcon_(#Null, #IDI_INFORMATION)
  ImageList_AddIcon_(himlSmall, hIcon)
  SendMessage_(GadgetID(0), #LVM_SETIMAGELIST, #LVSIL_SMALL, himlSmall)
 
  SendMessage_(GadgetID(0), #LVM_SETITEMCOUNT, ItemCount, #LVSICF_NOINVALIDATEALL)  
  
  For pos = 0 To itemcount
    ReDim myItems(pos)
    myItems(pos) = "Item "+Str(pos)
  Next
 
  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow
EndIf