如何用键盘滚动分割的视口?

清泛编译
81. 如何用键盘滚动分割的视口?

我的问题是当我用鼠标滚动分割窗口时,视口滚动都很正常,但用键盘时,却什么也没有发生.
在你的视图继承类中加入如下两个函数,假定该类为CScrollerView:
void CScrollerView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
    BOOL processed;
    for (unsigned int i=0;i< nRepCnt&&processed;i++)
        processed=KeyScroll(nChar);
    if (!processed)
      CScrollView::OnKeyDown(nChar, nRepCnt, nFlags);
}
BOOL CScrollerView::KeyScroll(UINT nChar)
{
    switch (nChar)
        {
        case VK_UP:
            OnVScroll(SB_LINEUP,0,NULL);
            break;
        case VK_DOWN:
            OnVScroll(SB_LINEDOWN,0,NULL);
            break;
        case VK_LEFT:
            OnHScroll(SB_LINELEFT,0,NULL);
            break;
        case VK_RIGHT:
            OnHScroll(SB_LINERIGHT,0,NULL);
            break;
        case VK_HOME:
            OnHScroll(SB_LEFT,0,NULL);
            break;
        case VK_END:
            OnHScroll(SB_RIGHT,0,NULL);
            break;
        case VK_PRIOR:
            OnVScroll(SB_PAGEUP,0,NULL);
            break;
        case VK_NEXT:
            OnVScroll(SB_PAGEDOWN,0,NULL);
            break;
        default:
            return FALSE; // not for us
               // and let the default class
               // process it.
        }
  return TRUE;
}

本文导航

MFC 总结 技巧

分享到:
评论加载中,请稍后...
App Inventor 2 中文网,少儿编程首选平台!
回到顶部