Page 2 of 2

Posted: Fri Dec 21, 2007 10:14 am
by Fluid Byte
PB wrote:That's the point: to stop the user changing the headers.
Nope, the point is size changes.
Rook Zimbabwe wrote:Is there any way to just LOCK the column widths?
Thus header dragging and sorting should still be supported. If dragging, sorting and sizing is disbaled the headercontrol is useless. Either use #LVS_NOCOLUMNHEADER or if you only need it for display purposes simply disable it or use #LVS_NOSORTHEADER.

Posted: Sat Dec 22, 2007 11:35 am
by akj
Not nearly so interesting, but you could simply do this:

Code: Select all

; Based on netmaestro's code
OpenWindow(0,0,0,320,240,"void",#PB_Window_SystemMenu | #PB_Window_ScreenCentered) 
CreateGadgetList(WindowID(0)) 
ListIconGadget(0,0,0,320,240,"Name",160) 
AddGadgetColumn(0,1,"Type",80) 
AddGadgetColumn(0,1,"Size",60) 
header = SendMessage_(GadgetID(0),#LVM_GETHEADER,0,0) 
EnableWindow_(header, #False) ; Disable the header
Repeat 
  ev = WaitWindowEvent(1) 
Until ev = #WM_CLOSE 
End

Posted: Sat Dec 22, 2007 11:47 am
by hallodri
yes, remove all ui-functions from a header ... :?

Posted: Sat Dec 22, 2007 9:15 pm
by Fluid Byte
akj wrote:; Based on netmaestro's code
Sweet! Image

Hey, the first 5 lines are mine! Where the heck's my credit? Image

Re:

Posted: Tue Dec 27, 2022 6:52 am
by BarryG
Hi all, I'm using Fluid Byte's code to try to lock only column 3 from being shown (either by resizing or double-clicking it to show it). The following code fails, though. What am I missing? Thanks.

Code: Select all

Procedure WindowCallback(hWnd,uMsg,wParam,lParam)
  result=#PB_ProcessPureBasicEvents
  Select uMsg
    Case #WM_NOTIFY
      *lpnm.NMHDR = lParam
      If *lpnm\hwndFrom = GetWindow_(GadgetID(0),#GW_CHILD) And *lpnm\code = #HDN_BEGINTRACK And *lpnm\idFrom = 3
        ProcedureReturn 1
      EndIf
  EndSelect
  ProcedureReturn result
EndProcedure

OpenWindow(0,0,0,320,240,"ListIcon",#PB_Window_SystemMenu | #PB_Window_ScreenCentered)

ListIconGadget(0,0,0,320,240,"Name",80)
AddGadgetColumn(0,1,"Type",80)
AddGadgetColumn(0,2,"Size",80)
AddGadgetColumn(0,3,"Hidden",0) ; Never want this column to be seen.

SetWindowCallback(@WindowCallback())

While WaitWindowEvent() ! #PB_Event_CloseWindow : Wend

Re: Lock Column width in #ListIconGadget

Posted: Tue Dec 27, 2022 7:13 am
by JHPJHP
Hi BarryG,

See Windows Services & Other Stuff\Other_Stuff\GadgetStuff\ListIconGadget\HiddenColumn.pb

Re: Lock Column width in #ListIconGadget

Posted: Tue Dec 27, 2022 8:16 am
by BarryG
Far out! That works great. Much appreciated. One tiny issue when #PB_ListIcon_GridLines are used, though: the gridlines are thicker than normal under the ListIcon header. (I forgot to mention I had gridlines). See code and image below. It seems a column of 0 width can't be fixed?

Maybe this code can do it? -> https://www.vbforums.com/showthread.php ... rom-sizing

Code: Select all

#LVCFMT_FIXED_WIDTH = $100

OpenWindow(0,0,0,320,240,"ListIcon",#PB_Window_SystemMenu | #PB_Window_ScreenCentered)

ListIconGadget(0,0,0,320,240,"Name",80,#PB_ListIcon_GridLines)
AddGadgetColumn(0,1,"Type",80)
AddGadgetColumn(0,2,"Size",80)
AddGadgetColumn(0,3,"Hidden",1) ; Never want this column to be seen.

For i=1 To 5
  AddGadgetItem(0,-1,"Name"+#LF$+"Type"+#LF$+"Size"+#LF$+"Hidden")
Next

lv.LV_COLUMN : lv\mask = #LVCF_FMT : lv\fmt = #LVCFMT_FIXED_WIDTH
SendMessage_(GadgetID(0), #LVM_SETCOLUMN, 3, @lv)

While WaitWindowEvent() ! #PB_Event_CloseWindow : Wend
Image

Re: Lock Column width in #ListIconGadget

Posted: Tue Dec 27, 2022 12:36 pm
by Lord
Try

Code: Select all

AddGadgetColumn(0,3,"Hidden",-1) ; Never want this column to be seen.
This almost solved this.
Except for column header.

Re: Lock Column width in #ListIconGadget

Posted: Tue Dec 27, 2022 2:09 pm
by breeze4me
Processing in #HDN_BEGINTRACK notification does not prevent a double click on a divider.
Double-click is possible by positioning the mouse cursor exactly on the 4th divider, and it expands the hidden column.
Therefore, it is better to process #HDN_ITEMCHANGING notification.

Image

Code: Select all

Procedure WindowCallback(hWnd,uMsg,wParam,lParam)
  result=#PB_ProcessPureBasicEvents
  Select uMsg
    Case #WM_NOTIFY
      *lpnm.NMHEADER = lParam
      If *lpnm\hdr\hwndFrom = GetWindow_(GadgetID(0),#GW_CHILD) And *lpnm\hdr\code = #HDN_BEGINTRACK And *lpnm\iItem = 3
        Debug "Start the divider drag."
      EndIf
      
      If *lpnm\hdr\hwndFrom = GetWindow_(GadgetID(0),#GW_CHILD) And *lpnm\hdr\code = #HDN_DIVIDERDBLCLICK And *lpnm\iItem = 3
        Debug "The divider double-clicked."
      EndIf
      
      If *lpnm\hdr\hwndFrom = GetWindow_(GadgetID(0),#GW_CHILD) And *lpnm\hdr\code = #HDN_ITEMCHANGING And *lpnm\iItem = 3
        ProcedureReturn 1
      EndIf
      
  EndSelect
  ProcedureReturn result
EndProcedure

OpenWindow(0,0,0,320,240,"ListIcon",#PB_Window_SystemMenu | #PB_Window_ScreenCentered)

ListIconGadget(0,0,0,320,240,"Name",80,#PB_ListIcon_GridLines)
AddGadgetColumn(0,1,"Type",80)
AddGadgetColumn(0,2,"Size",80)
AddGadgetColumn(0,3,"Hidden",0) ; Never want this column to be seen.
For i=1 To 5
  AddGadgetItem(0,-1,"Name"+#LF$+"Type"+#LF$+"Size"+#LF$+"Hidden")
Next

SetWindowCallback(@WindowCallback())

While WaitWindowEvent() ! #PB_Event_CloseWindow : Wend

Re: Lock Column width in #ListIconGadget

Posted: Tue Dec 27, 2022 6:57 pm
by JHPJHP
Hi BarryG,

breeze4me might have a solution that fits your needs, but if not, and the hidden column is just to store information and the position of the column doesn't matter, make it the first column.

NOTE: On Windows 11 all the gridlines look the same, or I'm just old :)

Re: Lock Column width in #ListIconGadget

Posted: Wed Dec 28, 2022 2:10 am
by BarryG
Breeze4me's code works great for gridlines. Thanks to both of you!