-
大小: 4.94MB文件類型: .rar金幣: 2下載: 1 次發(fā)布日期: 2023-08-15
- 語言: C/C++
- 標(biāo)簽:
資源簡(jiǎn)介
MFC窗口特效之動(dòng)畫效果,可以應(yīng)用在一個(gè)對(duì)話框或者其派生類上,實(shí)現(xiàn)動(dòng)畫打開和動(dòng)畫關(guān)閉效果

代碼片段和文件信息
//?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(){
//獲得窗口預(yù)設(shè)的大小
CRect?dlgRect;
flashDlg->GetWindowRect(dlgRect);
//獲取屏幕大小
CRect?desktopRect;
flashDlg->GetDesktopWindow()->GetWindowRect(desktopRect);
//將窗口開始大小設(shè)為0,居中
flashDlg->MoveWindow(dlgRect.left?+?dlgRect.Width()?/?2
??dlgRect.top?+?dlgRect.Height()?/?2
???0
???0?
???);
//數(shù)據(jù)成員初始化
OriginalWidth=dlgRect.Width();
OriginalHeight=dlgRect.Height();
xCreateSpeed=2;
yCreateSpeed=3;
xDestorySpeed=2;
yDestorySpeed=3;
//設(shè)定定時(shí)器Timer1_ID
flashDlg->SetTimer(Timer1_ID10NULL);
}
void?CDlgFlash::OnTimer(UINT?nIDEvent){
{
//獲得此時(shí)窗口的實(shí)際大小
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()?
??);
//不要超過窗口預(yù)設(shè)的寬度
if(dlgRect.Width()?>=OriginalWidth)?
xCreateSpeed=0;?
//不要超過窗口預(yù)設(shè)的高度
if(dlgRect.Height()?>=OriginalHeight)
yCreateSpeed=0;
//停止變化,關(guān)閉定時(shí)器Timer1_ID
if((dlgRect.Width()?>=OriginalWidth)?&&?(dlgRect.Height()?>=OriginalHeight))
flashDlg->KillTimer(Timer1_ID);?
}
//如果是窗口關(guān)閉過程,則逐漸縮小窗口
if(nIDEvent?==?Timer2_ID)
{
flashDlg->MoveWindow(DestoryPosX
DestoryPosY?
dlgRect.Width()
dlgRect.Height()-yDestorySpeed
);
//當(dāng)高度等于零后高度就不在變化
//if(dlgRect.Height()?<=0)
?
//停止變化,關(guān)閉定時(shí)器Timer2_ID,并且關(guān)閉窗口
if(dlgRect.Height()?<=0)
{
yDestorySpeed=0;
flashDlg->KillTimer(Timer1_ID);
flashDlg->DestroyWindow();
}
}
}
}
void?CDlgFlash::StartFlashDestroyDlg(){
CRect?dlgRect;
//獲取窗口當(dāng)前的位置并保存
flashDlg->GetWindowRect(&dlgRect);
DestoryPosX=dlgRect.left;
DestoryPosY=dlgRect.top;
//開始啟動(dòng)定時(shí)器Timer2_ID
flashDlg->SetTimer(Timer2_ID10NULL);
}
void?CDlgFlash::SetFlashCreateSpeed(int?xint?y){
xCreateSpeed=x;
xCreateSpeed=y;
}
void?CDlgFlash::SetFlashDestroySpeed(int?y){
yDestorySpeed=y;
}
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件???????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個(gè)文件信息
- 上一篇:遺傳算法解八數(shù)碼問題
- 下一篇:mfc按CEdit編輯框彈出自定義鍵盤
評(píng)論
共有 條評(píng)論