Hi everyone,
does anyone know how to capture the event listicongadget scroll?
I have a listicon gadget on a panel and I need some way to capture when somebody clicks the scrollbar.
Thanks.
John Finney
listicongadget scroll capture
Here's a Win only method using API (full version of PB required).
Code: Select all
#WM_MOUSEWHEEL = 522
#MyWindow = 0
#MyStatusbar = 0
#MyListIcon = 1
#MyPanel = 2
scrollbar.SCROLLINFO\cbSize = SizeOf(SCROLLINFO)
scrollbar\fMask = #SIF_ALL
Global scrollbar, oldCallback
Procedure lvScrollInfo(hGadget, sb_VH, info$)
GetScrollInfo_(hGadget, sb_VH, @scrollbar)
StatusBarText(0, 0, info$)
StatusBarText(0, 1, "Min: " + Str(scrollbar\nMin))
StatusBarText(0, 2, "Max: " + Str(scrollbar\nMax))
StatusBarText(0, 3, "Pos: " + Str(scrollbar\nPos))
StatusBarText(0, 4, "Page size: " + Str(scrollbar\nPage))
StatusBarText(0, 5, "Tracking: " + Str(scrollbar\nTrackPos))
EndProcedure
Procedure myLVcallback(hwnd, msg, wparam, lparam)
Shared scroll$
result = CallWindowProc_(oldCallback, hwnd, msg, wparam, lparam)
Select msg
Case #WM_VSCROLL
Select wparam &$FFFF
Case #SB_BOTTOM
scroll$ = "Scrolled to bottom"
;Case #SB_ENDSCROLL
;scroll$ = "Scroll ended "
Case #SB_LINEDOWN
scroll$ = "Scrolled down one line"
Case #SB_LINEUP
scroll$ = "Scrolled up one line"
Case #SB_PAGEDOWN
scroll$ = "Scrolled down one page"
Case #SB_PAGEUP
scroll$ = "Scrolled up one page"
Case #SB_THUMBPOSITION
scroll$ = "Scrolled using scroll thumb"
Case #SB_THUMBTRACK
scroll$ = "Scrolling using thumb"
Case #SB_TOP
scroll$ = "Scrolled to top"
EndSelect
lvScrollInfo(hwnd, #SB_VERT, scroll$)
Case #WM_HSCROLL
Select wparam &$FFFF
;Case #SB_ENDSCROLL
; scroll$ = "Scroll ended"
Case #SB_LEFT
scroll$ = "Scrolled to upper left"
Case #SB_RIGHT
scroll$ = "Scrolled to lower right"
Case #SB_LINELEFT
scroll$ = "Scrolled left one unit"
Case #SB_LINERIGHT
scroll$ = "Scrolled right one unit"
Case #SB_PAGELEFT
scroll$ = "Scrolled left one page"
Case #SB_PAGERIGHT
scroll$ = "Scrolled right one page"
Case #SB_THUMBPOSITION
scroll$ = "Scrolled using scroll thumb"
Case #SB_THUMBTRACK
scroll$ = "Scrolling using thumb"
EndSelect
lvScrollInfo(hwnd, #SB_HORZ, scroll$)
EndSelect
ProcedureReturn result
EndProcedure
If OpenWindow(#MyWindow, 100, 100, 600, 260, #PB_Window_SystemMenu | #PB_Window_ScreenCentered,"ListIcon Detect scroll") And CreateGadgetList(WindowID())
CreateStatusBar(0, WindowID(#MyWindow))
AddStatusBarField(150)
For f = 1 To 5
AddStatusBarField(90)
Next f
PanelGadget(#MyPanel, 5, 5, 590, 220)
AddGadgetItem(#MyPanel, -1, "Panel 1")
ListIconGadget(#MyListIcon, 20, 20, 300, 150, "Column 0", 150, #PB_ListIcon_FullRowSelect | #PB_ListIcon_AlwaysShowSelection)
CloseGadgetList()
; --> Subclass ListIconGadget to catch scrolls
oldCallback = SetWindowLong_(GadgetID(#MyListIcon), #GWL_WNDPROC, @myLVcallback())
AddGadgetColumn(#MyListIcon,1,"Column 1",150)
For i = 0 To 100
AddGadgetItem(#MyListIcon,-1,"Line " + Str(i) + " Column 0" + Chr(10) + "Line " + Str(i) + " Column 1")
Next i
Repeat
event = WaitWindowEvent()
; --> Catch mousewheel scrolls in ListIconGadget
If EventGadgetID() = #MyListIcon And GetGadgetState(#MyListIcon) > -1 And event = #WM_MOUSEWHEEL
lvScrollInfo(GadgetID(#MyListIcon), #SB_VERT, "Scroll with mousewheel")
EndIf
Until event = #PB_Event_CloseWindow
EndIf
End
What goes around comes around.
PB 5.21 LTS (x86) - Windows 8.1
PB 5.21 LTS (x86) - Windows 8.1

