Announcement

Collapse
No announcement yet.

Scrollbar control basics

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

  • #21
    OK NOW it's finally working! Thanks!

    It wasn't moving the scroller last time, and on top of that I had left the same code in there from another section, thought I had removed it.

    So now I just need to get my math correct on my text and label's so that they rename appropriately for ea ch page I am on - no easy feat but I'll figure it out...

    Byval is gone, thanks!
    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


    • #22
      >OK NOW it's finally working

      I will make a guess that having to look up all that info to make it so, you are not likely to forget how you got it working.

      >just need to get my math correct ...appropriately for each page

      I'll trade you "lining up stuff on the page" tasks even up.

      I finally got the final specs on that invoice application. Now all I have to do is figure out where to break pages given ..

      - I have four (4) possible vertical inch values in which to print line items: First page which is last page; first page which is not last page; non-first last page; and non-first, non-last page.
      - Each line item requires a variable number of vertical inches (number of print lines).

      Deal?

      (Forgot: I don't want to break multiple-printline line items across a page, either)
      Last edited by Michael Mattias; 6 Aug 2008, 08:27 AM.
      Michael Mattias
      Tal Systems Inc. (retired)
      Racine WI USA
      [email protected]
      http://www.talsystems.com

      Comment


      • #23
        Yikes, I think I see some IF/THEN statements....

        This is my challenge, works on page down and scroll down but only goes back to 10....can't divide by zero so I'll be putting my thinking cap on tod ay.

        I haven't learned the last item we discussed about the handle just yet....time is tight lately

        Code:
             Case %WM_VSCROLL
                 SB.cbSize=SizeOf(SB)
                 SB.fMask=%SIF_ALL
                 GetScrollInfo g_hScroll, %SB_CTL, SB
                 Select Case LoWrd(CbWParam)
                     Case %SB_LINEDOWN,%SB_PAGEDOWN
                         If LoWrd(CbWParam) = %SB_PAGEDOWN Then SB.nPos=SB.nPos+SB.nPage
        
                         If SB.nPos = 9 Then Exit Function
                         Control Set Text CbHndl, %DEBUG,"SB.nPos: " & Format$(SB.nPos)
                         For lLoop = 1 To 10 'Change variables on the page
                             sTmp = "Command " & Format$(SB.nPos * 10 + lLoop)
                             Control Set Text CbHndl, %COMMANDLABEL0 + lLoop,sTmp
                             sTmp = Commands(SB.nPos * 10 + lLoop)
                             Control Set Text CbHndl, %COMMAND0 + lLoop,sTmp
                         Next
                         Incr SB.nPos  'INCREMENT AFTER otherwise it skips 10-20
        
                     Case %SB_LINEUP,%SB_PAGEUP
                         If LoWrd(CbWParam) = %SB_PAGEUP Then SB.nPos=SB.nPos-SB.nPage 'page value is 10
                         Decr SB.nPos  'DECREMENT AFTER otherwise it skips 10-20
                         Control Set Text CbHndl, %DEBUG,"SB.nPos: " & Format$(SB.nPos)
                         For lLoop = 1 To 10 'Change variables on the page
                             sTmp = "Command " & Format$(SB.nPos * 10 + lLoop)
                             Control Set Text CbHndl, %COMMANDLABEL0 + lLoop,sTmp
                             sTmp = Commands(SB.nPos * 10 + lLoop)
                             Control Set Text CbHndl, %COMMAND0 + lLoop,sTmp
                         Next
        
                     Case %SB_THUMBPOSITION
                         SB.nPos=SB.nTrackPos
                     Case %SB_THUMBTRACK
                         SB.nPos=SB.nTrackPos
                     Case Else
                         Exit Function
                 End Select
                 SetScrollInfo g_hScroll,ByVal %SB_CTL, 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


        • #24
          I have a small problem in my DDT scrollbar.

          the Graphic window displays correctly and the linedown/page down etc make the display correctly but the scrollbar sets the position to the correct point
          and displays it for a split second and
          then immediately goes back to the top making it appear that no scrolling has taken place.

          Written in pbwin8
          The control ID is %IDC_Scrollbar1
          It's a vertical control
          A portion of the callback:
          Code:
              CASE %WM_VSCROLL
                si.cbSize=SIZEOF(si)
                si.fMask=%SIF_ALL
               
               CONTROL HANDLE hDlgPreview, %IDC_SCROLLBAR1 TO hCtrl&
               GetScrollInfo hCtrl&, SFlag&, Si
               IF Offset!=0 THEN Offset!=32
               SELECT CASE LOWRD(CBWPARAM) 'wParam&)
                    CASE %SB_LINEDOWN       ' sames as %SB_LINERIGHT
          '               Si.nPos=Si.nPos+12 '1
                         TopLine!=TopLine!+3
                         BottomLine!=BottomLine!+3
          
                         IF TopLine!+offSet!>65 THEN
                           TopLine!=65-Offset!+1
                           BottomLine!=65
                         END IF
                         BottomLine!=TopLine!+Offset!
                         Si.npos=TopLine!*4
                         IF TopLine!>=Offset! AND Offset!<>0 THEN downit&=1
                         IF downit& THEN
                           CONTROL KILL hDlgPreview,305
                           IF numcolors>8 THEN
                             CONTROL ADD  IMGBUTTONX,hDlgPreview,305,"PU1",188*xoffset!,02,45*xoffset!,16*yoffset!
                           ELSE
                             CONTROL ADD  BUTTON,hDlgPreview,305,"Page Up",188*xoffset!,02,45*xoffset!,16*yoffset!
                           END IF
                         END IF
          ''msgbox "topline!="+str$(topline!)+"  "+"Bottomline!="+STR$(bottomline!)
                    CASE %SB_LINEUP         ' sames as %SB_LINELEFT
          '               Si.nPos=Si.nPos-12
                         TopLine!=TopLine!-3
                         IF TopLine!<0 THEN TopLine!=0
                         BottomLine!=TopLine!+Offset!
                         Si.nPos=TopLine!*4
                         IF BottomLine!<=Offset! THEN Downit&=0
                         IF downit&=0 THEN
                           CONTROL KILL hDlgPreview,305
                           IF numcolors>8 THEN
                             CONTROL ADD  IMGBUTTONX,hDlgPreview,305,"PD1",188*xoffset!,02,45*xoffset!,16*yoffset!
                           ELSE
                             CONTROL ADD  BUTTON,hDlgPreview,305,"Page Down",188*xoffset!,02,45*xoffset!,16*yoffset!
                           END IF
                         END IF
                    CASE %SB_PAGEDOWN       ' sames as %SB_PAGERIGHT
                         Si.nPos=Si.nPos+135 'Si.nPage
                         TopLine!=Offset!
          '
                         BottomLine!=65
          
                         IF downit&=0 THEN
                           downit&=1
                           CONTROL KILL hDlgPreview,305
                           IF numcolors>8 THEN
                             CONTROL ADD  IMGBUTTONX,hDlgPreview,305,"PU1",188*xoffset!,02,45*xoffset!,16*yoffset!
                           ELSE
                             CONTROL ADD  BUTTON,hDlgPreview,305,"Page Up",188*xoffset!,02,45*xoffset!,16*yoffset!
                           END IF
                         END IF
          
                    CASE %SB_PAGEUP         ' sames as %SB_PAGELEFT
                         'TopLine!=TopLine!-12
                         'if TopLine!<0 then TopLine!=0
                         'Si.nPos=TopLine!*4 'Si.nPos-Si.nPage
                         TopLine!=0
                         BottomLine!=Offset!
                         Si.nPos=0
                    CASE %SB_THUMBPOSITION
                         Si.nPos=Si.nTrackPos    'SP&
                    CASE %SB_THUMBTRACK
                         Si.nPos=Si.nTrackPos    'SP&
               END SELECT
               SetScrollInfo hCtrl&, %SB_CTL, si, %TRUE
               lResult&=previewit(coid$,pagespreviewed&) 'read from file
               EXIT FUNCTION
          The previewit reads the information from a file and prints it on the Graphic
          with the Graphic statements.

          I have a Page Down/Page Up button that either shows the bottom half of the page or the top half of the page and it works fine with the scroll bar either being at the top or bottom.

          **posted later***
          Figured out the problem
          It was in the GetScrollinfo statement
          Code:
          changed
               GetScrollInfo hCtrl&, SFlag&, Si
          to
               GetScrollInfo hCtrl&, %SB_CTL, si
          and it works fine now
          Last edited by Fred Buffington; 27 May 2009, 06:04 PM.
          Client Writeup for the CPA

          buffs.proboards2.com

          Links Page

          Comment


          • #25
            Hi Fred,

            Here's my DDT working effort, maybe it'll help:

            Code:
            	CASE %WM_VSCROLL ' vertical scrollbar has been used
            		SCROLLBAR GET PAGESIZE CB.HNDL, %VerSB TO S&
            		SCROLLBAR GET RANGE CB.HNDL, %VerSB TO L&, H&
            
            		SELECT CASE CB.CTL
            '			CASE %SB_THUMBPOSITION
            '			SCROLLBAR GET TRACKPOS CB.HNDL, %VerSB TO P&
            '			SCROLLBAR SET POS CB.HNDL, %VerSB, P&
            
            			CASE %SB_THUMBTRACK
            			SCROLLBAR GET TRACKPOS CB.HNDL, %VerSB TO P&
            			SCROLLBAR SET POS CB.HNDL, %VerSB, P&
            
            			CASE %SB_LINEDOWN
            			SCROLLBAR GET POS CB.HNDL, %VerSB TO P&
            			P& += D& ': P& = MIN&( H&, P& ) 'stay in range
            			SCROLLBAR SET POS CB.HNDL, %VerSB, P&
            
            			CASE %SB_LINEUP
            			SCROLLBAR GET POS CB.HNDL, %VerSB TO P&
            			P& -= D& ': P& = MAX&( L&, P& ) 'stay in range
            			SCROLLBAR SET POS CB.HNDL, %VerSB, P&
            
            			CASE %SB_PAGEDOWN
            			SCROLLBAR GET POS CB.HNDL, %VerSB TO P&
            			P& += S& ': P& = MIN&( H&, P& ) 'stay in range
            			SCROLLBAR SET POS CB.HNDL, %VerSB, P&
            
            			CASE %SB_PAGEUP
            			SCROLLBAR GET POS CB.HNDL, %VerSB TO P&
            			P& -= S& ': P& = MAX&( L&, P& ) 'stay in range
            			SCROLLBAR SET POS CB.HNDL, %VerSB, P&
            
            			CASE %SB_BOTTOM
            			SCROLLBAR SET POS CB.HNDL, %VerSB, H&
            
            			CASE %SB_TOP
            			SCROLLBAR SET POS CB.HNDL, %VerSB, L&
            	
            			CASE ELSE
            				EXIT FUNCTION
            		END SELECT
            The rest of the effort is here :

            http://www.powerbasic.com/support/pb...ad.php?t=40344
            Regards,
            Marc

            Comment


            • #26
              Started working on the Scroll Bars in Easy Tape and found this thread. I tool My Pal Rodney 's example (#9) and fooled around with it until I understood it better (removed all the unnecessary PBForms stuff and renamed some variables).

              Took me awhile to realize when the scroll posn is returned, it's actually figured from a percentage of the range of where the scroll "button' is in the range (that's probably not sensical to anyone else (except maybe My Pal)) but anyway here's the code:

              Code:
                
              'http://powerbasic.com/support/pbforums/showthread.php?t=38102&highlight=add+scrollbar
              'Rodney Hicks
              '--------------------------------------------------------------------------------------------------
              ' *******************************************************
              'PBWIN 9.02 - WinApi 05/2008 - XP Pro 
               '
              ' *******************************************************
              
              #Compile Exe
              #Dim All
              '--------------------------------------------------------------------------------------------------
              '   ** Includes **
              '--------------------------------------------------------------------------------------------------
              #If Not %Def(%WINAPI)
                #Include "WIN32API.INC"
              #EndIf
              '--------------------------------------------------------------------------------------------------
              '--------------------------------------------------------------------------------------------------
              '   ** Constants **
              '--------------------------------------------------------------------------------------------------
              %IDD_DIALOG1 =  101
              %IDC_LABEL1  = 1001
              %IDC_LABEL2  = 1002
              %IDC_LABEL3  = 1003
              %IDC_HELPME  = 1004
              '--------------------------------------------------------------------------------------------------
              Global g_dlg_wd, g_dlg_ht As Long
              Global g_dlg_Widest_Control, g_dlg_Deepest_Control As Long
              '--------------------------------------------------------------------------------------------------
              '   ** Declarations **
              '--------------------------------------------------------------------------------------------------
              Declare CallBack Function ShowDIALOG1Proc()
              Declare Function ShowDIALOG1(ByVal hParent As Dword) As Long
              '--------------------------------------------------------------------------------------------------
              '--------------------------------------------------------------------------------------------------
              '   ** 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
              '
                Local White_Space_Moves, Arrow_Moves As Long
              '
                w= 600 
                h= 600                ' '
                vt=50  'White space moves
                ht=50  'White space moves
                hs=5   'Arrow Moves
                vs=5   'Arrow Moves    
                White_Space_Moves = vt
                Arrow_Moves = vs
              '
                Select Case As Long CbMsg
                  Case %WM_INITDIALOG
                    ' Initialization handler
                    si.cbSize=Len(si)
                    si.fMask=%SIF_ALL
                    si.nMin=0
                    si.nMax= g_dlg_Deepest_Control'h
                    si.nPage= White_Space_Moves 'vt
                    SetScrollInfo CbHndl, %SB_VERT, si, 1
                    si.nMin=0
                    si.nMax= g_dlg_Widest_Control 'w
                    si.nPage= White_Space_Moves
                    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_HELPME
                        ?"clicked"
                    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- Arrow_Moves 'hs
                      Case %SB_PAGELEFT
              '          si.nPos=si.nPos=si.nPage '<<< Error
                        si.nPos=si.nPos - White_Space_Moves
                      Case %SB_LINERIGHT
                        si.nPos=si.nPos+ Arrow_Moves 'hs
                      Case %SB_PAGERIGHT
                        si.nPos=si.nPos+  White_Space_Moves'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
                    Dialog Set Text CB.Hndl, Using$("Horizontal #, ", si.nPos)
                    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- Arrow_Moves
                      Case %SB_PAGEUP
                        si.nPos=si.nPos- White_Space_Moves'si.nPage
                      Case %SB_LINEDOWN
                        si.nPos=si.nPos+ Arrow_Moves
                      Case %SB_PAGEDOWN
                        si.nPos=si.nPos+ White_Space_Moves'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
                    Dialog Set Text CB.Hndl, Using$("Vertical #, ", si.nPos)
                    Function = 1
                    
                End Select
              End Function
              '--------------------------------------------------------------------------------------------------
              '--------------------------------------------------------------------------------------------------
              '   ** Dialogs **
              '--------------------------------------------------------------------------------------------------
              Function ShowDIALOG1(ByVal hParent As Dword) As Long
                Local lRslt As Long
                Local hDlg  As Dword
                Local stile, stile_ex As Long
                Local n As String 
                
                n$ = " 1234567890"
                g_dlg_wd = 300' 283
                g_dlg_ht = 300 '359     
              '  
               ' 
              '  stile = %WS_POPUP 
                stile = stile Or %WS_BORDER
              '  stile = stile Or %WS_DLGFRAME
                stile = stile Or %WS_SYSMENU
                stile = stile Or %WS_MINIMIZEBOX
                stile = stile Or %WS_MAXIMIZEBOX
              '  stile = stile Or %WS_CLIPSIBLINGS
              '  stile = stile Or %WS_VSCROLL 'not needed as PB automatically adds it if needed
              '  stile = stile Or %WS_VISIBLE
              '  stile = stile Or %DS_MODALFRAME
              '  stile = stile Or %DS_3DLOOK
              '  stile = stile Or %DS_NOFAILCREATE
              '  stile = stile Or %DS_SETFONT
              '
              ' stile_ex = %WS_EX_CONTROLPARENT 
              ' stile_ex = stile_ex Or %WS_EX_RIGHTSCROLLBAR
              ' stile_ex = stile_ex Or %WS_EX_LEFT
              ' stile_ex = stile_ex Or %WS_EX_LTRREADING
              '
                Dialog New Pixels, hParent, "SCROLLER", , , g_dlg_wd, g_dlg_ht, Stile, Stile_ex, To hDlg
                Stile = %SS_Right
                Control Add Label,  hDlg, %IDC_LABEL1, "5 , 5 Label1" & n$, 5, 5, 100, 30, stile
                Control Add Label,  hDlg, %IDC_LABEL2, "510, 260  - 510 LEFT" & n$, 510, 260, 100, 30, stile
                Control Add Label,  hDlg, %IDC_LABEL3, "10, 405  -  405 BOTTOM" & n$, 10, 405, 100, 30, stile
                Control Add Button, hDlg, %IDC_HELPME, "475, 130 HELP", 475, 130, 200, 35
              '  
                g_dlg_Widest_Control = 510 'Label2 
                g_dlg_Deepest_Control = 405 'Label3 
              '
                Dialog Show Modal hDlg, Call ShowDIALOG1Proc To lRslt
              '
                Function = lRslt
              End Function
              '--------------------------------------------------------------------------------------------------
              It's a pretty day. I hope you enjoy it.

              Gösta

              JWAM: (Quit Smoking): http://www.SwedesDock.com/smoking
              LDN - A Miracle Drug: http://www.SwedesDock.com/LDN/

              Comment

              Working...
              X