Disable ListIcon header hover/click

Windows specific forum
wombats
Enthusiast
Enthusiast
Posts: 717
Joined: Thu Dec 29, 2011 5:03 pm

Disable ListIcon header hover/click

Post 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
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4953
Joined: Sun Apr 12, 2009 6:27 am

Re: Disable ListIcon header hover/click

Post by RASHAD »

Hi

Code: Select all

  header = SendMessage_(GadgetID(0), #LVM_GETHEADER, 0, 0)
  EnableWindow_(Header,0)
Egypt my love
wombats
Enthusiast
Enthusiast
Posts: 717
Joined: Thu Dec 29, 2011 5:03 pm

Re: Disable ListIcon header hover/click

Post 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
BarryG
Addict
Addict
Posts: 4168
Joined: Thu Apr 18, 2019 8:17 am

Re: Disable ListIcon header hover/click

Post 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.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4953
Joined: Sun Apr 12, 2009 6:27 am

Re: Disable ListIcon header hover/click

Post 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 )
Egypt my love
wombats
Enthusiast
Enthusiast
Posts: 717
Joined: Thu Dec 29, 2011 5:03 pm

Re: Disable ListIcon header hover/click

Post 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!
Post Reply