希望在CScroolView中连续的输出图形,并且要求能连续查看所有的该次任务的所有历史输出,但是当坐标值超出32767时,绘图便出现问题。对此MDSN的解释是
Note   Under Windows 95, all screen coordinates are limited to 16 bits. Therefore, an int passed to a CDC member function must lie in the range –32768 to 32767.
我用的是VC++6,操作系统是XP,不是95啊,怎么也有这个限制!!在StdAfx.h中预定义
#ifndef  WINVER
#define  WINVER  0x0500
#endif
#ifndef  _WIN32_WINNT
#define _WIN32_WINNT 0x0500
#endif#ifndef _WIN32_WINDOWS
#define _WIN32_WINDOWS 0x0500
#endif还是不行,请教各位高手,能否给个解决的办法???

解决方案 »

  1.   

    The limits of the logical coordinate system are from -32768 to +32767. An item can be drawn anywhere within this coordinate system; however, the window extent cannot be set to greater than 32767. (Although this might seem to limit the system to the -16384 to 16383 range, this is not the case.) If the viewport and window are set up properly, everything will be shown. For example, to set up the whole logical coordinate system to be shown within the application's area of the screen, the following code works properly:    /*  Establish viewport to be upper-left quarter of client area */    GetClientRect(hWnd, (LPRECT) &CRect);
       SetViewportOrg(hDC, 0, 0);
       SetViewportExt(hDC, (CRect.right - CRect.left) / 2, \                       (CRect.bottom - CRect.top) / 2);   /*  Set Window Origin and Extent such that total logical */ 
       /*     coordinate system will cover entire client area   */    SetWindowOrg(hDC, -32767, -32767);
       SetWindowExt(hDC, 32767, 32767);
      

  2.   

    When the following mapping modes are set, calls to SetWindowExt and SetViewportExt are ignored:MM_HIENGLISH 
    MM_LOMETRIC 
    MM_HIMETRIC 
    MM_TEXT 
    MM_LOENGLISH 
    MM_TWIPS Two standard mapping modes, MM_ISOTROPIC and MM_ANISOTROPIC, are not used for CScrollView. 我的CScroolView的mapmode是MM_TEXT,所以不能使用SetViewExt()和SetWindowExt
      

  3.   

    我也有过类似的问题,其实MSDN写了的。用下面的函数得出真的值。
    CWnd::GetScrollInfo(SB_HORZ,&info);
    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. 
      

  4.   

    刚好我也遇到类似的问题,搭车问一下:
    MSDN里说MM_ISOTROPIC 不支持CScrollView,
    但我现在因为精度和坐标系问题想在MM_ISOTROPIC模式下绘图,又想使用滚动条,有没有办法解决?
      

  5.   

    这个问题,CScrollView确实存在。 
    要解决,我的办法是 生成自己的  CScrollView类,主要代码可以直接拷贝过来, 主要修改:对滚动条的控制主要用了GetPos/SetPos. 这个函数只支持 16位POS值,要改为:
    GetScrollInfo, SetScollInfo.函数主要要修改 UpdateScrollBar 和对滚动条消息的响应。 OnScrollBy  等函数。通过这样的修改,确实可以将滚动范围扩展到32值,但是CDC好象也不支持32位的坐标, 所以绘图的时候要自己计算偏移量,并在合适的位置绘图。这样处理后,就能实现32位的坐标了。 
      

  6.   

    我完的图的值都是几万几万的,好像也没事,可能是我用的是MM_ISOTROPIC模式吧。
    你试试这样画:int PRECISION=1000;//精度,你自己随便设,现在是1000:1
    pDC->SetMapMode(MM_ISOTROPIC);
    pDC->SetWindowOrg(0,0);
    pDC->SetWindowExt(PRECISION,PRECISION);
    pDC->SetViewportExt(1,1);pDC->LineTo(100*PRECISION,200*PRECISION);
    pDC->Rectangle(300*PRECISION,300*PRECISION,500*PRECISION,500*PRECISION);
    pDC->TextOut(200*PRECISION,200*PRECISION,"Xzdfgdgsdgdfg");PRECISION是设置的精度,这样你逻辑坐标输出1000个点,设备DC只输出一个点的长度,相当于把图像缩小了。如果把SetWindowExt和SetViewportExt的值换一下则起到相反的效果,但这样精度就低了(相当于把图像放大了)。我都是用这种方式画的图,几万都没关系。
    VC中int是4个字节的,范围应该在-2^31到+2^31之间,应该足够你画图了~