More code...
Code: Select all
Global offset.POINT
Procedure TestCallback(Handle.l, uMsg.l, wParam.l, lParam.l)
;
Protected lResult.l
;
Protected AllowScroll.l
;
Protected HoldInfo.SCROLLINFO
;
If uMsg = #WM_HSCROLL
;{ User is scrolling a horizontal scrollbar.
; If lParam = GadgetID(0)
;/ This would be a place to test which scrollbar is used.
HoldInfo\cbSize = SizeOf(SCROLLINFO)
;
HoldInfo\fMask = #SIF_ALL
;
GetScrollInfo_(lParam, #SB_CTL, @HoldInfo)
;
AllowScroll = #True
; Allow scrolling by default.
If wParam & $FFFF = #SB_THUMBTRACK
HoldInfo\nPos = HoldInfo\nTrackPos
ElseIf wParam & $FFFF = #SB_LINERIGHT
HoldInfo\nPos + 1
ElseIf wParam & $FFFF = #SB_LINELEFT
HoldInfo\nPos - 1
ElseIf wParam & $FFFF = #SB_PAGERIGHT
HoldInfo\nPos + 3
ElseIf wParam & $FFFF = #SB_PAGELEFT
HoldInfo\nPos - 3
Else
; The scroll message is unhandled.
AllowScroll = #False
; Do not allow the user to scroll.
EndIf
;
If AllowScroll
;
If HoldInfo\nPos <> offset\X
;
offset\X = HoldInfo\nPos
;
Else
;
ProcedureReturn #True
;
EndIf
;
Else
;
ProcedureReturn #True
;
EndIf
;
;}
ElseIf uMsg = #WM_VSCROLL
;{ User is scrolling a vertical scrollbar.
; If lParam = GadgetID(1)
;/ This would be a place to test which scrollbar is used.
HoldInfo\cbSize = SizeOf(SCROLLINFO)
; Store the size of the ScrollInfo structure.
HoldInfo\fMask = #SIF_ALL
; All settings are needed.
GetScrollInfo_(lParam, #SB_CTL, @HoldInfo)
; Retrieve information on the scrollbar.
AllowScroll = #True
; Allow scrolling by default.
If wParam & $FFFF = #SB_THUMBTRACK
HoldInfo\nPos = HoldInfo\nTrackPos
ElseIf wParam & $FFFF = #SB_LINEUP
HoldInfo\nPos - 1
ElseIf wParam & $FFFF = #SB_LINEDOWN
HoldInfo\nPos + 1
ElseIf wParam & $FFFF = #SB_PAGEUP
HoldInfo\nPos - 3
ElseIf wParam & $FFFF = #SB_PAGEDOWN
HoldInfo\nPos + 3
Else
; The scroll message is unhandled.
AllowScroll = #False
; Do not allow the user to scroll.
EndIf
;
If AllowScroll
;
If HoldInfo\nPos <> offset\Y
offset\Y = HoldInfo\nPos
Else
ProcedureReturn #True
EndIf
;
Else
; The user is not allowed to scroll to the desired position.
ProcedureReturn #True
; Do not process the scrollbar event.
EndIf
;}
EndIf
;
ProcedureReturn #PB_ProcessPureBasicEvents
;
EndProcedure
If OpenWindow(0, 0, 0, 305, 140, "ScrollBarGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
TextGadget (2, 10, 25, 250, 20, "ScrollBar Standard (start=50, page=30/100)",#PB_Text_Center)
ScrollBarGadget (0, 10, 42, 250, 20, 0, 100, 30)
SetGadgetState (0, 50) ; set 1st scrollbar (ID = 0) to 50 of 100
TextGadget (3, 10,115, 250, 20, "ScrollBar Vertical (start=100, page=50/300)",#PB_Text_Right)
ScrollBarGadget (1, 270, 10, 25, 120 ,0, 300, 50, #PB_ScrollBar_Vertical)
SetGadgetState (1, 100) ; set 2nd scrollbar (ID = 1) to 100 of 300
ButtonGadget(4, 0, 0, 20, 20, "D")
ButtonGadget(5, 20, 0, 20, 20, "S")
ButtonGadget(6, 40, 0, 20, 20, "E")
ButtonGadget(7, 60, 0, 20, 20, "?")
SetWindowCallback(@TestCallback())
Repeat
Event=WaitWindowEvent()
EventGadget=EventGadget()
If Event=#PB_Event_Gadget And EventGadget=0
Debug "1 : "+Str(EventType())
EndIf
If Event=#PB_Event_Gadget And EventGadget=1
Debug "2 : "+Str(EventType())
EndIf
If Event=#PB_Event_Gadget And EventGadget=4 And EventType() = #PB_EventType_LeftClick
DisableGadget(0, #True)
EndIf
If Event=#PB_Event_Gadget And EventGadget=5 And EventType() = #PB_EventType_LeftClick
SetGadgetAttribute(0, 35, 0)
EndIf
If Event=#PB_Event_Gadget And EventGadget=6 And EventType() = #PB_EventType_LeftClick
DisableGadget(0, #False)
EndIf
If Event=#PB_Event_Gadget And EventGadget=7 And EventType() = #PB_EventType_LeftClick
If GetWindowLong_(GadgetID(0), #GWL_STYLE) & #WS_DISABLED : Debug "Disabled" : Else : Debug "Enabled" : EndIf
EndIf
Until Event=#PB_Event_CloseWindow
EndIf
So now there are 4 buttons at the top: D, S, E, ?
D disables the horizontal scrollbar. S sets the attribute and E enables the scrollbar. ? should output whether the scrollbar is enabled or not.
I'm not seeing the behavior you're seeing. I click D to disable the scrollbar and then S to set the attribute as you say and the scrollbar is still disabled.
So...? Is that not how you're doing it?