Page 1 of 1

Disable ListIcon header hover/click

Posted: Sun Mar 09, 2025 6:23 am
by wombats
I want to disable the hover effect and clicking on a ListIconGadget header. Putting #LVS_NOSORTHEADER in the flags when creating a ListIconGadget works, but I can't get it to with SetWindowLong. I want to use it on a ListIconGadget on a dialog and putting it in the XML doesn't seem to work. Does anyone know how to make this work?

Code: Select all

If OpenWindow(0, 100, 100, 300, 100, "Window 1", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ListIconGadget(0, 5, 5, 290, 90, "Name", 100, #PB_ListIcon_FullRowSelect)
  AddGadgetColumn(0, 1, "Address", 250)
  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")
  s = GetWindowLong_(GadgetID(0), #GWL_STYLE)
  s = s | #LVS_NOSORTHEADER
  SetWindowLong_(GadgetID(0), #GWL_STYLE, s)
EndIf

If OpenWindow(1, WindowX(0), WindowY(0) + WindowHeight(0) + 50, 300, 100, "Window 2", #PB_Window_SystemMenu)
  LFlags = #PB_ListIcon_FullRowSelect | #LVS_NOSORTHEADER
  ListIconGadget(1, 5, 5, 290, 90, "Name", 100, LFlags)
  AddGadgetColumn(1, 1, "Address", 250)
  AddGadgetItem(1, -1, "Harry Rannit"+Chr(10)+"12 Parliament Way, Battle Street, By the Bay")
  AddGadgetItem(1, -1, "Ginger Brokeit"+Chr(10)+"130 PureBasic Road, BigTown, CodeCity")
EndIf

Repeat
  Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow

Re: Disable ListIcon header hover/click

Posted: Sun Mar 09, 2025 7:39 am
by RASHAD
Hi

Code: Select all

  header = SendMessage_(GadgetID(0), #LVM_GETHEADER, 0, 0)
  EnableWindow_(Header,0)

Re: Disable ListIcon header hover/click

Posted: Sun Mar 09, 2025 9:34 am
by wombats
Thanks. That disables resizing the columns, unfortunately. It did put me on the right path, though. :)

I got it working like this:

Code: Select all

If OpenWindow(0, 100, 100, 300, 100, "Window 1", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ListIconGadget(0, 5, 5, 290, 90, "Name", 100, #PB_ListIcon_FullRowSelect)
  AddGadgetColumn(0, 1, "Address", 250)
  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")
  Define s
  header = SendMessage_(GadgetID(0), #LVM_GETHEADER, 0, 0)
  s = GetWindowLong_(header, #GWL_STYLE)
  s = s ! #HDS_BUTTONS
  SetWindowLong_(header, #GWL_STYLE, s)
EndIf

Re: Disable ListIcon header hover/click

Posted: Sun Mar 09, 2025 10:39 am
by BarryG
Note: You also need to use GetWindowLongPtr_() and SetWindowLongPtr_() now, instead of GetWindowLong_() and SetWindowLong_(). This is needed from when PureBasic went 64-bit.

Re: Disable ListIcon header hover/click

Posted: Sun Mar 09, 2025 3:56 pm
by RASHAD
Hi wombats
Good catch and good solution :)

Code: Select all

header = SendMessage_(GadgetID(0), #LVM_GETHEADER, 0, 0)
SetWindowLongPtr_(header, #GWL_STYLE,GetWindowLongPtr_(header, #GWL_STYLE) &~#HDS_BUTTONS )

Re: Disable ListIcon header hover/click

Posted: Sun Mar 09, 2025 4:59 pm
by wombats
BarryG wrote: Sun Mar 09, 2025 10:39 am Note: You also need to use GetWindowLongPtr_() and SetWindowLongPtr_() now, instead of GetWindowLong_() and SetWindowLong_(). This is needed from when PureBasic went 64-bit.
Thanks! I didn't know that.
RASHAD wrote: Sun Mar 09, 2025 3:56 pm Hi wombats
Good catch and good solution :)

Code: Select all

header = SendMessage_(GadgetID(0), #LVM_GETHEADER, 0, 0)
SetWindowLongPtr_(header, #GWL_STYLE,GetWindowLongPtr_(header, #GWL_STYLE) &~#HDS_BUTTONS )
Thanks!