如何让对话框最大化时,其上的List控件适应对话框的尺寸!谢谢

解决方案 »

  1.   

    CRECT rect;GetClientRect(&rect);然后MoveWindow(&rect);
      

  2.   

    重载OnSize()函数,比如List控件和对话框的大小完全一致.
    void CTestDlg::OnSize(UINT nType, int cx, int cy) 
    {
    CDialog::OnSize(nType, cx, cy);
    m_list.MoveWindow(0,0,cx,cy,TRUE);
    }
      

  3.   

    to:xindao_wang(nike) 
    用你的方法,运行时出现错误提示,忽略后,可用;但最大化后还原Dialog时,控件尺寸不变, 怎么办?
      

  4.   

    重载OnSize()函数,比如List控件和对话框的大小完全一致.
    void CTestDlg::OnSize(UINT nType, int cx, int cy) 
    {
    CDialog::OnSize(nType, cx, cy);
             if(cx>0&&cy>0)
    m_list.MoveWindow(0,0,cx,cy,TRUE);
    }
      

  5.   

    处理WM_SIZE消息,因为窗口大小发生变化时回调用这个函数,你可以使用
    CRect rect;
    GetClientRect(&rect);
    m_List.MoveWindow(rect,TRUE);
    或者
    m_List.MoveWindow(CRect(0,0,cx,cy),TRUE);
      

  6.   

    在OnSize()里写这个函数,程序运行报错!
             if(GetDlgItem(IDC_LIST1)->m_hWnd)
    {

    CRect theRect;
             GetClientRect(&theRect);
    theRect.left=theRect.left+7;
    theRect.top=theRect.top+7;
    theRect.bottom=theRect.bottom-7;
    theRect.right=theRect.right-7;
    GetDlgItem(IDC_LIST1)->MoveWindo(&theRect,true); }
    怎么办????
      

  7.   

    在OnSize()里写这个函数
    CWnd *myWnd;
    myWnd=GetDlgItem(IDC_LIST1);
             if(myWnd)
    {

    CRect theRect;
             GetClientRect(&theRect);
    theRect.left=theRect.left+7;
    theRect.top=theRect.top+7;
    theRect.bottom=theRect.bottom-7;
    theRect.right=theRect.right-7;
    GetDlgItem(IDC_LIST1)->MoveWindo(&theRect,true); }
      

  8.   

    在窗口最大化的时候,我怎么改变Button控件的位置?