在 Void MainFrm::OnSize(UINT Type,int cx,int cy){}函数中 cx cy 分别代表的是窗口的尺寸吗? 我想在一个对话框类内读出该尺寸 我该用什么办法饿。。

解决方案 »

  1.   

    CRect rect;
    GetWindowRect(&rect);
    rect.Width()//宽     rect.Heigth()//高
      

  2.   

    rect.Width() 就是cx吗rect.Heigth()就是cy吗?
      

  3.   

    CClient   dc(this)
    dc.GetClientRect().x,
    dc.GetClientRect().y 
      

  4.   

    MSDN:
    cx
    Specifies the new width of the client area.
    cy
    Specifies the new height of the client area.
    应该是GetClientRect
      

  5.   

    不对吧 我现在就想把参数 cx cy的值取出来保存到变量里 然后通过调用变量来实现加减而已。。
      

  6.   

    窗口的尺寸不知道你是指整个窗口还是客户区的尺寸
    整个窗口直接通过GetWindowRect可以获得
    而OnSize中的cx,cy是客户区的尺寸GetClientRect获得
      

  7.   

    我该用什么办法来获取客户区的cx  and cy 呢?
      

  8.   

    测试了一下,好像还是应该GetWindowRect()上一个是客户区的
    CRect rect;
    /*GetClientRect(&rect);*/
    GetWindowRect(rect);
    int width=rect.Width();
    int height=rect.Height();
      

  9.   


    CRect rect;
        GetClientRect(&rect);
        int width=rect.Width();
        int height=rect.Height();
      

  10.   

    CRect rect;
    GetClientRect(&rect);
    int w=rect.Width();
    int h=rect.Height();
    CString str;   
    str.Format("宽=%d,高=%d",w,h);   
    MessageBox(str,"真的",0);
      

  11.   

    问题是这样的 我在主程序中通过 键盘事件触发 对话框 ,我在对话框的OnitDialog()函数里加入了setWindowPos()函数 想通过在OnitDialog()函数计算出主程序的客户端区的尺寸大小,也就是长度和宽度,利用setWindowPos()函数的x y来进行对话框的定位。 不知道这个方法能不能实现如果能的话麻烦大大教下好吗?
      

  12.   


    BOOL SetWindowPos(
      HWND hWnd,             // handle to window
      HWND hWndInsertAfter,  // placement-order handle
      int X,                 // horizontal position
      int Y,                 // vertical position
      int cx,                // width
      int cy,                // height
      UINT uFlags            // window-positioning flags
    );函数都有了,可以了
      

  13.   

    不是函数的问题,这个函数是 设置位置和 对话框大小的 。现在的问题是我想通过它 来定位对话框出现在主程序中的位置 也就是 我活的主程序的长度和宽度后 例如主程序的长度和宽度为 A B
    在setWindowPos()里的 X 处写为 A-30 Y处写为 B-50 那么我每次呼出的对话框就肯定锁定在这个位置上了 不管主窗体的大小如何改变 我都放到这个位置 或者说是 这个点上。如果能实现的话麻烦告诉下好吗?
      

  14.   

    同问,其实就是想让对话框的大小和MFC的白色工作去大小一样,不知道怎么弄 啊。