ListIconGadget and row height

Just starting out? Need help? Post your questions and find answers here.
jak64
Enthusiast
Enthusiast
Posts: 639
Joined: Sat Aug 15, 2020 5:02 pm
Location: Ciboure (France)

ListIconGadget and row height

Post by jak64 »

Hello everyone,
I wrote a program with a ListIconGadget.
I use this program with an ASUS tablet running Windows 10.

Here is my problem:
The elements displayed in the list are with the font that I have chosen, the height of each line therefore depends on the size of the font, which makes it difficult to select an element with your finger, unless you put a very large font, which I don't want.
Is there a way to set the height of the lines in a ListIconGadget, independently of the font size?

Thanks to you

ps: I am French and do not speak English, which is why I have difficulty searching through Posts to verify that someone has already asked a similar question.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4991
Joined: Sun Apr 12, 2009 6:27 am

Re: ListIconGadget and row height

Post by RASHAD »

Hi

Code: Select all

Global oldproc, header_h

Procedure Hheight(hwnd, msg, wParam, lParam)
  Select msg
    Case #HDM_LAYOUT       
      result = CallWindowProc_(oldproc, hwnd, msg, wParam, lParam)
      *hdlayout.HD_LAYOUT = lParam
      If *hdlayout\prc <> 0
        *rect.RECT = *hdlayout\prc
        *rect\top = header_h
      EndIf
      If *hdlayout\pwpos <> 0
        *windowpos.WINDOWPOS = *hdlayout\pwpos
        *windowpos\cy = header_h
      EndIf
      
    Default
      result = CallWindowProc_(oldproc, hWnd, Msg, wParam, lParam)
      
  EndSelect
  ProcedureReturn result
EndProcedure

LoadFont(0,"tahoma",8)

If OpenWindow(0, 0, 0, 600, 300, "ListIconGadgets", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ListIconGadget(0, 10,  10 , 580, 280, "Column 1", 120, #PB_ListIcon_GridLines| #PB_ListIcon_FullRowSelect)
  
  SetGadgetFont(0,FontID(0))
  
  For b = 2 To 4
    AddGadgetColumn(0, b, "Column " + Str(b), 120)
  Next
  For b = 0 To 2 
    AddGadgetItem(0, b, "Item 1"+Chr(10)+"Item 2"+Chr(10)+"Item 3"+Chr(10)+"Item 4")
  Next      
  
  header_h = 60 
  Header = SendMessage_(GadgetID(0), #LVM_GETHEADER, 0, 0)
  oldproc = SetWindowLong_(Header, #GWL_WNDPROC, @Hheight())
  SendMessage_(GadgetID(0), #LVM_SCROLL, 0, 0)
  
  row_h = 40
  hImg = ImageList_Create_(1, row_h, #ILC_COLORDDB, 0, 0)          ;Set Row Height
  SendMessage_(GadgetID(0), #LVM_SETIMAGELIST, #LVSIL_SMALL,hImg)
  ImageList_Destroy_(hImg)
  
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Egypt my love
jak64
Enthusiast
Enthusiast
Posts: 639
Joined: Sat Aug 15, 2020 5:02 pm
Location: Ciboure (France)

Re: ListIconGadget and row height

Post by jak64 »

Hello RASHAD,

Thanks, that’s great!
Good evening (it’s 8:36 p.m. here in France)
Post Reply