|
-
September 30th, 2003, 02:57 AM
#1
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)
-
September 30th, 2003, 03:05 AM
#2
-
September 30th, 2003, 06:31 AM
#3
-
September 30th, 2003, 07:29 AM
#4
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)
-
September 30th, 2003, 08:20 AM
#5
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)
-
October 3rd, 2003, 08:40 AM
#6
Not sure what you're trying to do, have you tried using a ScrollView?
-
October 3rd, 2003, 09:00 AM
#7
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|