MFC 控件的最大化

来源:互联网 发布:jquery each 数组 编辑:程序博客网 时间:2024/06/10 01:41

网络上由于多相关文章,但是我完成后想自己总结一份

if (cx==0||cy==0)//初始化
    {
        cx=800;
        cy=600;
    }

    float dx_percent=(m_old_cx==0)?1:(float)((float)cx/(float)m_old_cx);//变化率
    float dy_percent=(m_old_cy==0)?1:(float)((float)cy/(float)m_old_cy);

    if (m_old_cx)
    {
        CRect wndrect;
        CWnd *pwnd;
        int ictrlid;
        CWnd *pchile=GetWindow(GW_CHILD);


        while (pchile)//循环窗体上的所有控件
        {
            ictrlid=pchile->GetDlgCtrlID();

            pwnd=GetDlgItem(ictrlid);
            pwnd->GetWindowRect(&wndrect);
            ScreenToClient(&wndrect);
            wndrect.right=(int)(wndrect.right*dx_percent);
            wndrect.left=(int)(wndrect.left*dx_percent);
            wndrect.bottom=(int)(wndrect.bottom*dy_percent);
            wndrect.top=(int)(wndrect.top*dy_percent);
            pwnd->MoveWindow(&wndrect);

            pchile=pchile->GetWindow(GW_HWNDNEXT);

        }


        //tab子窗口大小,要特殊处理,但是子窗口可以看做控件

           pwnd = GetDlgItem( IDC_TAB2 );


        if ( NULL != pwnd )

        {
        CRect CrTab;
        m_tab.GetClientRect(&CrTab);//得到父对话框的位置

        CrTab.top+=20;
        CrTab.left+=0;
        CrTab.bottom-=0;
        CrTab.right-=0;
        page1.MoveWindow(&CrTab);
        page2.MoveWindow(&CrTab);


        }
    }
  m_old_cx=cx;
 m_old_cy=cy;

 

原创粉丝点击