设为首页 加入收藏

TOP

VC???????Ч?????
2013-09-26 19:37:13 来源: 作者: 【 】 浏览:96
Tags:

Ч У С Ч 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();

}

}

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇VC实现将对话框最小化到托盘 下一篇vc中将IP转换为域名

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: