怎样根据窗口的Rect变量判断窗口的大小??

解决方案 »

  1.   

    CRect rc;
    GetWindowRect(&rc);
      

  2.   

    感谢两位!!
    可能是我说的不清楚了……
    我是说如果要判断两个窗口哪个大,是不是可以用这样的语句:if(Rect1>Rect2)
    初学,笑话啦^_^
      

  3.   

    你可以比较两个窗口的宽度和高度啊
    if( Rect1.GetWidth() > Rect2.GetWidth() )
      //...if( Rect1.GetHeight() > Rect2.GetHeight() )
      //...
      

  4.   

    CRect里原来没有“>”这个运算符的,如果要用你必须自定义类并重载大于运算符,重载函数大概这样:
    BOOL CMyRect::operator > (const CRect& Rect2)
    {
    int Area1 = Width() * Height();
    int Area2 = Rect21.Width() * Rect2.Height();
    if (Area1 > Area2)
        return TRUE;
    else
        return FALSE;
    }
      

  5.   

    int Area2 = Rect21.Width() * Rect2.Height();笔误应为:int Area2 = Rect2.Width() * Rect2.Height();
    懂了吗。
      

  6.   

    测试代码:
    CMyRect rect1;
    rect1.left =10;
    rect1.right =110;
    rect1.top =10;
    rect1.bottom =110; CRect rect2(0, 10, 110, 110);
    if (rect1 > rect2)
    AfxMessageBox("rect1 > rect2");
             else
    AfxMessageBox("rect1 < rect2");
      

  7.   

    感谢 zpj888(VC) 、 cgsmarter(享受每天) 两位大侠!!
    我知道怎么做了