我用的是mfc中的cscrollbar类,在用setscrollinfo()设定了范围后,只能滚动到32767的长度,要是数据再长就拖不动了,msdn中说范围能达到32位,怎样设定能使滚动的范围达到32位呢。高手最好能给源程序例子哈。

解决方案 »

  1.   

    http://topic.csdn.net/t/20030321/21/1561576.html重载OnVScroll函数,使用   GetScrollInfo()获取nPos的32位数值,   以下代码不完整,应该只处理
    SB_THUMBTRACK   和   SB_THUMBPOSITION   void   CXXXView::OnVScroll(UINT   nSBCode,   UINT   nPos,   CScrollBar*   pScrollBar)   
    {
    SCROLLINFO   ScrollInfo;
    GetScrollInfo(SB_VERT,   &ScrollInfo,   SIF_TRACKPOS);
    nPos   =   ScrollInfo.nTrackPos;CScrollView::OnVScroll(nSBCode,   nPos,   pScrollBar);
    }
      

  2.   

    MSDN里的解释:Note that the WM_HSCROLL message carries only 16 bits of scroll box position data. Thus, applications that rely solely on WM_HSCROLL (and WM_VSCROLL) for scroll position data have a practical maximum position value of 65,535. However, because the SetScrollInfo, SetScrollPos, SetScrollRange, GetScrollInfo, GetScrollPos, and GetScrollRange functions support 32-bit scroll bar position data, there is a way to circumvent the 16-bit barrier of the WM_HSCROLL and WM_VSCROLL messages. See GetScrollInfo for a description of the technique
      

  3.   

    To get the 32-bit position of the scroll box (thumb) during a SB_THUMBTRACK request code in a WM_HSCROLL or WM_VSCROLL message, call GetScrollInfo with the SIF_TRACKPOS value in the fMask member of the SCROLLINFO structure. The function returns the tracking position of the scroll box in the nTrackPos member of the SCROLLINFO structure. This allows you to get the position of the scroll box as the user moves it. The following sample code illustrates the technique.Hide ExampleSCROLLINFO si;
    case WM_HSCROLL:
        switch(LOWORD(wparam)) {
            case SB_THUMBTRACK:
              // Initialize SCROLLINFO structure
     
                ZeroMemory(&si, sizeof(si));
                si.cbSize = sizeof(si);
                si.fMask = SIF_TRACKPOS;
     
              // Call GetScrollInfo to get current tracking 
              //    position in si.nTrackPos
     
                if (!GetScrollInfo(hwnd, SB_HORZ, &si) )
                    return 1; // GetScrollInfo failed
                break;
            .
            .
            .
        }
      

  4.   

    msdn中的例子我看过了,可是设了在数据量加到到32767以上时就会出现拖不动的情况,对于API中的GetScrollInfo(hwnd,  SB_HORZ,  &si),我不是很会用,主要时hwnd不知道怎么设,谢谢指导
      

  5.   

    上一次我的可能没有说清楚啊,是这样的,我的图像大小是8000*3000的,还要有放大的功能,如8倍吧,这样放大的话,我重载滚动条的函数,里面的SB_LONEUP,SB_LINEDOWN,SB_PAGEUP,SB_PAGEDOWN都是正常的,可用的,可是就是S_THUMBPOSITION,SB_THUMBTRACK这两个拉到一定的时候就会回到初始的位置,我都有用SetScrollInfo重设过的,这是怎么问题呢?
      

  6.   

    自已根据图像大小和当前位置来计算出pos,并且调用SetScrollPos或SetScrollInfo