Announcement

Collapse
No announcement yet.

Scrollbar control basics

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Scrollbar control basics

    I want to put a scrollbar on an app, the scrollbar is NOT attached to any control, it's just there to make a user think he is scrolling through pages of labels/textboxes when in reality I will relabel and reuse those text/label controls...

    So I've searched and come up with code but not grasping what i"m doing wr ong, I'm ASSUMING that since I'm using this as a control and not the dialog scroll taht I should treat it like any other control and put it under WM_COMMAND.......no?

    Note I'm also only using a vertical scrollbar.
    I can also tell something is wrong as it appears to be two scrollbars jammed together, not a nice clean control (It's a visual thing)


    Code:
    In my DIalog Proc
    Static hScrollCtl       As Long
    Static SB               As SCROLLINFO     
    
    
    Select Case CbMsg
    
        Case %WM_INITDIALOG 
            SB.cbSize=SizeOf(SB)
            SB.fMask=%SIF_ALL
            SB.nMin=1
            SB.nMax=100
            SB.nPage=10
            SB.nPos=1
            SB.nTrackPos=0
            SetScrollInfo ByVal hScrollCtl,ByVal %SB_VERT, SB, %TRUE  
    
    
         Case %WM_COMMAND
          Select Case LoWrd(CbWParam)
              Case %IDVSCROLL
                  GetScrollInfo hScrollCtl, %SB_VERT, SB
                  Local oldPos   As Long
                  oldPos = SB.nPos
                  Select Case LoWrd(CbWParam)
                      Case %SB_LINEDOWN
                          SB.nPos = SB.nPos + 1
                      Case %SB_PAGEDOWN
                        SB.nPos = SB.nPos + SB.nPage
                    Case %SB_LINEUP
                        SB.nPos = SB.nPos - 1
                    Case %SB_PAGEUP
                        SB.nPos = SB.nPos - SB.nPage
                    Case %SB_THUMBTRACK
                        SB.nPos = HiWrd(CbWParam)
                    Case Else
                        Exit Function
                  End Select
                  SB.fMask = %SIF_POS
                  SetScrollInfo hScrollCtl, %SB_VERT, SB, 1
                  ScrollWindow hScrollCtl, 0, oldPos - SB.nPos, ByVal %NULL, ByVal %NULL
    Scott Turchin
    MCSE, MCP+I
    http://www.tngbbs.com
    ----------------------
    True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

  • #2
    I'm ASSUMING that since I'm using this as a control and not the dialog scroll taht I should treat it like any other control and put it under WM_COMMAND.......no?
    No. You should be looking for WM_HSCROLL and/or WM_VSCROLL (in your case only the WM_VSCROLL ) notification messages to detect events (clicks or keyboard action) occuring on the scrollbars.

    The WM_VSCROLL message is sent to a window when a scroll event occurs in the window's standard vertical scroll bar. This message is also sent to the owner of a vertical scroll bar control when a scroll event occurs in the control.
    See your WinApi reference for more details.

    MCM
    PS
    >Static hScrollCtl As Long

    FWIW, not necessary to keep as a STATIC. You can always get 'when needed' with GetDlgItem(hWnd, %ID_SCROLLBAR) or CONTROL HANDLE hDlg, %ID_SCROLLBAR
    Michael Mattias
    Tal Systems Inc. (retired)
    Racine WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      Try CASE %WM_VSCROLL in the SELECT CASE CBMSG block.

      Of course Michael's help is a tad more specific
      Last edited by Rodney Hicks; 2 Aug 2008, 12:33 PM. Reason: Near simultaneous postings
      Rod
      I want not 'not', not Knot, not Knott, not Nott, not knot, not naught, not nought, but aught.

      Comment


      • #4
        :doh:
        WM_VSCROLL
        ...
        lParam
        If the message is sent by a scroll bar, this parameter is the handle to the scroll bar control. If the message is not sent by a scroll bar, this parameter is NULL.
        Michael Mattias
        Tal Systems Inc. (retired)
        Racine WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          OK Got the point but still can't get the message...
          I put MSGBOX's in to verify - no go.....

          Code:
              Case %WM_INITDIALOG    
                  SB.cbSize=SizeOf(SB)
                  SB.fMask=%SIF_ALL
                  SB.nMin=0
                  SB.nMax=100
                  SB.nPage=10
                  SB.nPos=10
                  SB.nTrackPos=10
                  SetScrollInfo GetDlgItem(CbHndl,%IDVSCROLL),ByVal %SB_VERT, SB, %TRUE
          
          
               Case %WM_VSCROLL
                   SB.cbSize=SizeOf(SB)
                   SB.fMask=%SIF_ALL
                   GetScrollInfo GetDlgItem(CbHndl,%IDVSCROLL), %SB_VERT, SB
                   Select Case LoWrd(CbLParam)
                       Case %SB_LINEDOWN
                           SB.nPos=SB.nPos + 1
                           MsgBox "Down"
                       Case %SB_LINEUP
                           SB.nPos=SB.nPos - 1
                           MsgBox "Up"
                       Case %SB_PAGEDOWN
                           SB.nPos=SB.nPos+SB.nPage
                           MsgBox "Down"
                       Case %SB_PAGEUP
                           SB.nPos=SB.nPos-SB.nPage
                           MsgBox "Up"
                       Case %SB_THUMBPOSITION
                           SB.nPos=SB.nTrackPos
                       Case %SB_THUMBTRACK
                           SB.nPos=SB.nTrackPos
                       Case Else
                           Exit Function
                   End Select
                   SetScrollInfo GetDlgItem(CbHndl,%IDVSCROLL),ByVal %SB_VERT, SB, %TRUE
          Scott Turchin
          MCSE, MCP+I
          http://www.tngbbs.com
          ----------------------
          True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

          Comment


          • #6
            Code:
             Case %WM_VSCROLL
                     SB.cbSize=SizeOf(SB)
                     SB.fMask=%SIF_ALL
                     GetScrollInfo GetDlgItem(CbHndl,%IDVSCROLL), %SB_VERT, SB
                    Select Case LoWrd(CbLParam)   '   Use wrong value so routine won't work.
                        Case %SB_LINEDOWN
            What does your doc say about wParam and lparam for WM_VSCROLL notification?

            MCM
            Michael Mattias
            Tal Systems Inc. (retired)
            Racine WI USA
            [email protected]
            http://www.talsystems.com

            Comment


            • #7
              What doc?
              Scott Turchin
              MCSE, MCP+I
              http://www.tngbbs.com
              ----------------------
              True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

              Comment


              • #8
                What doc?

                Whatever you use for your Windows API documentation,that's what doc.

                Ain't got nuttin' local? Start here: http://msdn.microsoft.com/en-us/default.aspx
                Michael Mattias
                Tal Systems Inc. (retired)
                Racine WI USA
                [email protected]
                http://www.talsystems.com

                Comment


                • #9
                  This I found in the forums, but I don't know who put it there, it does a good job with scrollbars and easy to understand, adapt, and adopt.
                  Code:
                  #PBFORMS CREATED V1.51
                  '--------------------------------------------------------------------------------------------------
                  ' The first line in this file is a PB/Forms metastatement.
                  ' It should ALWAYS be the first line of the file. Other
                  ' PB/Forms metastatements are placed at the beginning and
                  ' end of "Named Blocks" of code that should be edited
                  ' with PBForms only. Do not manually edit or delete these
                  ' metastatements or PB/Forms will not be able to reread
                  ' the file correctly.  See the PB/Forms documentation for
                  ' more information.
                  ' Named blocks begin like this:    #PBFORMS BEGIN ...
                  ' Named blocks end like this:      #PBFORMS END ...
                  ' Other PB/Forms metastatements such as:
                  '     #PBFORMS DECLARATIONS
                  ' are used by PB/Forms to insert additional code.
                  ' Feel free to make changes anywhere else in the file.
                  '--------------------------------------------------------------------------------------------------
                  
                  #COMPILE EXE
                  #DIM ALL
                  
                  '--------------------------------------------------------------------------------------------------
                  '   ** Includes **
                  '--------------------------------------------------------------------------------------------------
                  #PBFORMS BEGIN INCLUDES 
                  #IF NOT %DEF(%WINAPI)
                    #INCLUDE "WIN32API.INC"
                  #ENDIF
                  #PBFORMS END INCLUDES
                  '--------------------------------------------------------------------------------------------------
                  
                  '--------------------------------------------------------------------------------------------------
                  '   ** Constants **
                  '--------------------------------------------------------------------------------------------------
                  #PBFORMS BEGIN CONSTANTS 
                  %IDD_DIALOG1 =  101
                  %IDC_LABEL1  = 1001
                  %IDC_LABEL2  = 1002
                  %IDC_LABEL3  = 1003
                  %IDC_HELPME  = 1004
                  #PBFORMS END CONSTANTS
                  '--------------------------------------------------------------------------------------------------
                  
                  '--------------------------------------------------------------------------------------------------
                  '   ** Declarations **
                  '--------------------------------------------------------------------------------------------------
                  DECLARE CALLBACK FUNCTION ShowDIALOG1Proc()
                  DECLARE FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
                  #PBFORMS DECLARATIONS
                  '--------------------------------------------------------------------------------------------------
                  
                  '--------------------------------------------------------------------------------------------------
                  '   ** Main Application Entry Point **
                  '--------------------------------------------------------------------------------------------------
                  FUNCTION PBMAIN()
                    ShowDIALOG1 %HWND_DESKTOP
                  END FUNCTION
                  '--------------------------------------------------------------------------------------------------
                  
                  '--------------------------------------------------------------------------------------------------
                  '   ** CallBacks **
                  '--------------------------------------------------------------------------------------------------
                  CALLBACK FUNCTION ShowDIALOG1Proc()
                    LOCAL w AS LONG, h AS LONG, oldPos AS LONG, si AS SCROLLINFO
                    LOCAL vt AS LONG, ht AS LONG, hs AS LONG, vs AS LONG
                    w=600
                    h=400
                    vt=50
                    ht=50
                    hs=5
                    vs=5
                    SELECT CASE AS LONG CBMSG
                      CASE %WM_INITDIALOG
                        ' Initialization handler
                        si.cbSize=LEN(si)
                        si.fMask=%SIF_ALL
                        si.nMin=0
                        si.nMax=h
                        si.nPage=vt
                        SetScrollInfo CBHNDL, %SB_VERT, si, 1
                        si.nMin=0
                        si.nMax=w
                        si.nPage=ht
                        si.nPos=0
                        SetScrollInfo CBHNDL, %SB_HORZ, si, 1
                  
                      CASE %WM_NCACTIVATE
                        STATIC hWndSaveFocus AS DWORD
                        IF ISFALSE CBWPARAM THEN
                          ' Save control focus
                          hWndSaveFocus = GetFocus()
                        ELSEIF hWndSaveFocus THEN
                          ' Restore control focus
                          SetFocus(hWndSaveFocus)
                          hWndSaveFocus = 0
                        END IF
                  
                      CASE %WM_COMMAND
                        ' Process control notifications
                        SELECT CASE AS LONG CBCTL
                          CASE %IDC_LABEL1
                  
                          CASE %IDC_LABEL2
                  
                          CASE %IDC_LABEL3
                  
                        END SELECT
                      CASE %WM_HSCROLL
                        si.cbSize=SIZEOF(si)
                        si.fMask=%SIF_ALL
                        GetScrollInfo CBHNDL, %SB_HORZ, si
                        oldPos=si.nPos
                        SELECT CASE LOWRD(CBWPARAM)
                          CASE %SB_LINELEFT
                            si.nPos=si.nPos-hs
                          CASE %SB_PAGELEFT
                            si.nPos=si.nPos=si.nPage
                          CASE %SB_LINERIGHT
                            si.nPos=si.nPos+hs
                          CASE %SB_PAGERIGHT
                            si.nPos=si.nPos+si.nPage
                          CASE %SB_THUMBTRACK
                            si.nPos=HIWRD(CBWPARAM)
                          CASE ELSE
                            EXIT FUNCTION
                        END SELECT
                        si.nPos=MAX&(si.nMin, MIN&(si.nPos, si.nMax-si.nPage))
                        si.fMask=%SIF_POS
                        SetScrollInfo CBHNDL,%SB_HORZ,si,1
                        ScrollWindow CBHNDL, oldPos-si.nPos,0,BYVAL %NULL, BYVAL %NULL
                        FUNCTION = 1
                  
                      CASE %WM_VSCROLL
                        si.cbSize=SIZEOF(si)
                        si.fMask=%SIF_ALL
                        GetScrollInfo CBHNDL, %SB_VERT, si
                        oldPos=si.nPos
                        SELECT CASE LOWRD(CBWPARAM)
                          CASE %SB_LINEUP
                            si.nPos=si.nPos-vs
                          CASE %SB_PAGEUP
                            si.nPos=si.nPos-si.nPage
                          CASE %SB_LINEDOWN
                            si.nPos=si.nPos+vs
                          CASE %SB_PAGEDOWN
                            si.nPos=si.nPos+si.nPage
                          CASE %SB_THUMBTRACK
                            si.nPos=HIWRD(CBWPARAM)
                          CASE ELSE
                            EXIT FUNCTION
                        END SELECT
                        si.nPos=MAX&(si.nMin, MIN&(si.nPos, si.nMax-si.nPage+1))
                        si.fMask=%SIF_POS
                        SetScrollInfo CBHNDL, %SB_VERT, si, 1
                        ScrollWindow CBHNDL,0, oldPos-si.nPos,BYVAL %NULL, BYVAL %NULL
                        FUNCTION = 1
                    END SELECT
                  END FUNCTION
                  '--------------------------------------------------------------------------------------------------
                  
                  '--------------------------------------------------------------------------------------------------
                  '   ** Dialogs **
                  '--------------------------------------------------------------------------------------------------
                  FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
                    LOCAL lRslt AS LONG
                  
                  #PBFORMS BEGIN DIALOG %IDD_DIALOG1->->
                    LOCAL hDlg  AS DWORD
                  
                    DIALOG NEW hParent, "SCROLLER", 359, 88, 283, 359, %WS_POPUP OR %WS_BORDER OR %WS_DLGFRAME OR _
                      %WS_SYSMENU OR %WS_MINIMIZEBOX OR %WS_MAXIMIZEBOX OR %WS_CLIPSIBLINGS OR %WS_VSCROLL OR _
                      %WS_VISIBLE OR %DS_MODALFRAME OR %DS_3DLOOK OR %DS_NOFAILCREATE OR %DS_SETFONT, _
                      %WS_EX_CONTROLPARENT OR %WS_EX_LEFT OR %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR, TO hDlg
                    CONTROL ADD LABEL,  hDlg, %IDC_LABEL1, "Label1", 5, 5, 100, 10
                    CONTROL ADD LABEL,  hDlg, %IDC_LABEL2, "510 LEFT", 510, 260, 100, 10
                    CONTROL ADD LABEL,  hDlg, %IDC_LABEL3, "405BOTTOM", 10, 305, 100, 10
                    CONTROL ADD BUTTON, hDlg, %IDC_HELPME, "HELP", 475, 130, 50, 15
                  #PBFORMS END DIALOG
                  
                    DIALOG SHOW MODAL hDlg, CALL ShowDIALOG1Proc TO lRslt
                  
                  #PBFORMS BEGIN CLEANUP %IDD_DIALOG1
                  #PBFORMS END CLEANUP
                  
                    FUNCTION = lRslt
                  END FUNCTION
                  '--------------------------------------------------------------------------------------------------
                  Last edited by Rodney Hicks; 3 Aug 2008, 04:36 PM. Reason: add info
                  Rod
                  I want not 'not', not Knot, not Knott, not Nott, not knot, not naught, not nought, but aught.

                  Comment


                  • #10
                    Code:
                          GetScrollInfo CBHNDL, %SB_VERT, si
                    This gets scroll info for the scrollbar which is part of the dialog, not a child scrollbar control, which is what this question is about.

                    See your documentation for more details.
                    Michael Mattias
                    Tal Systems Inc. (retired)
                    Racine WI USA
                    [email protected]
                    http://www.talsystems.com

                    Comment


                    • #11
                      Using my code above I REM'd out the initial SETSCROLLINFO and amazing enough the scrollbar "Looks" normal now, not like a shadow on another one.
                      But as soon as I click it and do the SETSCROLLINFO it takes on that form and stops functioning....I think I"mdoing it correctly but I have a conflict of some kind...
                      Scott Turchin
                      MCSE, MCP+I
                      http://www.tngbbs.com
                      ----------------------
                      True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

                      Comment


                      • #12
                        > [on WM_INITDIALOG]
                        > SetScrollInfo ByVal hScrollCtl,ByVal %SB_VERT, SB, %TRUE

                        Value of hScrollCtl was not set prior to this call in WM_INITDIALOG.

                        When SetScrollInfo is called later after adjustment, SB values must be adjusted based in the settings used in SetScrollinfo... i.e. you must adjust your 'scroll position' based in the current page and position within the page. i.e, it is unlikely SB_LINEDOWN will correspond to exactly one "scroll unit" as set with SetScrollInfo, even if you had properly called SetScrollInfo with a valid control handle on WM_INITDIALOG.

                        But it looks like you are getting closer.
                        Michael Mattias
                        Tal Systems Inc. (retired)
                        Racine WI USA
                        [email protected]
                        http://www.talsystems.com

                        Comment


                        • #13
                          I did a Control Handle cbhndl, %IDVSCROLL to hScrollCtl but forgot to paste it.

                          THe weird part is, and I wish I could take a picture and send you, AFTER I do the SetScroll, the scrollbar gets thinner and looks like a second one underneath it, UNLESS I do that byval stuff and even then it only works once and goes back to it again....
                          Scott Turchin
                          MCSE, MCP+I
                          http://www.tngbbs.com
                          ----------------------
                          True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

                          Comment


                          • #14
                            >wish I could take a picture and send you

                            Well, next best thing - actually a better thing when you think about it - make up a little one-screen demo program.

                            I assume what we don't see in code posted so far is when you get WM_VSCROLL, you scroll some other control containing text and/or pictures.

                            And, if the user uses he keyboard to scroll in that other control, you want to reset the external scrollbar so the thumb stays about where it belongs relative to "how far down the list" the user has scrolled.

                            Surely you can cut and paste a few pieces from what you've got and post it here for others to play with?

                            MCM
                            Michael Mattias
                            Tal Systems Inc. (retired)
                            Racine WI USA
                            [email protected]
                            http://www.talsystems.com

                            Comment


                            • #15
                              Ya can do, except it appears I have resolved that issue.......

                              The handle to the scrollbar must be passed byval or it acts WEIRD....

                              SetScrollInfo byval varptr(scrollhandle) etc etc....

                              Tx!
                              Scott Turchin
                              MCSE, MCP+I
                              http://www.tngbbs.com
                              ----------------------
                              True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

                              Comment


                              • #16
                                This works almost flawlessly....debug time 2nite..

                                Code:
                                %IDVSCROLL          = %WM_USER + 208
                                
                                Winmain:
                                Control Add ScrollBar, g_hDlg,%IDVSCROLL,"",410,150,10,60
                                
                                DialogProc:
                                
                                Local  SB               As SCROLLINFO
                                Static PageNo           As Long
                                Local  cStart           As Long
                                Local  cStop            As Long
                                
                                Select Case CbMsg
                                    Case %WM_INITDIALOG
                                        Control Handle CbHndl, %IDVSCROLL To g_hScroll
                                        SB.cbSize=SizeOf(SB)
                                        SB.fMask=%SIF_ALL
                                        SB.nMin=0
                                        SB.nMax=100
                                        SB.nPage=10
                                        SB.nPos=10
                                        SB.nTrackPos=10
                                        SetScrollInfo ByVal VarPtr(g_hScroll) ,%SB_VERT, SB, %TRUE
                                        PageNo = 1
                                
                                     Case %WM_VSCROLL
                                         SB.cbSize=SizeOf(SB)
                                         SB.fMask=%SIF_ALL
                                         GetScrollInfo ByVal VarPtr(g_hScroll), %SB_VERT, SB
                                         Select Case LoWrd(CbWParam)
                                
                                             Case %SB_LINEDOWN
                                                 SB.nPos=SB.nPos + 1
                                                 If PageNo = 10 Then  'Can't go past page 10
                                                     Exit Function
                                                 Else
                                                     Incr PageNo
                                                     cStart = PageNo * 10
                                                     cStop = (PageNo * 10) + 10
                                '                     MsgBox "cStart: " & Format$(cStart) & $CrLf & "cStop: " & Format$(cStop)
                                                     For lLoop = cStart To cStop 'Change variables on the page
                                                         Incr lCount
                                                         sTmp = "Command " & Format$(lLoop)
                                                         Control Set Text CbHndl, %COMMANDLABEL0 + lCount,sTmp
                                                         sTmp = Commands(lLoop)
                                                         Control Set Text CbHndl, %COMMAND0 + lCount,sTmp
                                                     Next
                                                End If
                                
                                             Case %SB_LINEUP
                                                 SB.nPos=SB.nPos - 1
                                                 If PageNo = 1 Then
                                                     Exit Function
                                                 Else
                                                     Decr PageNo
                                                     cStart = PageNo * 10
                                                     cStop = (PageNo * 10) + 10
                                '                     MsgBox "cStart: " & Format$(cStart) & $CrLf & "cStop: " & Format$(cStop)
                                                     For lLoop = cStart To cStop
                                                         Incr lCount
                                                         sTmp = "Command " & Format$(lLoop)
                                                         Control Set Text CbHndl, %COMMANDLABEL0 + lCount,sTmp
                                                         sTmp = Commands(lLoop)
                                                         Control Set Text CbHndl, %COMMAND0 + lCount,sTmp
                                                     Next
                                                 End If
                                
                                             Case %SB_PAGEDOWN
                                                 SB.nPos=SB.nPos+SB.nPage
                                                 If PageNo = 10 Then  'Can't go past page 10
                                                     Exit Function
                                                 Else
                                                     Incr PageNo
                                                     cStart = PageNo * 10
                                                     cStop = (PageNo * 10) + 10
                                '                     MsgBox "cStart: " & Format$(cStart) & $CrLf & "cStop: " & Format$(cStop)
                                                     For lLoop = cStart To cStop 'Change variables on the page
                                                         Incr lCount
                                                         sTmp = "Command " & Format$(lLoop)
                                                         Control Set Text CbHndl, %COMMANDLABEL0 + lCount,sTmp
                                                         sTmp = Commands(lLoop)
                                                         Control Set Text CbHndl, %COMMAND0 + lCount,sTmp
                                                     Next
                                                End If
                                
                                             Case %SB_PAGEUP
                                                 SB.nPos=SB.nPos-SB.nPage
                                                 SB.nPos=SB.nPos - 1
                                                 If PageNo = 1 Then
                                                     Exit Function
                                                 Else
                                                     Decr PageNo
                                                     cStart = PageNo * 10
                                                     cStop = (PageNo * 10) + 10
                                                     MsgBox "cStart: " & Format$(cStart) & $CrLf & "cStop: " & Format$(cStop)
                                                     For lLoop = cStart To cStop
                                                         Incr lCount
                                                         sTmp = "Command " & Format$(lLoop)
                                                         Control Set Text CbHndl, %COMMANDLABEL0 + lCount,sTmp
                                                         sTmp = Commands(lLoop)
                                                         Control Set Text CbHndl, %COMMAND0 + lCount,sTmp
                                                     Next
                                                 End If
                                             Case %SB_THUMBPOSITION
                                                 SB.nPos=SB.nTrackPos
                                             Case %SB_THUMBTRACK
                                                 SB.nPos=SB.nTrackPos
                                             Case Else
                                                 Exit Function
                                         End Select
                                         SetScrollInfo ByVal VarPtr(g_hScroll),ByVal %SB_VERT, SB, %TRUE
                                Scott Turchin
                                MCSE, MCP+I
                                http://www.tngbbs.com
                                ----------------------
                                True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

                                Comment


                                • #17
                                  >SetScrollInfo ByVal VarPtr(g_hScroll) ,%SB_VERT, SB, %TRUE

                                  Time to re-

                                  When GetScrollInfo and SetScrollInfo are used for a standalone control, what is the correct value to use for parameter two? (Hint: it is not %SB_VERT!)

                                  And BYVAL VARPTR(g_hScroll) is not correct. That handle should be passed by value, not by reference ("BYVAL VARPTR()" = "BYREF")

                                  (FWIW, you do not need to save that handle in a global variable. It comes as lparam on every WM_SCROLL notification from a standalone scrollbar control)

                                  MCM
                                  Last edited by Michael Mattias; 4 Aug 2008, 06:17 PM.
                                  Michael Mattias
                                  Tal Systems Inc. (retired)
                                  Racine WI USA
                                  [email protected]
                                  http://www.talsystems.com

                                  Comment


                                  • #18
                                    DId not know that!
                                    I'll see if I can test that here today, odds are it will be a few days - I will be back though!! Company flying in....ugh...
                                    Scott Turchin
                                    MCSE, MCP+I
                                    http://www.tngbbs.com
                                    ----------------------
                                    True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

                                    Comment


                                    • #19
                                      Originally posted by Michael Mattias View Post
                                      >SetScrollInfo ByVal VarPtr(g_hScroll) ,%SB_VERT, SB, %TRUE

                                      Time to re-

                                      When GetScrollInfo and SetScrollInfo are used for a standalone control, what is the correct value to use for parameter two? (Hint: it is not %SB_VERT!)

                                      And BYVAL VARPTR(g_hScroll) is not correct. That handle should be passed by value, not by reference ("BYVAL VARPTR()" = "BYREF")

                                      (FWIW, you do not need to save that handle in a global variable. It comes as lparam on every WM_SCROLL notification from a standalone scrollbar control)

                                      MCM
                                      OK Mike ya got me, what are the answers for parameter 2 then????

                                      Did not know about lparam but that would be easier to work with so I will change and test!

                                      Tx!
                                      Scott Turchin
                                      MCSE, MCP+I
                                      http://www.tngbbs.com
                                      ----------------------
                                      True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

                                      Comment


                                      • #20
                                        >OK Mike ya got me, what are the answers for parameter 2 then????

                                        !!!

                                        Check your WinAPI doc for WM_HSCROLL, WM_VSCROLL, GetScrollInfo and SetScrollInfo.

                                        And while you're at it, check the doc under CONTROL ADD SCROLLBAR in your compiler help file. It even tells you explicitly there to be careful to avoid making the mistake of using SB_VERT or SB_HORZ!!

                                        (Now that we know this is DDT rather than SDK style I can point you there).

                                        In fairness... there is some bad inconsistency on that help file page as well. First, the syntax for CONTROL ADD SCROLLBAR allows you to enter a "txt$" parameter, although that text is never shown (cleverly explained away in the text of the help, however) ; second, it supports a CALLBACK option allowing you to have a control-level callback function WHICH CAN NEVER BE CALLED. (Surprise!).

                                        MCM
                                        Michael Mattias
                                        Tal Systems Inc. (retired)
                                        Racine WI USA
                                        [email protected]
                                        http://www.talsystems.com

                                        Comment

                                        Working...
                                        X