对话框变化有关问题?最大最小还原,你来回答

对话框变化问题?最大最小还原,在线等你来回答!
在对话框初始化时 GetClientRect(&m_OldRect);

ShowWindow(SW_MAXIMIZE);//使程序进来时对话框最大话
写了个方法:用于调整控件变化
void CEmpDataMa::updateIDRect(CRect m_oldrect,int cx,int cy)
{


CWnd *pWnd; 
int idc[10]={IDC_BTN_EmpBack,IDC_CHECK_ChangePassword,IDC_CHECK_EmpInfos,IDC_CHECK_EmpOut,IDC_CHECK_SetBumen,IDC_CHECK_SetSysD,
IDC_CHECK_ShuokaDa,IDC_CHECK_Time_shuoka,IDC_STATIC_EmpMFunc,IDC_STATIC_ChildDlgPic};
int i,num =10 ;

for(i=0;i<=num;i++)
{
pWnd = GetDlgItem(idc[i]);
if(pWnd)
{
CRect rect; //获取控件变化前的大小
pWnd->GetWindowRect(&rect);
ScreenToClient(&rect);//将控件大小转换为在对话框中的区域坐标
rect.left=rect.left*cx/m_oldrect.Width();/////调整控件大小
rect.right=rect.right*cx/m_oldrect.Width();
rect.top=rect.top*cy/m_oldrect.Height();
rect.bottom=rect.bottom*cy/m_oldrect.Height();
pWnd->MoveWindow(rect);//设置控件大小
}
}

}

void CEmpDataMa::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
/*if (cx==0||cy==0)
{
cx = 800;
cy = 600;
}*/
updateIDRect(m_OldRect,cx,cy);
GetClientRect(&m_OldRect);
}
现在的问题是:最大化可以,我点击最小化时,会停在屏幕的左下方,当我在点击还原原来大小时会出错。

有哪位高手可以纠正一下????

------解决方案--------------------
“停在屏幕的左下方”貌似是因为程序没有在任务栏上显示吧
------解决方案--------------------
重新编写下“还原”的代码:发送一个RESTORE的消息
------解决方案--------------------
http://www.codeproject.com/KB/dialog/RPResizeDlg.aspx
------解决方案--------------------
CWnd::OnSize
afx_msg void OnSize( UINT nType, int cx, int cy );

Parameters

nType

Specifies the type of resizing requested. This parameter can be one of the following values: 

SIZE_MAXIMIZED Window has been maximized.


SIZE_MINIMIZED Window has been minimized.


SIZE_RESTORED Window has been resized, but neither SIZE_MINIMIZED nor SIZE_MAXIMIZED applies.


SIZE_MAXHIDE Message is sent to all pop-up windows when some other window is maximized.


SIZE_MAXSHOW Message is sent to all pop-up windows when some other