0,1,2,3, ... ,n, n+1,n+2, ...
That convention is not only very old, it's also very intuitive and simple.
The corresponding computer convention is the TrackBar, which also represents values increasing and decreasing along a line.
On a horizontal TrackBar, values are expected to increase from small to large as the Slider moves towards the right (either by pressing the Right-Arrow key, or by sliding it with the mouse). Conversely, values must decrease as the Slider moves left. That works exactly as expected in Windows. Easy to track too. Intuitive to use.
On a vertical TrackBar, one similarly expects values to increase as the Slider moves up, and to decrease as it moves down. Small values at the bottom, larger ones at the top. The Up-arrow will show an increase, the Down-arrow a decrease. Again, simple and intuitive, isn't it ? Of course...
But not for Windows. :roll: Ahhhhhh!!!! How could they screw up something so simple?
Run the PB Windows applet below, and see for yourself how the vertical TrackkBar throws the convention out the window (so to speak

PS: my many thanks to Sparkie for an example code (which i just can't find any more!) that made me find my way around this.
Code: Select all
;;
;; Blue -- September 2009
;;
;; source: http://www.purebasic.fr/english/viewtopic.php?f=13&t=39184
;;
EnableExplicit
#faux = 0
#vrai = ~#faux
Enumeration
#htrack
#hTxt
#vtrack
#vTxt
#cmdOK
#cmdCancel
#cmdReset
EndEnumeration
#winColor = #Black
#txColor = #Yellow
;- variables globales
Global bgColor = CreateSolidBrush_(#winColor)
Global hTrack_ID, vTrack_ID
Global endScroll_done
Procedure WindowProc(hWnd, msg, wParam, lParam)
Define gadget, sPos, ePos
Select msg
Case #WM_CTLCOLORSTATIC
SetBkMode_(wParam,#TRANSPARENT)
SetTextColor_(wParam, #txColor)
ProcedureReturn bgColor
Case #WM_HSCROLL, #WM_VSCROLL
If lParam = hTrack_ID
gadget = #hTrack
Else
gadget = #vTrack
EndIf
sPos = GetGadgetData(gadget)
ePos = GetGadgetState(gadget)
Select wParam & $FFFF
Case #SB_THUMBPOSITION
Debug "------- #SB_THUMBPOSITION message "
If Not endScroll_done
Debug " mouse wheel "
SetGadgetData(gadget, epos) ;; because not done in #SB_ENDSCROLL
EndIf
SetGadgetText(gadget+1, "from " + Str(sPos) + " to " + Str(ePos))
endScroll_done = #faux
Case #SB_ENDSCROLL
SetGadgetData(gadget, epos) ; end position becomes next start position
SetGadgetText(gadget+1, "From " + Str(sPos) + " to " + Str(ePos))
Debug "#SB_ENDSCROLL wparam "+ Hex(wparam) + " " + Str(sPos) + " " + Str(ePos)
endScroll_done = #vrai
Case #SB_THUMBTRACK , #SB_LINELEFT, #SB_PAGELEFT, #SB_LINERIGHT, #SB_PAGERIGHT
SetGadgetText(gadget+1, "Start = " + Str(sPos) + ": now at " + Str(ePos))
; Debug " s: " + Str(spos) + ", e: " + Str(ePos)
EndSelect ;; wparam
EndSelect ;; msg
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
Procedure InitDialogue(winW,winH)
If Not OpenWindow(0,#PB_Ignore,0,winW,winH,"Tracking Values on TrackBars",#PB_Window_SystemMenu)
ProcedureReturn 0
EndIf
SetWindowColor(0, #winColor)
SetWindowCallback(@WindowProc())
Define gadget, gX, gY, gW, gH
gH = 20
gW = 60
gY = winH - gH - 10
gX = winW - gW - 10
gadget = #cmdOK
ButtonGadget(gadget,gX,gY,gW,gH," Quit ")
gX - 80 - 6
gadget = #cmdReset
ButtonGadget(gadget,gX,gY,80,20,"Reset")
gH = 200
gW = 32
gY = 10
gX = 10
gadget = #vtrack
vTrack_ID = TrackBarGadget(gadget, gX,gY, gW,gH, 1,10, #PB_TrackBar_Ticks | #PB_TrackBar_Vertical)
SetGadgetData(gadget,1) ; starting position of the thumb in the trackBar
SetActiveGadget(#vtrack) ; forces Windows to redraw the object
gX + gW + 4
TextGadget(gadget+1, gX,gY+gH-20-20, 150,20, "Vertical trackBar at 1")
gH = gW
gW = GadgetHeight(gadget) * 1.2
gadget = #htrack
hTrack_ID = TrackBarGadget(gadget, gX,gY, gW,gH, 1,10, #PB_TrackBar_Ticks)
SetGadgetData(gadget,1) ; starting position of the thumb in the trackBar
TextGadget(gadget+1, gX+10,gY+gH+4, 150,20, "Horizontal trackBar at 1")
ProcedureReturn #vrai
EndProcedure
Procedure Reset()
SetGadgetText(#htrack+1, "Horizontal trackBar at 1")
SetGadgetData(#htrack,1)
SetGadgetState(#htrack,1)
SetGadgetState(#vtrack,1)
SetGadgetData(#vtrack,1)
SetGadgetText(#vtrack+1, "Vertical trackBar at 1")
SetActiveGadget(#vtrack) ; forces Windows to redraw the object
EndProcedure
;;; ==================================================
If InitDialogue(320,220)
Define gadget, event, evType, evWindow
Repeat
;-{ boucle des évènements }
event = WaitWindowEvent()
evType = EventType()
evWindow = EventWindow()
gadget = EventGadget()
Select event
Case #PB_Event_CloseWindow: Break ;
Case #PB_Event_Gadget
Select gadget
Case #cmdOK: Break
Case #cmdCancel: Break
Case #cmdReset: Reset()
EndSelect
; Default
; If event : Debug event : EndIf
EndSelect
;}
ForEver
EndIf
;;; ==================================================
If bgColor
DeleteObject_(bgColor)
EndIf
End
But it's NOT a PB problem. In fact it's only a programming problem

A solution, simple and effective, is presented in TrackBar : mathematically correct scrolling !