我用MFC做个界面,想在对话框上面加个导航条样的东西,我想获得对话框横向大小,然后放张图片上去,不知道可以不?有没什么更好的方法?

解决方案 »

  1.   

    在对话框里调用
    CRect rect;
    GetClientRect(rect);
    就可以得到对话框的矩形大小。
      

  2.   

    GetClientRect
    The GetClientRect function retrieves the coordinates of a window's client area. The client coordinates specify the upper-left and lower-right corners of the client area. Because client coordinates are relative to the upper-left corner of a window's client area, the coordinates of the upper-left corner are (0,0). BOOL GetClientRect(
      HWND hWnd,      // handle to window
      LPRECT lpRect   // address of structure for client coordinates
    );typedef struct _RECT { 
        LONG left; 
        LONG top; 
        LONG right; 
        LONG bottom; 
    } RECT; 
      

  3.   

    GetClientRect是得到客户区尺寸
    对于对话框来说,得到的就是除了标题栏、边框以外的区域大小
    如果要获得整个对话框尺寸
    就用GetWindowRect
      

  4.   

    CRect rect;
    this->GetWindowRect(&rect);
    CString s;
    s.Format("width:%d  height:%d",rect.Width(),rect.Height());
    MessageBox(s);
    试了下,这样可以了..