CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2003
    Posts
    162

    question on scrollbar control

    i have a scrollbar control in a dialog box.


    i set the SetScrollRange to be (0,100)

    how can i make so that 1 click is increment of 20 at the scrollbar?

    thanks
    0 error(s), 0 warning(s)

  2. #2
    Join Date
    Sep 2003
    Posts
    3
    See MSDN !!!

  3. #3
    Join Date
    Aug 2003
    Posts
    162
    ?
    0 error(s), 0 warning(s)

  4. #4
    Join Date
    Aug 2003
    Posts
    162
    i have created a scrollbar in a dialog and set the scroll range from 0 to 100.

    but when i click the arrow it has no effect at all... ;\
    how to i detect the arrow click??

    thanks
    0 error(s), 0 warning(s)

  5. #5
    Join Date
    Aug 2003
    Posts
    162
    this is some code i got from other post.. it works well but i need to modify something which i do not know how.....
    Code:
    BOOL CScrollDialog::OnInitDialog() 
    {
    	CDialog::OnInitDialog();
    	
    	// TODO: Add extra initialization here
    	SCROLLINFO si;
    	si.fMask = SIF_RANGE | SIF_PAGE;
    	si.nMin = 0;
    	si.nMax = 400;
    	si.nPage = 5;
    	m_scrollbar.SetScrollInfo(&si, FALSE);
    	return TRUE;  // return TRUE unless you set the focus to a control
    	              // EXCEPTION: OCX Property Pages should return FALSE
    }
    
    void CScrollDialog::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
    {
    	// TODO: Add your message handler code here and/or call default
    	SCROLLINFO si;
    
    	si.cbSize = sizeof( SCROLLINFO );
    	m_scrollbar.GetScrollInfo(&si, SIF_ALL );
    
    	switch( nSBCode )
    	{
    		case SB_LEFT:
    		case SB_LINELEFT: 
    			si.nPos -= (si.nPos < 5 ? si.nPos : 5);
    			break;
    		case SB_RIGHT:
    		case SB_LINERIGHT:
    			si.nPos += ((si.nMax - si.nPos)<5?(si.nMax - si.nPos ):5);
    			break;
    		case SB_PAGELEFT:
    			si.nPos -= (si.nPos < (int) si.nPage ? si.nPos : si.nPage);
    			break;
    		case SB_PAGERIGHT:
    			si.nPos += ((si.nMax - si.nPos)< (int)si.nPage?(si.nMax - si.nPos ):si.nPage);
    			break;
    		case SB_THUMBPOSITION:
    		case SB_ENDSCROLL:
    			return;
    			break;
    		case SB_THUMBTRACK:
    			si.nPos = si.nTrackPos;
    			break;
    	}
    
    	m_scrollbar.SetScrollPos(si.nPos);
    	
    	CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
    }
    the scroll is unlimited... when the scroll reach the end the nPage value is still increasing when clicked. how can i make the nPage value stop at nMax ?

    and when i clicked the left scroll the number increase instead of decrease.

    anyone knows how to modify ?? i'm quite new to scrollbar ;\

    Thanks in advance.
    0 error(s), 0 warning(s)

  6. #6
    Join Date
    Oct 2003
    Location
    Reading, UK
    Posts
    46
    Not sure what you're trying to do, have you tried using a ScrollView?

  7. #7
    Join Date
    Jul 2001
    Location
    jordan
    Posts
    63
    go to MSDN and search for OnHScroll, there's an example at
    the bottom , just copy/paste the example. That will get the
    horizontal scrollbar working, just a little modification will get the
    vertical one working too. Let us know when you've got the
    horizontal one working and we can help you with the vertical
    one if you need it.

    awni

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured