从CCtrlView派生的View, 加入的滚动条无法滚动,请高人指点啊解决办法
从CCtrlView派生的View, 加入的滚动条无法滚动,请高人指点啊
我从CtrlView派生了一个CXTabView,功能类似Property Sheet的那种,一个View里面有好几个页面。但该视图没有滚动条,我在Create()里面添加了Style |= WS_VSCROLL|WS_HSCROLL. 运行后出现了滚动条,但是滚动条压根就滚动不了,在此View里面无法收到滚动消息, 添加了WM_VSCROLL和WM_HSCROLL的消息处理函数也就无法运行,怎么回事啊?
------解决方案--------------------
这个似乎还挺麻烦的!
好象要添不少东西.
建议ScrollView派生,要添加控件的话,再上面嵌个子窗口好了!
------解决方案--------------------
CFormView上面放Tab不行么
在Tab上放滚动条也可以
------解决方案--------------------
http://blog.****.net/mynamelj/archive/2006/10/09/1327652.aspx
------解决方案--------------------
不知道,帮顶
------解决方案--------------------
假设滚动条的范围都是0到100;
void CXTabView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: Add your message handler code here and/or call default
int nPrevPos = GetScrollPos(SB_HORZ);
switch(nSBCode)
{
case SB_LEFT: // Scroll to far left.
nPrevPos = 0;
break;
case SB_ENDSCROLL: // End scroll.
break;
case SB_LINELEFT: // Scroll left.
nPrevPos -= 1;
break;
case SB_LINERIGHT: // Scroll right.
nPrevPos += 1;
break;
case SB_PAGELEFT: // Scroll one page left.
nPrevPos -= 10;
break;
case SB_PAGERIGHT: // Scroll one page right.
nPrevPos += 10;
break;
case SB_RIGHT: // Scroll to far right.
nPrevPos = 100;
break;
case SB_THUMBPOSITION: // Scroll to absolute position. The current position is specified by the nPos parameter.
nPrevPos = nPos;
break;
case SB_THUMBTRACK: // Drag scroll box to specified position. The current position is specified by the nPos parameter.
nPrevPos = nPos;
break;
default :
break;
}
SetScrollPos(SB_HORZ, nPrevPos);
CCtrlView::OnHScroll(nSBCode, nPos, pScrollBar);
}
void CXTabView::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: Add your message handler code here and/or call default
int nPrevPos = GetScrollPos(SB_VERT);
switch(nSBCode)
{
case SB_BOTTOM: // Scroll to bottom.
nPrevPos = 100;
break;
case SB_ENDSCROLL: // End scroll.
break;
case SB_LINEDOWN: // Scroll one line down.
nPrevPos += 1;
break;
case SB_LINEUP: // Scroll one line up.
nPrevPos -= 1;
break;
case SB_PAGEDOWN: // Scroll one page down.
nPrevPos += 10;
break;
case SB_PAGEUP: // Scroll one page up.
nPrevPos -= 10;
break;
case SB_THUMBPOSITION: // Scroll to the absolute position. The current position is provided in nPos.
nPrevPos = nPos;
break;
case SB_THUMBTRACK: // Drag scroll box to specified position. The current position is provided in nPos.
nPrevPos = nPos;
break;
case SB_TOP: // Scroll to top.
nPrevPos = 0;
break;
default:
break;
}
SetScrollPos(SB_VERT, nPrevPos);
CCtrlView::OnVScroll(nSBCode, nPos, pScrollBar);
}
可以调节数字改变滚动条滚动的速度!
我从CtrlView派生了一个CXTabView,功能类似Property Sheet的那种,一个View里面有好几个页面。但该视图没有滚动条,我在Create()里面添加了Style |= WS_VSCROLL|WS_HSCROLL. 运行后出现了滚动条,但是滚动条压根就滚动不了,在此View里面无法收到滚动消息, 添加了WM_VSCROLL和WM_HSCROLL的消息处理函数也就无法运行,怎么回事啊?
------解决方案--------------------
这个似乎还挺麻烦的!
好象要添不少东西.
建议ScrollView派生,要添加控件的话,再上面嵌个子窗口好了!
------解决方案--------------------
CFormView上面放Tab不行么
在Tab上放滚动条也可以
------解决方案--------------------
http://blog.****.net/mynamelj/archive/2006/10/09/1327652.aspx
------解决方案--------------------
不知道,帮顶
------解决方案--------------------
假设滚动条的范围都是0到100;
void CXTabView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: Add your message handler code here and/or call default
int nPrevPos = GetScrollPos(SB_HORZ);
switch(nSBCode)
{
case SB_LEFT: // Scroll to far left.
nPrevPos = 0;
break;
case SB_ENDSCROLL: // End scroll.
break;
case SB_LINELEFT: // Scroll left.
nPrevPos -= 1;
break;
case SB_LINERIGHT: // Scroll right.
nPrevPos += 1;
break;
case SB_PAGELEFT: // Scroll one page left.
nPrevPos -= 10;
break;
case SB_PAGERIGHT: // Scroll one page right.
nPrevPos += 10;
break;
case SB_RIGHT: // Scroll to far right.
nPrevPos = 100;
break;
case SB_THUMBPOSITION: // Scroll to absolute position. The current position is specified by the nPos parameter.
nPrevPos = nPos;
break;
case SB_THUMBTRACK: // Drag scroll box to specified position. The current position is specified by the nPos parameter.
nPrevPos = nPos;
break;
default :
break;
}
SetScrollPos(SB_HORZ, nPrevPos);
CCtrlView::OnHScroll(nSBCode, nPos, pScrollBar);
}
void CXTabView::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: Add your message handler code here and/or call default
int nPrevPos = GetScrollPos(SB_VERT);
switch(nSBCode)
{
case SB_BOTTOM: // Scroll to bottom.
nPrevPos = 100;
break;
case SB_ENDSCROLL: // End scroll.
break;
case SB_LINEDOWN: // Scroll one line down.
nPrevPos += 1;
break;
case SB_LINEUP: // Scroll one line up.
nPrevPos -= 1;
break;
case SB_PAGEDOWN: // Scroll one page down.
nPrevPos += 10;
break;
case SB_PAGEUP: // Scroll one page up.
nPrevPos -= 10;
break;
case SB_THUMBPOSITION: // Scroll to the absolute position. The current position is provided in nPos.
nPrevPos = nPos;
break;
case SB_THUMBTRACK: // Drag scroll box to specified position. The current position is provided in nPos.
nPrevPos = nPos;
break;
case SB_TOP: // Scroll to top.
nPrevPos = 0;
break;
default:
break;
}
SetScrollPos(SB_VERT, nPrevPos);
CCtrlView::OnVScroll(nSBCode, nPos, pScrollBar);
}
可以调节数字改变滚动条滚动的速度!