PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Stephane Fonteyne on January 28, 2010, 03:43:14 PM

Title: Cant move the thumb and can't move with the mouse the scrollbar
Post by: Stephane Fonteyne on January 28, 2010, 03:43:14 PM
Hi everyone,

I try to move the scrollbar with the mouse, but it doesn't work.
This is my source code:



Function FORM1_WM_CREATE ( _
                         hWndForm As Dword, _      ' handle of Form
                         ByVal UserData As Long _  ' optional user defined Long value
                         ) As Long
                         
  Static sbline   As Long : sbline = 2                'SmallChange
  Static sbpage   As Long : sbPage = 10               'LargeChange
  Static sbpos    As Long : sbPos  = 10               'Positie 10
  Static sbMin    As Long : sbMin  = 20               'Min : 20ms
  Static sbMax    As Long : sbMax  = 500              'Max : 500ms 
 
  FF_ScrollBar_SetPos(HWND_FORM1_HSCROLL1, sbPos, -1)
  FF_ScrollBar_SetRange(HWND_FORM1_HSCROLL1, sbMin, sbMax)

End Function




'--------------------------------------------------------------------------------
Function FORM1_HSCROLL1_WM_HSCROLL ( _
                                   ControlIndex  As Long,  _  ' index in Control Array
                                   hWndForm      As Dword, _  ' handle of Form
                                   hWndControl   As Dword, _  ' handle of Control
                                   nScrollCode   As Long,  _  ' scroll bar value
                                   nPosition     As Long   _  ' current scroll bar position
                                   ) As Long
       
   
  Static sbline   As Long : sbline = 2                'SmallChange
  Static sbpage   As Long : sbPage = 10               'LargeChange
  Static sbpos    As Long : sbPos  = 10               'Positie 10
  Static sbMin    As Long : sbMin  = 20               'Min : 20ms
  Static sbMax    As Long : sbMax  = 500              'Max : 500ms 
           

   Select Case nScrollCode                      'Scrolling request
      Case %SB_LINERIGHT
         '====================================================================
         'The SmallChange : op de pijltjes van de ScrollBar
         '====================================================================
         sbpos = Min(sbMax, sbpos + sbline)          'sbline is small change
         FF_ScrollBar_SetPos(HWND_FORM1_HSCROLL1, sbPos, -1)
         'Control Set Text CB.HNDL, %IDC_LABEL1, "Position =" + Str$(sbpos)
         
      Case %SB_LINELEFT
         '====================================================================
         'The SmallChange : op de pijltjes van de ScrollBar
         '====================================================================
         sbpos = Max(sbMin, sbpos - sbline)
         FF_ScrollBar_SetPos(HWND_FORM1_HSCROLL1, sbPos, -1)
         'Control Set Text CB.HNDL, %IDC_LABEL1, "Position =" + Str$(sbpos)
         '====================================================================

      Case %SB_PAGERIGHT
         '====================================================================
         'The LargeChange : page, size of Thumb
         '====================================================================
         sbpos = Min(sbMax, sbpos + sbpage)         ' page is larger change, also = size of Thumb
         FF_ScrollBar_SetPos(HWND_FORM1_HSCROLL1, sbPos, -1)
         'Control Set Text CB.HNDL, %IDC_LABEL1, "Position ="+Str$(sbpos)
         '====================================================================
                   
      Case %SB_PAGELEFT
         '====================================================================
         'The LargeChange : page, size of Thumb
         '====================================================================
         sbpos = Max(sbMin, sbpos - sbpage)
         FF_ScrollBar_SetPos(HWND_FORM1_HSCROLL1, sbPos, -1)
         'Control Set Text CB.HNDL, %IDC_LABEL1, "Position ="+Str$(sbpos)
         '====================================================================

      Case %SB_THUMBTRACK                     ' ### comment out one or other
         '====================================================================
         'Positie van de scrollerpijl
         '====================================================================
         sbpos = nPosition
         FF_ScrollBar_SetPos(HWND_FORM1_HSCROLL1, sbPos, -1)
         'Control Set Text CB.HNDL, %IDC_LABEL1, "Position ="+Str$(sbpos)
         '====================================================================   
   End Select
End Function




Can sombody help my what I do wrong in my code?
Thanks in advance
Title: Re: Cant move the thumb and can't move with the mouse the scrollbar
Post by: Rolf Brandt on January 28, 2010, 05:39:10 PM
Hello Stephane,

try this code:
Function FORM1_HSCROLL1_WM_HSCROLL ( _
                                   ControlIndex  As Long,  _  ' index in Control Array
                                   hWndForm      As Dword, _  ' handle of Form
                                   hWndControl   As Dword, _  ' handle of Control
                                   nScrollCode   As Long,  _  ' scroll bar value
                                   nPosition     As Long   _  ' current scroll bar position
                                   ) As Long

   
   Local x As Long
     
   x = FF_ScrollBar_GetPos( HWND_FORM1_HSCROLL1 )
   FF_ScrollBar_SetPos( HWND_FORM1_HSCROLL1, x + 5, %True )
End Function


Rolf