用MFC向导创建的模态对话框,请问如何在程序中定义对话框的大小,比如我想要640*480大小的窗口怎么实现?

解决方案 »

  1.   

    CWnd::SetWindowPos
    BOOL SetWindowPos( const CWnd* pWndInsertAfter, int x, int y, int cx, int cy, UINT nFlags );wndBottom   Places the window at the bottom of the Z-order. If this CWnd is a topmost window, the window loses its topmost status; the system places the window at the bottom of all other windows.
    wndTop   Places the window at the top of the Z-order.
    wndTopMost   Places the window above all nontopmost windows. The window maintains its topmost position even when it is deactivated.
    wndNoTopMost   Repositions the window to the top of all nontopmost windows (that is, behind all topmost windows). This flag has no effect if the window is already a nontopmost window. 例如:
    SetWindowPos(&wndTop,0,0,641,480,
    SWP_DRAWFRAME);
    将创建一个640X480的顶层窗口!
      

  2.   

    sorry!
    SetWindowPos(&wndTop,0,0,640,480,
    SWP_DRAWFRAME);
      

  3.   


    5. 如何动态放大/缩小对话框
    还是可以用SetWindowPos或MoveWindow来实现它。void CTest_deleteDlg::OnMakeSmall() 
    {
        SetWindowPos(NULL,0,0,200,200,SWP_NOZORDER|SWP_NOMOVE);
    }void CTest_deleteDlg::OnExpand() 
    {
        SetWindowPos(NULL,0,0,500,300,SWP_NOZORDER|SWP_NOMOVE);
    }或://伸、缩在IDC_DYCREDITS和IDC_COPYRIGHT两STATIC控件间,做为分隔线
    BOOL CAbout::OnInitDialog() 
    {
    CDialog::OnInitDialog();
    //"关于"对话框中对话框可收缩效果
    CRect Rect1,Rect2;       //对话框收缩时大小

    GetDlgItem(IDC_DYCREDITS)->GetWindowRect(Rect1); 
    GetDlgItem(IDC_COPYRIGHT)->GetWindowRect(Rect2); 
    m_nReducedHeight = Rect1.Height()+(Rect1.top -Rect2.bottom)/2; //收缩后窗体高度
    dlgRect.bottom -= (Rect1.Height()+(Rect1.top -Rect2.bottom)/2); 
    MoveWindow(&dlgRect);               //如果要显示对话框起始动态效果的话,不能使用该句 m_bVertical=false;                                //默认收缩对话框
    }
    // ---------------------------------------------------------
    // 名称: OnMore
    // 功能: 是否允许显示
    // 变量: 无
    // 返回: 无
    // 编写: 徐景周,2002.4.8
    // ---------------------------------------------------------
    void CAbout::OnMore() 
    {
    m_bVertical = !m_bVertical; 

    if(m_bVertical == FALSE) //不显示

    SetDlgItemText(ID_MORE,_T("更多>>")); SizeWindow(m_nReducedHeight,true);// m_DyCredits.EndScrolling();              //停止滚动

    else //显示

    SetDlgItemText(ID_MORE,_T("<<隐藏")); SizeWindow(m_nReducedHeight,false); m_DyCredits.StartScrolling(); //开始滚动


    UpdateWindow(); 
    }// ---------------------------------------------------------
    // 名称: SizeWindow
    // 功能: 伸展或收缩对话框    
    // 变量: ReduceHeight-收缩高度,bExtend-是否伸展
    // 返回: 无
    // 编写: 徐景周,2002.4.8
    // ---------------------------------------------------------
    void CAbout::SizeWindow(int ReduceHeight, bool bExtend)
    {
    CRect rc;
    GetWindowRect(&rc);
    if(bExtend)
    {
    for (int i= 0; i < ReduceHeight; i++)
    {
    rc.bottom--;
    MoveWindow(&rc);
    }
    }
    else
    {
    for (int i= 0; i < ReduceHeight; i++)
    {
    rc.bottom++;
    MoveWindow(&rc);
    }
    }

      

  4.   

    例如:
    BOOL CAboutDlg::OnInitDialog() 
    {
    CDialog::OnInitDialog();

    // TODO: Add extra initialization here
    SetWindowPos(&wndTop,0,0,1024,768,
    SWP_DRAWFRAME); return TRUE;  // return TRUE unless you set the focus to a control
                  // EXCEPTION: OCX Property Pages should return FALSE
    }
    创建一个最大化窗口----当然是指17寸显示器
      

  5.   

    BOOL CAboutDlg::OnInitDialog() 
    {
    CDialog::OnInitDialog();

    // TODO: Add extra initialization here
    SetWindowPos(&wndTop,0,0,640,480,
    SWP_DRAWFRAME); return TRUE;                 }
      

  6.   

    SetWindowPos(&wndTop,0,0,640,480,
    SWP_DRAWFRAME);
    gz!!!!!!!!!
      

  7.   

    use SetWindowPos(.....)
    the parameters can be checked up from the MSDN
    or just the same with the upper