我想在整个桌面上画一个椭圆,用向导生成单文档框架,添加以下代码后void CDrawView::OnLButtonDown(UINT nFlags, CPoint point) 
{

CRect rect;
CWindowDC dc(NULL);
GetWindowRect(&rect);
dc.Ellipse(rect);}为什么只能在客户区里面画个椭圆,但当我把dc.Ellipse(rect)里的rect
改成(0,0,100,100)时,就可以在桌面画出一个小椭圆了。

解决方案 »

  1.   

    GetWindowRect()得到的是客户区的大小
      

  2.   

    客户区的不是GetClientRect()吗?
      

  3.   

    The GetWindowRect function retrieves the dimensions of the bounding rectangle of the specified window. The dimensions are given in screen coordinates that are relative to the upper-left corner of the screen.
      

  4.   

    GetWindowRect()返回的是屏幕坐标,所以当rect
    改成(0,0,100,100)时,就可以在桌面左上角画出一个小椭圆了
      

  5.   

    GetWindowRect()返回的是屏幕坐标(200,200,600,600);
    即窗口的左上角坐标为屏幕的(200,200)处,所以
    (0,0,100,100)超出窗口范围,就是在屏幕左上角坐标为(0,0)开始画一个小椭圆了
      

  6.   

    GetWindowRect()返回的RECT值是屏幕坐标,也就是所有的left,top等都是相对于屏幕左上角;GetClientRect()返回的RECT的值是客户区坐标,它的left,top等值是相对窗口左上角。你想在桌面上画,可以用GetDesktopWindow()获得桌面窗口,然后就可以用这个窗口的指针来画你想要的任何东东了
      

  7.   

    CWnd *pDeskTop=GetDesktopWindow();
    CDC *pDC=pDeskTop->GetWindowDC();