功能:
很簡單,就是通過手動,顯示進度,并表示數(shù)值。
不同點:函數(shù)不同,原來的不能公用了,特別是滾動條,是另外一個控件,響應(yīng)的消息也不是控件的,而是系統(tǒng)的那個WM_HScroll,函數(shù)也是對應(yīng)的了。設(shè)置標度,等等,函數(shù)都要對應(yīng),其實查API也可以。
// TODO: Add extra initialization here
m_progress.SetRange(0,100);
m_progress.SetStep(5);
m_progress.SetPos(0);
m_edit = 0;
UpdateData(FALSE)

void CTest27Dlg::OnForward()


{
// TODO: Add your control notification handler code here
int nLow,nUp;
m_progress.GetRange(nLow,nUp);
int nPos = m_progress.GetPos();
if(((nPos+5)>nUp)&&((nPos)<=nUp))
nPos = 100;
else
nPos += 5;
m_progress.SetPos(nPos);
m_edit = nPos;
UpdateData(FALSE);
}

void CTest27Dlg::OnBackward()


{
// TODO: Add your control notification handler code here
int nLow,nUp;
m_progress.GetRange(nLow,nUp);
int nPos = m_progress.GetPos();
if(((nPos-5)<nLow)&&((nPos)>=nLow))
nPos = 0;
else
nPos -= 5;
m_progress.SetPos(nPos);
m_edit = nPos;
UpdateData(FALSE);
}

// TODO: Add extra initialization here
m_scroll.SetScrollRange(0,100);
m_scroll.SetScrollPos(10);
m_edit = 10;
UpdateData(FALSE);




void CTest28Dlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)


{
// TODO: Add your message handler code here and/or call default
int npos = m_scroll.GetScrollPos(); //此函數(shù)也是固定的模式

switch(nSBCode)
{ //選擇模式,這個是由系統(tǒng)調(diào)用默認的
case SB_LINELEFT:
npos--;
break;
case SB_LINERIGHT:
npos++;
break;
case SB_PAGELEFT:
npos -= 10;
break;
case SB_PAGERIGHT:
npos += 10;
break;
case SB_THUMBTRACK:
npos = nPos;
break;
}
if(npos < 0)
nPos = 0;
if(npos > 100)
nPos = 100;
m_scroll.SetScrollPos(npos);
m_edit = npos;
UpdateData(FALSE);
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}


posted on 2010-02-07 00:22
deercoder 閱讀(405)
評論(0) 編輯 收藏 引用