我想实现这样的功能:在对话框中用静态文本框显示一段文字,然后在对框上设置一个水平滚动条控制这段文字的左右滚动。问题是:滚动条是动起来了,但这段文字没有滚动起来。我将这个水平滚动条与一个CScrollBar类的对象m_scrollBarHorizontal关联起来,并用下面这条函数初始化了这个滚动条:
////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CEasyScrollBarDlg::InitHScrollBar()
{ SCROLLINFO scrollInfo; scrollInfo.cbSize=sizeof(SCROLLINFO);
scrollInfo.fMask=SIF_ALL;
scrollInfo.nMax=100;
scrollInfo.nMin=0;
scrollInfo.nPage=10;
scrollInfo.nPos=0;
scrollInfo.nTrackPos=0; m_scrollBarHorizontal.SetScrollInfo(&scrollInfo);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
我在OnHScroll()函数中给出的是在MSDN中的sample代码。(在MSDN中键入OnHScroll就可以查到)(VC6.0)加入的代码如下:
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CEasyScrollBarDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
{
// TODO: Add your message handler code here and/or call default
   int minpos;
   int maxpos;   pScrollBar->GetScrollRange(&minpos, &maxpos); 
   maxpos = pScrollBar->GetScrollLimit();   // Get the current position of scroll box.
   int curpos = pScrollBar->GetScrollPos();   // Determine the new position of scroll box.
   switch (nSBCode)
   {
   case SB_LEFT:      // Scroll to far left.
      curpos = minpos;
      break;   case SB_RIGHT:      // Scroll to far right.
      curpos = maxpos;
      break;   case SB_ENDSCROLL:   // End scroll.
      break;   case SB_LINELEFT:      // Scroll left.
      if (curpos > minpos)
         curpos--;
      break;   case SB_LINERIGHT:   // Scroll right.
      if (curpos < maxpos)
         curpos++;
      break;   case SB_PAGELEFT:    // Scroll one page left.
   {
      // Get the page size. 
      SCROLLINFO   info;
      pScrollBar->GetScrollInfo(&info, SIF_ALL);
   
      if (curpos > minpos)
      curpos = max(minpos, curpos - (int) info.nPage);
   }
      break;   case SB_PAGERIGHT:      // Scroll one page right.
   {
      // Get the page size. 
      SCROLLINFO   info;
      pScrollBar->GetScrollInfo(&info, SIF_ALL);      if (curpos < maxpos)
         curpos = min(maxpos, curpos + (int) info.nPage);
   }
      break;   case SB_THUMBPOSITION: // Scroll to absolute position. nPos is the position
      curpos = nPos;      // of the scroll box at the end of the drag operation.
      break;   case SB_THUMBTRACK:   // Drag scroll box to specified position. nPos is the
      curpos = nPos;     // position that the scroll box has been dragged to.
      break;
   }   // Set the new position of the thumb (scroll box).
   pScrollBar->SetScrollPos(curpos);
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////请问有什么解决的方法呢?