Page 1 of 1

ExplorerListGadget Hide both scrollbars.

Posted: Wed Jun 26, 2024 2:36 pm
by AndyMK
I have searched and tried a few things to disable both scrollbars of an ExplorerListGadget but i cant get anything to work. I think i need to get a handle to the actual listview control and then use something like

Code: Select all

ShowScrollBar_(#listviewControl, #SB_BOTH, #False)
but i can figure out how to do it.

Re: ExplorerListGadget Hide both scrollbars.

Posted: Wed Jun 26, 2024 3:20 pm
by AndyMK
I figured it out with the help of chatgpt. Don't know if this is the best way to do it but it works.

Code: Select all

Global OldListViewProc

Procedure ListViewProc(hWnd, uMsg, wParam, lParam)
  Select uMsg
    Case #WM_NCCALCSIZE
      ProcedureReturn 0
  EndSelect
  
  ProcedureReturn CallWindowProc_(OldListViewProc, hWnd, uMsg, wParam, lParam)
EndProcedure

If OpenWindow(0, 0, 0, 600, 400, "ExplorerListGadget No scrollbars", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  SetWindowColor(0, RGB(0, 0, 0))
  ExplorerListGadget(0, 0, 0, 600, 400, "C:\")
  SetGadgetColor(0, #PB_Gadget_BackColor, RGB(0, 0, 0))
  SetGadgetColor(0, #PB_Gadget_FrontColor, RGB(255, 255, 255))
  SetWindowLongPtr_(GadgetID(0), #GWL_STYLE, GetWindowLongPtr_(GadgetID(0), #GWL_STYLE)|#LVS_NOCOLUMNHEADER)
  listViewHandle = GadgetID(0)
  currentStyle = GetWindowLongPtr_(listViewHandle, #GWL_STYLE)
  newStyle = currentStyle & ~#WS_HSCROLL & ~#WS_VSCROLL
  SetWindowLongPtr_(listViewHandle, #GWL_STYLE, newStyle)
  OldListViewProc = SetWindowLongPtr_(listViewHandle, #GWL_WNDPROC, @ListViewProc())
  
  Repeat
    Event = WaitWindowEvent()
    
    Select Event
      Case #PB_Event_Gadget
        Select EventGadget()
          Case 0
            If EventType() = #PB_EventType_LeftDoubleClick
              Debug GetGadgetText(0) + GetGadgetItemText(0, GetGadgetState(0))
            EndIf
        EndSelect
        
      Case #PB_Event_CloseWindow
        Quit = 1
    EndSelect
  Until Quit = 1
EndIf
End

Re: ExplorerListGadget Hide both scrollbars.

Posted: Wed Jun 26, 2024 3:21 pm
by AndyMK
The only thing i need to figure out now is how to get scroll events

Re: ExplorerListGadget Hide both scrollbars.

Posted: Wed Jun 26, 2024 3:55 pm
by RASHAD
Hi RASHAD GPT :mrgreen:
You can get the scroll events using mouse wheel and keyboard
# 1:

Code: Select all

If OpenWindow(0, 0, 0, 600, 400, "ExplorerListGadget No scrollbars", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ContainerGadget(10,10,10,580,380)
    ExplorerListGadget(0, 0, 0, 600, 400, "C:\")
  CloseGadgetList()
  SetGadgetColor(0, #PB_Gadget_BackColor, RGB(0, 0, 0))
  SetGadgetColor(0, #PB_Gadget_FrontColor, RGB(255, 255, 255))
  SetWindowLongPtr_(GadgetID(0), #GWL_STYLE, GetWindowLongPtr_(GadgetID(0), #GWL_STYLE)|#LVS_NOCOLUMNHEADER)
  
  Repeat
    Select WaitWindowEvent(1)       
      Case #PB_Event_CloseWindow
        Quit = 1
    EndSelect
  Until Quit = 1
EndIf
End

# 2:

Code: Select all

If OpenWindow(0, 0, 0, 600, 400, "ExplorerListGadget No scrollbars", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ExplorerListGadget(0, 10, 10, 620, 400, "C:\")
  SetGadgetColor(0, #PB_Gadget_BackColor, RGB(0, 0, 0))
  SetGadgetColor(0, #PB_Gadget_FrontColor, RGB(255, 255, 255))
  SetWindowLongPtr_(GadgetID(0), #GWL_STYLE, GetWindowLongPtr_(GadgetID(0), #GWL_STYLE)|#LVS_NOCOLUMNHEADER)
  GetClientRect_(GadgetID(0),r.RECT)
  hrgn = CreateRectRgn_(r\left+1, r\top+4, r\right-20, r\bottom-20)
  SetWindowRgn_(GadgetID(0), hrgn, #True)
  
  Repeat
    Select WaitWindowEvent(1)       
      Case #PB_Event_CloseWindow
        Quit = 1
    EndSelect
  Until Quit = 1
EndIf
End

Re: ExplorerListGadget Hide both scrollbars.

Posted: Wed Jun 26, 2024 4:12 pm
by AndyMK
Hi RASHAD "GPT" :shock:

Nice examples and much more manageable than what i posted. Any chance you know how i can intercept the scrolling so i can add a custom scrollbar?
I tried #WM_VSCROLL in the callback but it does not get fired so i assume the gadget is doing something else internally

Re: ExplorerListGadget Hide both scrollbars.

Posted: Wed Jun 26, 2024 4:22 pm
by RASHAD
Hi AndyMK
I am going to sleep right now
Be tuned
Unless any one of PB Gorillas :) did the job before me

Re: ExplorerListGadget Hide both scrollbars.

Posted: Wed Jun 26, 2024 4:26 pm
by AndyMK
:D waiting

Re: ExplorerListGadget Hide both scrollbars.

Posted: Wed Jun 26, 2024 6:03 pm
by RASHAD
Scroll to any line vertically by command

Code: Select all

If OpenWindow(0, 0, 0, 600, 400, "ExplorerListGadget No scrollbars", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ContainerGadget(10,10,10,580,380)
    ExplorerListGadget(0, 0, 0, 600, 400, "C:\")
  CloseGadgetList()
  SetGadgetColor(0, #PB_Gadget_BackColor, RGB(0, 0, 0))
  SetGadgetColor(0, #PB_Gadget_FrontColor, RGB(255, 255, 255))
  SetWindowLongPtr_(GadgetID(0), #GWL_STYLE, GetWindowLongPtr_(GadgetID(0), #GWL_STYLE)|#LVS_NOCOLUMNHEADER)
  p.POINT
  SendMessage_(GadgetID(0), #LVM_GETITEMPOSITION, 4, p)
  SendMessage_(GadgetID(0), #LVM_SCROLL, 0, p\y)
  
  Repeat
    Select WaitWindowEvent(1)               
      Case #PB_Event_CloseWindow
        Quit = 1
    EndSelect
  Until Quit = 1
EndIf
End
Get The scroller information using Mouse Wheel

Code: Select all

#OBJID_HSCROLL= $FFFFFFFA
#OBJID_VSCROLL= $FFFFFFFB
#OBJID_CLIENT = $FFFFFFFC

Structure SCROLLBARINFO Align #PB_Structure_AlignC
  cbSize.l
  rcScrollBar.RECT
  dxyLineButton.l
  xyThumbTop.l
  xyThumbBottom.l
  reserved.l
  rgstate.l[6]
EndStructure

If OpenWindow(0, 0, 0, 600, 400, "ExplorerListGadget No scrollbars", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ContainerGadget(10,10,10,580,380)
    ExplorerListGadget(0, 0, 0, 600, 400, "C:\")
  CloseGadgetList()
  SetGadgetColor(0, #PB_Gadget_BackColor, RGB(0, 0, 0))
  SetGadgetColor(0, #PB_Gadget_FrontColor, RGB(255, 255, 255))
  SetWindowLongPtr_(GadgetID(0), #GWL_STYLE, GetWindowLongPtr_(GadgetID(0), #GWL_STYLE)|#LVS_NOCOLUMNHEADER)
  sc.SCROLLBARINFO
  sc\cbSize=SizeOf(sc)
  GetScrollBarInfo_(GadgetID(0),#OBJID_VSCROLL,@sc)
  lineh = sc\dxyLineButton - 1
  Repeat
    Select WaitWindowEvent(1)
      Case #WM_MOUSEWHEEL
        GetScrollBarInfo_(GadgetID(0),#OBJID_VSCROLL,@sc)
        Debug Sc\xyThumbTop / lineh
               
      Case #PB_Event_CloseWindow
        Quit = 1
    EndSelect
  Until Quit = 1
EndIf
End

Re: ExplorerListGadget Hide both scrollbars.

Posted: Wed Jun 26, 2024 6:18 pm
by AndyMK
Wow. Amazing what 1 hour and 30 minutes of sleep can do :shock:
Thanks for you help

Re: ExplorerListGadget Hide both scrollbars.

Posted: Wed Jun 26, 2024 6:21 pm
by RASHAD
I didn't sleep yet
You know family affairs :D

Re: ExplorerListGadget Hide both scrollbars.

Posted: Wed Jun 26, 2024 6:29 pm
by AndyMK
Say no more :P
"Family affairs" is good