Ч У С Ч MoveWindow(); OnTimer();
:
int m_nWidth,m_nHeight;
int m_nDx,m_nDy;
int m_nDx1,m_nDy1;
CMyDlg::OnInitDialog() м , Ч
CRect dlgRect;
GetWindowRect(dlgRect);
CRect desktopRect;
GetDesktopWindow()->GetWindowRect(desktopRect);
MoveWindow((desktopRect.Width()-dlgRect.Width())/2,(desktopRect.Height()-dlgRect.Height())/2,0,0);
m_nWidth=dlgRect.Width();
m_nHeight=dlgRect.Height();
m_nDx=6;
m_nDy=8;
m_nDx1=6;
m_nDy1=6;
SetTimer(1,10,NULL);
CMyDlg::OnClose() м Ч
SetTimer(2,10,NULL);
OnClose() У CDialog::OnClose();
ú CMyDlg::OnTimer(UINT nIDEvent)
CRect dlgRect;
GetWindowRect(dlgRect);
CRect desktopRect;
GetDesktopWindow()->GetWindowRect(desktopRect);
if(nIDEvent==1)
{
MoveWindow((-m_nDx+desktopRect.Width()-dlgRect.Width())/2,(-m_nDy+desktopRect.Height()-dlgRect.Height())/2,+m_nDx+dlgRect.Width(),+m_nDy+dlgRect.Height());
if(dlgRect.Width()>=m_nWidth)
m_nDx=0;
if(dlgRect.Height()>=m_nHeight)
m_nDy=0;
if((dlgRect.Width()>=m_nWidth)&&(dlgRect.Height()>=m_nHeight))
KillTimer(1);
}
if((dlgRect.Width()>=m_nWidth)&&(dlgRect.Height()>=m_nHeight))
KillTimer(1);
if(nIDEvent==2)
{
MoveWindow((+m_nDx+desktopRect.Width()-dlgRect.Width())/2,(+m_nDy+desktopRect.Height()-dlgRect.Height())/2,-m_nDx1+dlgRect.Width(),-m_nDy1+dlgRect.Height());
if(dlgRect.Width()<=0)
m_nDx1=0;
if(dlgRect.Height()<=0)
m_nDy1=0;
if((dlgRect.Width()<=0)&&(dlgRect.Height()<=0))
{
KillTimer(2);
CDialog::OnOK();
}
}