Announcement

Collapse
No announcement yet.

Scrollbar control basics

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

  • Michael Mattias
    replied
    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

    Leave a comment:


  • Scott Turchin
    replied
    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

    Leave a comment:


  • Michael Mattias
    replied
    :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.

    Leave a comment:


  • Rodney Hicks
    replied
    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, 01:33 PM. Reason: Near simultaneous postings

    Leave a comment:


  • Michael Mattias
    replied
    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

    Leave a comment:


  • Scott Turchin
    started a topic Scrollbar control basics

    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
Working...
X