void CDIALOGNOSE::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
SCROLLINFO si;
int nVScrollMax = 0;
m_nVScrollPos = m_nVPageSize = 0;
if (cy < m_nViewHeight) {
nVScrollMax = m_nViewHeight - 1;
m_nVPageSize = cy;
m_nVScrollPos = min (m_nVScrollPos, m_nViewHeight -
m_nVPageSize - 1);
}
si.fMask = SIF_PAGE | SIF_RANGE | SIF_POS;
si.nMin = 0;
si.nMax =nVScrollMax;
si.nPos = m_nVScrollPos;
si.nPage = m_nVPageSize;
SetScrollInfo (SB_VERT, &si, TRUE);
// TODO: 在此处添加消息处理程序代码
}
int CDIALOGNOSE::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialog::OnCreate(lpCreateStruct) == -1)
return -1;
CClientDC dc (this);
m_nCellWidth = dc.GetDeviceCaps (LOGPIXELSX);
m_nCellHeight = dc.GetDeviceCaps (LOGPIXELSY) / 4;
m_nRibbonWidth = m_nCellWidth / 2;
m_nViewWidth = (26 * m_nCellWidth) + m_nRibbonWidth;
m_nViewHeight = m_nCellHeight * 50;
CRect rect;
GetClientRect(&rect);
//m_nViewWidth = (26 * m_nCellWidth) + m_nRibbonWidth;
// TODO: 在此添加您专用的创建代码
return 0;
}
void CDIALOGNOSE::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
int nDelta;
Compute the vertical scroll distance, or "delta."
switch (nSBCode) {
case SB_LINEUP:
nDelta = -LINESIZE;
break;
case SB_PAGEUP:
nDelta = -m_nVPageSize;
break;
case SB_THUMBTRACK:
nDelta = (int) nPos - m_nVScrollPos;
break;
case SB_PAGEDOWN:
nDelta = m_nVPageSize;
break;
case SB_LINEDOWN:
nDelta = LINESIZE;
break;
case SB_BOTTOM:
nDelta = heifht;
break;
default:
return;
}
int nScrollPos = m_nVScrollPos + nDelta;
int nMaxPos = m_nViewHeight - m_nVPageSize;
if (nScrollPos < 0)
nDelta = -m_nVScrollPos;
else if (nScrollPos > nMaxPos)
nDelta = nMaxPos - m_nVScrollPos;
//
// Update the scroll position and scroll the window.
//
if (nDelta != 0) {
m_nVScrollPos += nDelta;
SetScrollPos (SB_VERT, m_nVScrollPos, TRUE);
ScrollWindow (0, -nDelta);
}
CDialog::OnVScroll(nSBCode, nPos, pScrollBar);
}