Code: Select all
#WHEEL_DELTA = 120
Procedure ScrollAreaProc(hwnd, msg, wparam, lparam)
oldproc = GetProp_(hwnd, "oldproc")
stepvalue = GetProp_(hwnd, "stepvalue")
Select msg
Case #WM_NCDESTROY
RemoveProp_(hwnd, "oldproc")
RemoveProp_(hwnd, "stepvalue")
Case #WM_VSCROLL
If wparam&$FFFF = #SB_LINEDOWN
h = GetScrollPos_(hwnd, #SB_VERT)
SetScrollPos_(hwnd, #SB_VERT,h+stepvalue,1)
ElseIf wparam & $FFFF = #SB_LINEUP
h = GetScrollPos_(hwnd, #SB_VERT)
SetScrollPos_(hwnd, #SB_VERT,h-stepvalue,1)
EndIf
Case #WM_HSCROLL
If wparam&$FFFF = #SB_LINERIGHT
h = GetScrollPos_(hwnd, #SB_HORZ)
SetScrollPos_(hwnd, #SB_HORZ,h+stepvalue,1)
ElseIf wparam & $FFFF = #SB_LINELEFT
h = GetScrollPos_(hwnd, #SB_HORZ)
SetScrollPos_(hwnd, #SB_HORZ,h-stepvalue,1)
EndIf
EndSelect
ProcedureReturn CallWindowProc_(oldproc, hwnd, msg, wparam, lparam)
EndProcedure
Procedure ScrollAreaPanelProc(hwnd, msg, wparam, lparam)
Protected zDelta.w, schWnd
oldproc = GetProp_(hwnd, "oldproc")
stepvalue = GetProp_(hwnd, "stepvalue")
Select msg
Case #WM_NCDESTROY
RemoveProp_(hwnd, "oldproc")
RemoveProp_(hwnd, "stepvalue")
Case #WM_MOUSEWHEEL
;Obtain the wheel increment in units of #WHEEL_DELTA (120).
zDelta = wParam>>16&$ffff
zDelta / #WHEEL_DELTA
If zDelta
schWnd = GadgetID(0)
h = GetScrollPos_(schWnd, #SB_VERT)
SetScrollPos_(schWnd, #SB_VERT,h-zDelta*stepvalue,1)
EndIf
EndSelect
ProcedureReturn CallWindowProc_(oldproc, hwnd, msg, wparam, lparam)
EndProcedure
If OpenWindow(0, 0, 0, 550, 550, "ScrollAreaGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
hwnd = ScrollAreaGadget(0, 10, 10, 500,500, 1000, 1000, 0)
ButtonGadget (1, 10, 10, 230, 30,"Button 1")
ButtonGadget (2, 80, 100, 230, 30,"Button 2")
ButtonGadget (3, 140, 200, 230, 30,"Button 3")
TextGadget (4, 200, 300, 230, 20,"This is the content of a ScrollAreaGadget!",#PB_Text_Right)
TextGadget (5, 200,400,60,20,"Step Value:")
StringGadget (6, 260,400,40,20,"10")
CloseGadgetList()
SetProp_(hwnd, "oldproc", SetWindowLongPtr_(hwnd, #GWL_WNDPROC, @ScrollAreaProc()))
SetProp_(hwnd, "stepvalue", 10)
hWnd = FindWindowEx_(hWnd, 0, "PureScrollAreaChild",0)
SetProp_(hwnd, "oldproc", SetWindowLongPtr_(hwnd, #GWL_WNDPROC, @ScrollAreaPanelProc()))
SetProp_(hwnd, "stepvalue", 10)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
End
Case #PB_Event_Gadget
Select EventGadget()
Case 1
MessageRequester("Info","Button 1 was pressed!",#PB_MessageRequester_Ok)
Case 2
MessageRequester("Info","Button 2 was pressed!",#PB_MessageRequester_Ok)
Case 3
MessageRequester("Info","Button 3 was pressed!",#PB_MessageRequester_Ok)
Case 6
If EventType() = #PB_EventType_Change
SetProp_(GadgetID(0), "stepvalue", Val(GetGadgetText(6)))
SetProp_(hWnd, "stepvalue", Val(GetGadgetText(6)))
EndIf
EndSelect
EndSelect
ForEver
EndIf