我在对话框上自定义画出了一个坐标系,放两个编辑框准备来实时反应鼠标在坐标中的值
想让鼠标只在坐标系内移动时,才在两个编辑框中显示鼠标的值(x和y轴坐标)
请问怎么办到?

解决方案 »

  1.   

    怎么定义的?SetMapMode SetWindowExtEx SetViewExtEx?
    先DPTOLP然后PtInRect
      

  2.   

    "怎么定义的?SetMapMode SetWindowExtEx SetViewExtEx?
    先DPTOLP然后PtInRect"
    -------------------------------
    我是按SetMapMode SetWindowExtEx SetViewExtEx怎么设的
    接下来呢?DPTOLP 和 PtInRect是什么?
    DPTOLP然后PtInRect具体怎么用
      

  3.   

    pDC->SetMapMode(MM_ANISOTROPIC);
    pDC->SetWindowOrg(X0,Y0);
    pDC->SetWindowExt(X,-Y);
    pDC->SetViewportOrg(0,0);
    pDC->SetViewportExt(rc.Width(),rc.Height());
    我是这么设的。X0=-200  Y0=800
                  X=500    Y=1600
      

  4.   

    The DPtoLP function converts device coordinates into logical coordinates. The conversion depends on the mapping mode of the device context, the settings of the origins and extents for the window and viewport, and the world transformation. The PtInRect function determines whether the specified point lies within the specified rectangle. A point is within a rectangle if it lies on the left or top side or is within all four sides. A point on the right or bottom side is considered outside the rectangle. 
      

  5.   

    大哥不要全写原版啊
    给点注释吗 看不懂
    DPTOLP()参数用什么?
    PtInRect呢
      

  6.   

    CRect rect;// 假如说这是一个矩形区,在这个区内有效
    //这个区域大小由你自已来定void CDialog::OnMouseMove(UINT nFlags,CPoint point)
    {
       CString strText;
       if(rect.PtInRect(point))
       {
          strText.Format("X:%d-Y:%d", point.x, point.y);
          m_Edit.SetWindowText(strText);
       }
    }
      

  7.   

    CString strText;
    CRect rect(0,0,150,1000); 
    if(rect.PtInRect(point))
       {
          strText.Format("X:%d-Y:%d", point.x, point.y);
          edit4.SetWindowText(strText);
       }这样还只是设备的物理坐标,
    不能显示我自定义的逻辑坐标的大小我想知道DPTOLP()参数用什么
      

  8.   

    有谁知道DPTOLP()参数怎么用?
      

  9.   

    你的情况适合用这个重载
    void DPtoLP( LPRECT lpRect ) const;
    lpRect即你的坐标系的区域
    它的作用是把rect指定区域内的设备坐标转化为你指定的逻辑坐标
      

  10.   

    在OnMouseMove函数中:
     CRect rect(0,0,150,3000);     
     DPtoLP(&rect);
       if(rect.PtInRect(point))
       {
          strText.Format("%d", point.x);
          edit4.SetWindowText(strText);
          strText.Format("%d", point.y);
          edit5.SetWindowText(strText);
       }
    提示:error C2660: 'DPtoLP' : function does not take 1 parameters
      

  11.   

    请问 重载
    void DPtoLP( LPRECT lpRect ) const;
    {}  《—函数里面怎么定义?
      

  12.   

    ....
    这个重载函数是CDC的类函数
    比如你当前的dc是pDC
    那要这样pDC.DPtoLP(&rect);