CWnd *pWnd=GetDlgItem(IDC_STATIC_T);
pWnd->Invalidate();
pWnd->UpdateWindow();
CDC *pDC = pWnd->GetDC();
pDC->Rectangle(0, 0,580,660);//矩形外框      CPen *pPenRed = new CPen(); //创建画笔对象
    CGdiObject *pOldPen = pDC ->SelectObject(pPenRed); //选中当前红色画笔,并保存以前的画笔        pDC ->MoveTo(40, 20); //绘制坐标轴
pDC ->LineTo(40, 620); //竖起轴
pDC ->LineTo(540,620); //水平轴

解决方案 »

  1.   

    void CXqDlg::OnMouseMove(UINT nFlags, CPoint point) 
    {
      
    }我想问下这个OnMouseMove里面的point坐标,是相对于哪个的,我怎么把这个坐标转换到我这个坐标系里面来
      

  2.   

    pointSpecifies the x- and y-coordinate of the cursor. These coordinates are always relative to the upper-left corner of the window.
      

  3.   

     These coordinates are always relative to the upper-left corner of the window.
      

  4.   

    Coordinate Space and Transformation Functions
    The following functions are used with coordinate spaces and transformations.   
     
    ClientToScreen  
    CombineTransform  
    DPtoLP  
    GetCurrentPositionEx  
    GetGraphicsMode  
    GetMapMode  
    GetViewportExtEx  
    GetViewportOrgEx  
    GetWindowExtEx  
    GetWindowOrgEx  
    GetWorldTransform  
    LPtoDP  
    MapWindowPoints  
    ModifyWorldTransform  
    OffsetViewportOrgEx  
    OffsetWindowOrgEx  
    ScaleViewportExtEx  
    ScaleWindowExtEx  
    ScreenToClient  
    SetGraphicsMode  
    SetMapMode  
    SetViewportExtEx  
    SetViewportOrgEx  
    SetWindowExtEx  
    SetWindowOrgEx  
    SetWorldTransform  
     
      

  5.   

    void CXqTestDlg::OnMouseMove(UINT nFlags, CPoint point) 
    {
        CRect rct;
    GetDlgItem(IDC_STATIC_T)->GetWindowRect(rct);  //GetWindowRect函数是获取控件坐标 相对于屏幕左上角 
        
    rct.TopLeft().x+=110;
        rct.TopLeft().y+=30;
        rct.BottomRight().x=rct.TopLeft().x+500;
    rct.BottomRight().y=rct.TopLeft().y+600;

    CPoint pt;
        GetCursorPos(&pt);  //GetCursorPos获取光标在屏幕坐标中的位置
    if(PtInRect(&rct,pt))  //PtInRect函数是Point是否在Rect内(点是否在矩形区域内)
    {
       HCURSOR hCur = LoadCursor(NULL,IDC_CROSS);
                    ::SetCursor(hCur);
       float zx,zy;
       zx=(300.0/497.0)*point.x-588.83;
       zy=(-600.0/598.0)*point.y+608.026;
       m_x.Format("%.2f",zx);
       m_y.Format("%.2f",zy);
       UpdateData(FALSE);
    }
    else
    {
         HCURSOR hCur = LoadCursor(NULL,IDC_ARROW);
                    ::SetCursor(hCur);
    }
    CDialog::OnMouseMove(nFlags, point);
    }这是我的OnMouseMove语句,在我的电脑上可以把坐标输出的很准,可是同样的程序换了台电脑就不行了,坐标输出的右乱了
      

  6.   

    rct.TopLeft().x+=110;
        rct.TopLeft().y+=30;
        rct.BottomRight().x=rct.TopLeft().x+500;
    rct.BottomRight().y=rct.TopLeft().y+600;zx=(300.0/497.0)*point.x-588.83;
       zy=(-600.0/598.0)*point.y+608.026;这么多立即数 ,与 电脑 有关 !
      

  7.   

    不如 IDC_STATIC_T 派生为 你的 Static
      

  8.   

    @ schlafenhamster        您好,接触没多久,你说的“不如 IDC_STATIC_T 派生为 你的 Static”“  没有理解,能指个方向怎么弄么
      

  9.   

    1 加一个新类
    class CMyStatic : public CStatic
    2. IDC_STATIC_T 的关联 改为 CMyStatic