ListIconGadget Fixed Column Width?

Just starting out? Need help? Post your questions and find answers here.
novablue
Enthusiast
Enthusiast
Posts: 165
Joined: Sun Nov 27, 2016 6:38 am

ListIconGadget Fixed Column Width?

Post by novablue »

Hi, i use this code to prevent the column widths from being changed by the user. The only problem is clicking on the column texts will select the first item in the list. How can i avoid this?

Code: Select all

If OpenWindow(0,0,0,500,250,"Window",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
  ListIconGadget(1,10,10,480,230,"Test Test Test Test 1234567890",200, #PB_ListIcon_FullRowSelect)
  AddGadgetItem(1, -1, "1")
  AddGadgetItem(1, -1, "2")
  AddGadgetItem(1, -1, "3")
  
  EnableWindow_(SendMessage_(GadgetID(1),#LVM_GETHEADER,#Null,#Null),0) 
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4659
Joined: Sun Apr 12, 2009 6:27 am

Re: ListIconGadget Fixed Column Width?

Post by RASHAD »

Hi
You can fix all columns or any special columns you like

Code: Select all

Procedure WinCB(hWnd, uMsg, wParam, lParam)
result = #PB_ProcessPureBasicEvents 
  Select uMsg
   Case #WM_NOTIFY
    *NMHDR.NMHDR = lParam
       If *NMHDR\hWndFrom = GetWindow_(GadgetID(0),#GW_CHILD) And *NMHDR\code = #HDN_ITEMCHANGING
          *phdn.NMHEADER = lParam
          ;If  *phdn\iItem = 1 Or *phdn\iItem = 3         
            ProcedureReturn 1
          ;EndIf
       EndIf
  EndSelect
  ProcedureReturn result
EndProcedure 
 
If OpenWindow(0, 0, 0, 600, 600, "Messages", #PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_ScreenCentered)
   ListIconGadget(0, 5, 5, 580, 580, "Name", 150, #PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection)
   AddGadgetColumn(0, 1, "Address", 150)
     AddGadgetItem(0, -1, "Harry Rannit"+Chr(10)+"12 Parliament Way, Battle Street, By the Bay")
     AddGadgetItem(0, -1, "Ginger Brokeit"+Chr(10)+"130 PureBasic Road, BigTown, CodeCity")
     AddGadgetItem(0, -1, "Harry Rannit"+Chr(10)+"12 Parliament Way, Battle Street, By the Bay")
     AddGadgetItem(0, -1, "Ginger Brokeit"+Chr(10)+"130 PureBasic Road, BigTown, CodeCity")
   AddGadgetColumn(0, 2, "Address", 100)
   AddGadgetColumn(0, 3, "Address 2", 100)
  SetWindowCallback(@WinCB())
  Repeat
    Select WaitWindowEvent()
    
      Case #PB_Event_CloseWindow
        End
    EndSelect
  ForEver
EndIf 
Egypt my love
novablue
Enthusiast
Enthusiast
Posts: 165
Joined: Sun Nov 27, 2016 6:38 am

Re: ListIconGadget Fixed Column Width?

Post by novablue »

Thanks works good.
Post Reply