資源簡介
MFC窗口特效之動畫效果,可以應用在一個對話框或者其派生類上,實現動畫打開和動畫關閉效果

代碼片段和文件信息
//?DlgFlash.cpp:?implementation?of?the?CDlgFlash?class.
//
//////////////////////////////////////////////////////////////////////
#include?“stdafx.h“
#include?“CDlgFlash.h“
#ifdef?_DEBUG
#undef?THIS_FILE
static?char?THIS_FILE[]=__FILE__;
#define?new?DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
//?Construction/Destruction
//////////////////////////////////////////////////////////////////////
CDlgFlash::CDlgFlash(CDialog*?Dlg)
{
flashDlg=Dlg;
Timer1_ID=9;
Timer2_ID=10;
InitCDlg();
}
CDlgFlash::CDlgFlash(CDialog*?Dlgint?Timer1_IDint?Timer2_ID)
{
flashDlg=Dlg;
this->Timer1_ID=Timer1_ID;
this->Timer2_ID=Timer2_ID;
InitCDlg();
}
CDlgFlash::~CDlgFlash()
{
}
void?CDlgFlash::InitCDlg(){
//獲得窗口預設的大小
CRect?dlgRect;
flashDlg->GetWindowRect(dlgRect);
//獲取屏幕大小
CRect?desktopRect;
flashDlg->GetDesktopWindow()->GetWindowRect(desktopRect);
//將窗口開始大小設為0,居中
flashDlg->MoveWindow(dlgRect.left?+?dlgRect.Width()?/?2
??dlgRect.top?+?dlgRect.Height()?/?2
???0
???0?
???);
//數據成員初始化
OriginalWidth=dlgRect.Width();
OriginalHeight=dlgRect.Height();
xCreateSpeed=2;
yCreateSpeed=3;
xDestorySpeed=2;
yDestorySpeed=3;
//設定定時器Timer1_ID
flashDlg->SetTimer(Timer1_ID10NULL);
}
void?CDlgFlash::OnTimer(UINT?nIDEvent){
{
//獲得此時窗口的實際大小
CRect?dlgRect;
flashDlg->GetWindowRect(&dlgRect);
//獲得桌面的大小
CRect?desktopRect;
flashDlg->GetDesktopWindow()->GetWindowRect(desktopRect);
//如果是窗口彈出過程,窗口居中,逐漸增大窗口
if(nIDEvent?==Timer1_ID)
{
flashDlg->MoveWindow(
??(desktopRect.Width()?-?dlgRect.Width())?/?2
??(desktopRect.Height()?-?dlgRect.Height())?/?2?
??xCreateSpeed+dlgRect.Width()
??yCreateSpeed+dlgRect.Height()?
??);
//不要超過窗口預設的寬度
if(dlgRect.Width()?>=OriginalWidth)?
xCreateSpeed=0;?
//不要超過窗口預設的高度
if(dlgRect.Height()?>=OriginalHeight)
yCreateSpeed=0;
//停止變化,關閉定時器Timer1_ID
if((dlgRect.Width()?>=OriginalWidth)?&&?(dlgRect.Height()?>=OriginalHeight))
flashDlg->KillTimer(Timer1_ID);?
}
//如果是窗口關閉過程,則逐漸縮小窗口
if(nIDEvent?==?Timer2_ID)
{
flashDlg->MoveWindow(DestoryPosX
DestoryPosY?
dlgRect.Width()
dlgRect.Height()-yDestorySpeed
);
//當高度等于零后高度就不在變化
//if(dlgRect.Height()?<=0)
?
//停止變化,關閉定時器Timer2_ID,并且關閉窗口
if(dlgRect.Height()?<=0)
{
yDestorySpeed=0;
flashDlg->KillTimer(Timer1_ID);
flashDlg->DestroyWindow();
}
}
}
}
void?CDlgFlash::StartFlashDestroyDlg(){
CRect?dlgRect;
//獲取窗口當前的位置并保存
flashDlg->GetWindowRect(&dlgRect);
DestoryPosX=dlgRect.left;
DestoryPosY=dlgRect.top;
//開始啟動定時器Timer2_ID
flashDlg->SetTimer(Timer2_ID10NULL);
}
void?CDlgFlash::SetFlashCreateSpeed(int?xint?y){
xCreateSpeed=x;
xCreateSpeed=y;
}
void?CDlgFlash::SetFlashDestroySpeed(int?y){
yDestorySpeed=y;
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????3104??2010-04-02?15:18??FileHandler\CDlgFlash.cpp
?????文件???????1763??2010-04-01?15:17??FileHandler\CDlgFlash.h
?????文件??????37620??2010-04-02?15:17??FileHandler\copyfile.aps
?????文件???????1858??2010-04-02?15:48??FileHandler\copyfile.clw
?????文件???????2196??2010-03-30?12:30??FileHandler\copyfile.cpp
?????文件???????4326??2010-03-31?13:46??FileHandler\copyfile.dsp
?????文件????????541??2010-03-28?18:03??FileHandler\copyfile.dsw
?????文件???????1346??2010-03-28?18:03??FileHandler\copyfile.h
?????文件??????99328??2010-04-02?15:48??FileHandler\copyfile.ncb
?????文件??????55808??2010-04-02?15:48??FileHandler\copyfile.opt
?????文件???????1648??2010-04-02?15:48??FileHandler\copyfile.plg
?????文件???????5876??2010-04-02?15:17??FileHandler\copyfile.rc
?????文件??????10591??2010-04-02?15:48??FileHandler\copyfileDlg.cpp
?????文件???????1952??2010-04-02?15:13??FileHandler\copyfileDlg.h
?????文件???????9707??2010-04-02?15:18??FileHandler\Debug\CDlgFlash.obj
?????文件??????????0??2010-04-02?15:18??FileHandler\Debug\CDlgFlash.sbr
?????文件????3654656??2010-04-02?15:18??FileHandler\Debug\copyfile.bsc
?????文件?????118876??2010-04-02?15:18??FileHandler\Debug\copyfile.exe
?????文件?????296664??2010-04-02?15:18??FileHandler\Debug\copyfile.ilk
?????文件??????14986??2010-04-02?15:13??FileHandler\Debug\copyfile.obj
?????文件????6880400??2010-04-01?14:44??FileHandler\Debug\copyfile.pch
?????文件?????427008??2010-04-02?15:18??FileHandler\Debug\copyfile.pdb
?????文件???????4072??2010-04-02?15:17??FileHandler\Debug\copyfile.res
?????文件??????????0??2010-04-02?15:13??FileHandler\Debug\copyfile.sbr
?????文件??????54828??2010-04-02?15:16??FileHandler\Debug\copyfileDlg.obj
?????文件??????????0??2010-04-02?15:16??FileHandler\Debug\copyfileDlg.sbr
?????文件?????105770??2010-04-01?14:44??FileHandler\Debug\StdAfx.obj
?????文件????1369712??2010-04-01?14:44??FileHandler\Debug\StdAfx.sbr
?????文件?????205824??2010-04-02?15:18??FileHandler\Debug\vc60.idb
?????文件?????372736??2010-04-02?15:18??FileHandler\Debug\vc60.pdb
............此處省略21個文件信息
- 上一篇:遺傳算法解八數碼問題
- 下一篇:mfc按CEdit編輯框彈出自定義鍵盤
評論
共有 條評論