#Include once "window9.bi"

Function ScrollBarGadget(ByVal gadget As Integer,ByVal x As Integer, ByVal y As Integer, ByVal width_ As Integer, ByVal Height_ As Integer, ByVal MINRange As Integer, ByVal MAXRange As Integer,ByVal Style As Integer=0, ByVal PageLength As Integer=10) As HWND Export
  SetPageStepScrollBar(PageLength)
  Var scroll=CreateWindowEx(0,"SCROLLBAR","",WS_CHILD Or WS_VISIBLE Or style,_
  x,y,width_,height_,GETGURRENTAL,Cast(HMENU,gadget),0,0)
  SetScrollRange(Scroll, SB_CTL, MINRange, MAXRange, TRUE)
  ADDIN9999(gadget,scroll)
  ColorAdd(scroll,&hf0f0f0,0)
  Return scroll
End Function

Function SetScrollGadgetPos OverLoad(ByVal gadget As Integer,ByVal POSITION As Integer) As Integer Export
  Return SetScrollPos(GadgetID(gadget),SB_CTL,POSITION,TRUE)
End Function

Function SetScrollGadgetPos OverLoad(ByVal hwnd As HWND,ByVal POSITION As Integer, ByVal style As integer) As Integer Export
  If style =0 Then
    Return SetScrollPos(hwnd,SB_HORZ,POSITION,TRUE)
  Else
    Return SetScrollPos(hwnd,SB_VERT,POSITION,TRUE)
  EndIf
End Function

Function GetScrollGadgetPos OverLoad(ByVal gadget As Integer) As Integer Export
  Return GetScrollPos(GadgetID(gadget),SB_CTL)
End Function

Function GetScrollGadgetPos OverLoad(ByVal hwnd As hwnd, ByVal style As Integer) As Integer Export
  If style =0 Then
    Return GetScrollPos(hwnd,SB_HORZ)
  Else
    Return GetScrollPos(hwnd,SB_VERT)
  EndIf
End Function

Function SetScrollGadgetRange OverLoad(ByVal gadget As Integer,ByVal MINRange As Integer,ByVal MAXRange As Integer) As Integer Export
  Return SetScrollRange(GadgetID(gadget), SB_CTL, MINRange, MAXRange, TRUE)
End Function

Function SetScrollGadgetRange OverLoad(ByVal hwnd As HWND,ByVal MINRange As Integer,ByVal MAXRange As Integer, ByVal style As Integer) As Integer Export
  If style=0 Then
    Return SetScrollRange(hwnd, SB_HORZ, MINRange, MAXRange, TRUE)
  Else
    Return SetScrollRange(hwnd, SB_VERT, MINRange, MAXRange, TRUE)
  EndIf
End Function

Function GetScrollGadgetRange OverLoad(ByVal gadget As Integer, ByVal flag As Integer) As Integer Export
  Dim As Integer MINRange
  Dim As Integer MAXRange
  GetScrollRange(GadgetID(gadget), SB_CTL, @MINRange, @MAXRange)
  Select Case flag
    Case 0
      Return   MINRange
    Case Else
      Return   MAXRange
  End Select
End Function

Function GetScrollGadgetRange OverLoad(ByVal HWND As HWND,ByVal flag As Integer, ByVal style As Integer) As Integer Export
  Dim As Integer MINRange
  Dim As Integer MAXRange
  If style=0 Then
    GetScrollRange(HWND, SB_HORZ, @MINRange, @MAXRange)
  Else
    GetScrollRange(HWND, SB_VERT, @MINRange, @MAXRange)
  EndIf
  Select Case flag
    Case 0
      Return   MINRange
    Case Else
      Return   MAXRange
  End Select
End Function

Function SetScrollGadgetPage OverLoad(ByVal gadget As Integer, ByVal page As Integer) As Integer Export
  Dim sinf As SCROLLINFO
  sinf.cbSize=SizeOf(sinf)
  sinf.fMask=SIF_RANGE Or SIF_PAGE
  GetScrollInfo(GadgetID(gadget),SB_CTL,@sinf)
  sinf.nPage=page
  Return SetScrollInfo(GadgetID(gadget),SB_CTL,@sinf,TRUE)
End Function

Function SetScrollGadgetPage OverLoad(ByVal HWND As HWND, ByVal page As Integer,ByVal style As Integer=0) As Integer Export
  Dim sinf As SCROLLINFO
  sinf.cbSize=SizeOf(sinf)
  sinf.fMask=SIF_RANGE Or SIF_PAGE
  If style=0 Then
    GetScrollInfo(hwnd,SB_HORZ,@sinf)
    sinf.nPage=page
    Return  SetScrollInfo(hwnd,SB_HORZ,@sinf,TRUE)
  Else
    GetScrollInfo(hwnd,SB_VERT,@sinf)
    sinf.nPage=page
    Return  SetScrollInfo(hwnd,SB_VERT,@sinf,TRUE)
  EndIf
End Function
