123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980 |
- // MyAnimateWindow.cpp : implementation file
- //
- #include "stdafx.h"
- #include "LYFZIPManage.h"
- #include "MyAnimateWindow.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // MyAnimateWindow dialog
- bool SleepEx( DWORD dwMilliseconds )
- {
- if( dwMilliseconds == 0 ) return TRUE;
- DWORD t1 = GetTickCount();
- while(1)
- {
- DWORD t2 = GetTickCount();
- if( t2 < t1 || (t2 - t1) > dwMilliseconds )break;
-
- MSG msg;
- if( PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) )
- {
- GetMessage( &msg, NULL, 0, 0 );
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- else
- {
- Sleep(1);
- }
- }
- return TRUE;
- }
- //---------------------------------------------------
- //from leftbottom to righttop
- //-------------------------------------------------
- bool MyAnimateWindow::MagicFun20( Image *hSrcDC , int x , int y , HDC hDestDC , int xd , int yd , int width , int height , int nDelay, int nStep)
- {
- try
- {
- int nSize = nStep;
- int Max = width>height?width:height;
- Graphics graph(hDestDC);
- while( nSize < Max )
- {
- if(m_bTerminate3)return 1;
- int nX = x+width-nSize;
- int nY = nSize;
- if( nX < 0 ) nX = 0;
- if( nY > height ) nY = height;
- // Rect desRect(xd , yd+height-nY , min(width,nSize) ,min(width,nSize)*height/width);
- Rect desRect(xd , yd+height-nY , min(width,nSize) ,min(width,nSize)*height/width);
- graph.DrawImage(hSrcDC, desRect, x , y , hSrcDC->GetWidth(), hSrcDC->GetHeight() ,UnitPixel);
- SleepEx( nDelay );
- nSize += nStep;
- }
- if(m_bTerminate3)return 1;
- Rect desRect(xd , yd , width , height);
- graph.DrawImage(hSrcDC, desRect, x , y , hSrcDC->GetWidth(), hSrcDC->GetHeight() ,UnitPixel);
- return TRUE;
- }
- catch(...)
- {
- }
- }
- bool MyAnimateWindow::MagicFun16( Image *hSrcDC , int x , int y , HDC hDestDC , int xd , int yd , int width , int height , int nDelay, int nStep )
- {
- try
- {
- Graphics graph(hDestDC);
- for( int i=0; i< width/nStep; i++ )
- {
- if(m_bTerminate2)return 1;
-
- Rect desRect(xd+width-(i+1)*nStep , yd , (i+1)*nStep , height);
- graph.DrawImage(hSrcDC, desRect, x , y , (i+1)*nStep, hSrcDC->GetHeight() ,UnitPixel);
- SleepEx( nDelay );
- }
- if(m_bTerminate2)return 1;
- Rect desRect(xd , yd , width , height);
- graph.DrawImage(hSrcDC, desRect, x , y , hSrcDC->GetWidth(), hSrcDC->GetHeight() ,UnitPixel);
- /* ·Êé
- Graphics graph(hDestDC);
- for( int i=0; i< width/nStep; i++ )
- {
- Rect desRect(xd+width-(i+1)*nStep , yd , (i+1)*nStep , height);
- graph.DrawImage(hSrcDC, desRect, x , y , hSrcDC->GetWidth(), hSrcDC->GetHeight() ,UnitPixel);
- SleepEx( nDelay );
- }
- Rect desRect(xd , yd , width , height);
- graph.DrawImage(hSrcDC, desRect, x , y , hSrcDC->GetWidth(), hSrcDC->GetHeight() ,UnitPixel);
- */
- return TRUE;
- }
- catch(...)
- {
- }
- }
- MyAnimateWindow::MyAnimateWindow(CWnd* pParent /*=NULL*/)
- : CDialog(MyAnimateWindow::IDD, pParent)
- {
- //{{AFX_DATA_INIT(MyAnimateWindow)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- m_pImg=NULL;
- m_mode=-1;
- m_mode2=-1;
- m_time=3000;
- m_effect=1;
- m_bTerminate=false;
- m_bRunning=false;
- m_hThread = NULL;
- m_bTerminate2=false;
- m_bRunning2=false;
- m_hThread2 = NULL;
- m_bTerminate3=false;
- m_bRunning3=false;
- m_hThread3 = NULL;
- }
- void MyAnimateWindow::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(MyAnimateWindow)
- // NOTE: the ClassWizard will add DDX and DDV calls here
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(MyAnimateWindow, CDialog)
- //{{AFX_MSG_MAP(MyAnimateWindow)
- ON_WM_ERASEBKGND()
- ON_WM_PAINT()
- ON_WM_TIMER()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // MyAnimateWindow message handlers
- BOOL MyAnimateWindow::OnEraseBkgnd(CDC* pDC)
- {
- try
- {
- // TODO: Add your message handler code here and/or call default
- if(m_pImg==NULL)
- return 1;
- // TODO: Add your message handler code here
- if(m_effect==1 || m_effect==2)
- {
- CRect rc;
- GetClientRect(rc);
- Graphics graph(m_pbmp);
- graph.Clear(Color(255,0,0,0));
- Rect desRect(m_pRc->left , m_pRc->top , m_pRc->Width (), m_pRc->Height ());
- graph.DrawImage(m_pImg, desRect, m_rc.left , m_rc.top , m_rc.Width() , m_rc.Height() ,UnitPixel);
- Graphics graph2(pDC->GetSafeHdc ());
- graph2.DrawImage(m_pbmp,0,0);
- }
- return 1;
- }
- catch(...)
- {
- }
- }
- void MyAnimateWindow::OnOK()
- {
- // TODO: Add extra validation here
- }
- void MyAnimateWindow::OnCancel()
- {
- // TODO: Add extra cleanup here
- }
- BOOL MyAnimateWindow::OnInitDialog()
- {
- CDialog::OnInitDialog();
-
- // TODO: Add extra initialization here
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void MyAnimateWindow::OnPaint()
- {
- CPaintDC dc(this); // device context for painting
- if(m_pImg==NULL)
- return;
- // TODO: Add your message handler code here
- if(m_effect==0)
- {
- /* Graphics graph(m_pbmp);
- graph.Clear(Color(255,0,0,0));
- Rect desRect(m_pRc->left , m_pRc->top , m_pRc->Width (), m_pRc->Height ());
- graph.DrawImage(m_pImg, desRect, m_rc.left , m_rc.top , m_rc.Width() , m_rc.Height() ,UnitPixel);
- Graphics graph2(dc.GetSafeHdc ());
- graph2.DrawImage(m_pbmp,0,0);*/
- try
- {
- if(m_rcneedclear.IsRectEmpty ())
- GetClientRect(m_rcneedclear);
- CDC *pDC=&dc;
- CRect rc,rc2;
- rc.IntersectRect(m_pRc, m_rcneedclear);
- rc2.left =m_rcneedclear.left ;
- rc2.top =rc.top ;
- rc2.right =rc.left ;
- rc2.bottom =rc.bottom ;
- pDC->FillSolidRect (rc2, 0);
- rc2.left =rc.right ;
- rc2.top =rc.top ;
- rc2.right =m_rcneedclear.right ;
- rc2.bottom =rc.bottom ;
- pDC->FillSolidRect (rc2, 0);
- rc2.left =rc.left ;
- rc2.top =m_rcneedclear.top ;
- rc2.right =rc.right ;
- rc2.bottom =rc.top ;
- pDC->FillSolidRect (rc2, 0);
- rc2.left =rc.left ;
- rc2.top =rc.bottom ;
- rc2.right =rc.right ;
- rc2.bottom =m_rcneedclear.bottom ;
- pDC->FillSolidRect (rc2, 0);
- m_rcneedclear=*m_pRc;
- Graphics graph(dc.GetSafeHdc ());
- graph.Clear(Color(255,0,0,0));
- Rect desRect(m_pRc->left , m_pRc->top , m_pRc->Width (), m_pRc->Height ());
- graph.DrawImage(m_pImg, desRect, m_rc.left , m_rc.top , m_rc.Width() , m_rc.Height() ,UnitPixel);
-
- }
- catch(...)
- {
- }
- }
- // Do not call CDialog::OnPaint() for painting messages
- }
- void MyAnimateWindow::SetImage(Image *img)
- {
- m_pImg=img;
- }
- void MyAnimateWindow::MyExit()
- {
- AnimateWindow(GetSafeHwnd(), 500, AW_BLEND | AW_HIDE);
- }
- unsigned __stdcall DrawEffect1Thread(LPVOID lpParam)
- {
- try
- {
- MyAnimateWindow *pThis=(MyAnimateWindow*)lpParam;
- CDC *pDC=pThis->GetDC();
- pThis->DrawEffect1(pDC);
- pThis->ReleaseDC(pDC);
- if(pThis->m_bTerminate==0)
- pThis->m_pParent->SetTimer(1, 1, NULL);
- pThis->m_bRunning=false;
- pThis->m_bTerminate=false;
-
- return 0;
- }
- catch(...)
- {
- }
- }
- unsigned __stdcall DrawEffect2Thread(LPVOID lpParam)
- {
- try
- {
- MyAnimateWindow *pThis=(MyAnimateWindow*)lpParam;
- CDC *pDC=pThis->GetDC();
- pThis->ShowWindow(SW_SHOW);
- CRect rc;
- pThis->GetClientRect(rc);
- pDC->FillSolidRect (rc,0);
- if(pThis->m_time<2000)
- pThis->MagicFun16( pThis->m_pImg , 0 , 0 , pDC->GetSafeHdc() , pThis->m_pRc->left , pThis->m_pRc->top , pThis->m_pRc->Width (), pThis->m_pRc->Height () , 1, pThis->m_pRc->Width ()/12 );
- else if(pThis->m_time<3000)
- pThis->MagicFun16( pThis->m_pImg , 0 , 0 , pDC->GetSafeHdc() , pThis->m_pRc->left , pThis->m_pRc->top , pThis->m_pRc->Width (), pThis->m_pRc->Height () , 1, pThis->m_pRc->Width ()/18 );
- else
- pThis->MagicFun16( pThis->m_pImg , 0 , 0 , pDC->GetSafeHdc() , pThis->m_pRc->left , pThis->m_pRc->top , pThis->m_pRc->Width (), pThis->m_pRc->Height () , 1, pThis->m_pRc->Width ()/25 );
- pThis->ReleaseDC(pDC);
- if(pThis->m_bTerminate2==0)
- pThis->m_pParent->SetTimer(1, pThis->m_time, NULL);
- pThis->m_bRunning2=false;
- pThis->m_bTerminate2=false;
-
- return 0;
- }
- catch(...)
- {
- }
- }
- unsigned __stdcall DrawEffect3Thread(LPVOID lpParam)
- {
- try
- {
- MyAnimateWindow *pThis=(MyAnimateWindow*)lpParam;
- CDC *pDC=pThis->GetDC();
- pThis->ShowWindow(SW_SHOW);
- CRect rc;
- pThis->GetClientRect(rc);
- pDC->FillSolidRect (rc,0);
- if(pThis->m_time<2000)
- pThis->MagicFun20( pThis->m_pImg , 0 , 0 , pDC->GetSafeHdc() , pThis->m_pRc->left , pThis->m_pRc->top , pThis->m_pRc->Width (), pThis->m_pRc->Height () , 1, pThis->m_pRc->Width ()/12 );
- else if(pThis->m_time<3000)
- pThis->MagicFun20( pThis->m_pImg , 0 , 0 , pDC->GetSafeHdc() , pThis->m_pRc->left , pThis->m_pRc->top , pThis->m_pRc->Width (), pThis->m_pRc->Height () , 1, pThis->m_pRc->Width ()/18 );
- else
- pThis->MagicFun20( pThis->m_pImg , 0 , 0 , pDC->GetSafeHdc() , pThis->m_pRc->left , pThis->m_pRc->top , pThis->m_pRc->Width (), pThis->m_pRc->Height () , 1, pThis->m_pRc->Width ()/25 );
- pThis->ReleaseDC(pDC);
- if(pThis->m_bTerminate3==0)
- pThis->m_pParent->SetTimer(1, pThis->m_time, NULL);
- pThis->m_bRunning3=false;
- pThis->m_bTerminate3=false;
-
- return 0;
- }
- catch(...)
- {
- }
- }
- void MyAnimateWindow::ShowAlpha()
- {
- try
- {
- m_rc=CRect(0,0,m_pImg->GetWidth(),m_pImg->GetHeight());
- if(m_effect==1)
- {
- m_times=0;
- m_mode2++;
- if(m_mode2>7)m_mode2=0;
- switch(m_mode2)
- {
- case 0:
- m_mode=0;
- break;
- case 1:
- m_mode=4;
- break;
- case 2:
- m_mode=1;
- break;
- case 3:
- m_mode=5;
- break;
- case 4:
- m_mode=2;
- break;
- case 5:
- m_mode=6;
- break;
- case 6:
- m_mode=3;
- break;
- case 7:
- m_mode=7;
- break;
- }
- if(m_mode==0)
- {
- m_rc.left+=80;
- m_rc.bottom-=80;
- }
- else if(m_mode==1)
- {
- m_rc.right-=80;
- m_rc.bottom-=80;
- }
- else if(m_mode==2)
- {
- m_rc.left+=80;
- m_rc.top+=80;
- }
- else if(m_mode==3)
- {
- m_rc.right-=80;
- m_rc.top+=80;
- }
- // SetTimer(1, max(10,m_time/80), NULL);
- if(m_time<2000)
- AnimateWindow(GetSafeHwnd(), 200, AW_BLEND);
- else if(m_time<3000)
- AnimateWindow(GetSafeHwnd(), 400, AW_BLEND);
- else
- AnimateWindow(GetSafeHwnd(), 600, AW_BLEND);
- // Invalidate();
-
-
- }
- else if(m_effect==2)
- {
- if(m_time<2000)
- AnimateWindow(GetSafeHwnd(), 200, AW_BLEND);
- else if(m_time<3000)
- AnimateWindow(GetSafeHwnd(), 400, AW_BLEND);
- else
- AnimateWindow(GetSafeHwnd(), 600, AW_BLEND);
- m_pParent->SetTimer(1, m_time, NULL);
- }
- else if(m_effect==3)
- {
- TerminateThread2();
-
- }
- else if(m_effect==4)
- {
- TerminateThread3();
-
- }
- else
- {
- ShowWindow(SW_SHOW);
- Invalidate();
- m_pParent->SetTimer(1, m_time, NULL);
- }
- }
- catch(...)
- {
- }
- }
- BOOL MyAnimateWindow::PreTranslateMessage(MSG* pMsg)
- {
- // TODO: Add your specialized code here and/or call the base class
- return m_pParent->PreTranslateMessage(pMsg);
- // return CDialog::PreTranslateMessage(pMsg);
- }
- void MyAnimateWindow::OnTimer(UINT nIDEvent)
- {
- // TODO: Add your message handler code here and/or call default
- /*if(nIDEvent==1)
- {
- m_times++;
- if(ChenkOver())return;
- if(m_mode==0)
- {
- m_rc.left--;
- m_rc.bottom++;
- // if(m_times%3==0)
- {
- if(m_pRc->Width ()<m_pRc->Height () && m_pRc->right<g_dm.dmPelsWidth)
- {
- m_pRc->left++;
- m_pRc->right++;
- }
- else if(m_pRc->Width ()>m_pRc->Height () && m_pRc->top)
- {
- m_pRc->top--;
- m_pRc->bottom--;
- }
- }
- }
- else if(m_mode==1)
- {
- m_rc.right++;
- m_rc.bottom++;
-
- {
- if(m_pRc->Width ()<m_pRc->Height () && m_pRc->left)
- {
- m_pRc->left--;
- m_pRc->right--;
- }
- else if(m_pRc->Width ()>m_pRc->Height () && m_pRc->top)
- {
- m_pRc->top--;
- m_pRc->bottom--;
- }
- }
- }
- else if(m_mode==2)
- {
- m_rc.left--;
- m_rc.top--;
-
- {
- if(m_pRc->Width ()<m_pRc->Height () && m_pRc->right<g_dm.dmPelsWidth)
- {
- m_pRc->left++;
- m_pRc->right++;
- }
- else if(m_pRc->Width ()>m_pRc->Height () && m_pRc->bottom<g_dm.dmPelsHeight)
- {
- m_pRc->top++;
- m_pRc->bottom++;
- }
- }
- }
- else if(m_mode==3)
- {
- m_rc.right++;
- m_rc.top--;
-
- {
- if(m_pRc->Width ()<m_pRc->Height () && m_pRc->left)
- {
- m_pRc->left--;
- m_pRc->right--;
- }
- else if(m_pRc->Width ()>m_pRc->Height () && m_pRc->bottom<g_dm.dmPelsHeight)
- {
- m_pRc->top++;
- m_pRc->bottom++;
- }
- }
- }
- else if(m_mode==4)
- {
- m_rc.left++;
- m_rc.bottom--;
-
- {
- if(m_pRc->Width ()<m_pRc->Height () && m_pRc->left)
- {
- m_pRc->left--;
- m_pRc->right--;
- }
- else if(m_pRc->Width ()>m_pRc->Height () && m_pRc->bottom<g_dm.dmPelsHeight)
- {
- m_pRc->top++;
- m_pRc->bottom++;
- }
- }
- }
- else if(m_mode==5)
- {
- m_rc.right--;
- m_rc.bottom--;
-
- {
- if(m_pRc->Width ()<m_pRc->Height () && m_pRc->right<g_dm.dmPelsWidth)
- {
- m_pRc->left++;
- m_pRc->right++;
- }
- else if(m_pRc->Width ()>m_pRc->Height () && m_pRc->bottom<g_dm.dmPelsHeight)
- {
- m_pRc->top++;
- m_pRc->bottom++;
- }
- }
- }
- else if(m_mode==6)
- {
- m_rc.left++;
- m_rc.top++;
-
- {
- if(m_pRc->Width ()<m_pRc->Height () && m_pRc->left)
- {
- m_pRc->left--;
- m_pRc->right--;
- }
- else if(m_pRc->Width ()>m_pRc->Height () && m_pRc->top)
- {
- m_pRc->top--;
- m_pRc->bottom--;
- }
- }
- }
- else if(m_mode==7)
- {
- m_rc.right--;
- m_rc.top++;
-
- {
- if(m_pRc->Width ()<m_pRc->Height () && m_pRc->right<g_dm.dmPelsWidth)
- {
- m_pRc->left++;
- m_pRc->right++;
- }
- else if(m_pRc->Width ()>m_pRc->Height () && m_pRc->top)
- {
- m_pRc->top--;
- m_pRc->bottom--;
- }
- }
- }
- Invalidate();
-
- }*/
- }
- BOOL MyAnimateWindow::ChenkOver()
- {
- if(m_times<80)return 0;
- m_pParent->SetTimer(1, 1, NULL);
- return 1;
- }
- void MyAnimateWindow::DrawEffect1(CDC *pDC)
- {
- try
- {
- GetClientRect(m_rcneedclear);
- // Graphics graph(m_pbmp);
- Graphics graph(pDC->GetSafeHdc ());
- int step=5;
- if(m_time<2000)
- step=5;
- else if(m_time<3000)
- step=3;
- else if(m_time<4000)
- step=2;
- else
- step=1;
- for(int i=0; i<80/step; i++)
- {
- if(m_bTerminate)break;
- // graph.Clear(Color(255,0,0,0));
- if(m_mode==0)
- {
- m_rc.left-=step;
- m_rc.bottom+=step;
- // if(m_times%3==0)
- {
- if(m_pRc->Width ()<m_pRc->Height () && m_pRc->right<g_dm.dmPelsWidth)
- {
- m_pRc->left++;
- m_pRc->right++;
- }
- else if(m_pRc->Width ()>m_pRc->Height () && m_pRc->top)
- {
- m_pRc->top--;
- m_pRc->bottom--;
- }
- }
- }
- else if(m_mode==1)
- {
- m_rc.right+=step;
- m_rc.bottom+=step;
-
- {
- if(m_pRc->Width ()<m_pRc->Height () && m_pRc->left)
- {
- m_pRc->left--;
- m_pRc->right--;
- }
- else if(m_pRc->Width ()>m_pRc->Height () && m_pRc->top)
- {
- m_pRc->top--;
- m_pRc->bottom--;
- }
- }
- }
- else if(m_mode==2)
- {
- m_rc.left-=step;
- m_rc.top-=step;
-
- {
- if(m_pRc->Width ()<m_pRc->Height () && m_pRc->right<g_dm.dmPelsWidth)
- {
- m_pRc->left++;
- m_pRc->right++;
- }
- else if(m_pRc->Width ()>m_pRc->Height () && m_pRc->bottom<g_dm.dmPelsHeight)
- {
- m_pRc->top++;
- m_pRc->bottom++;
- }
- }
- }
- else if(m_mode==3)
- {
- m_rc.right+=step;
- m_rc.top-=step;
-
- {
- if(m_pRc->Width ()<m_pRc->Height () && m_pRc->left)
- {
- m_pRc->left--;
- m_pRc->right--;
- }
- else if(m_pRc->Width ()>m_pRc->Height () && m_pRc->bottom<g_dm.dmPelsHeight)
- {
- m_pRc->top++;
- m_pRc->bottom++;
- }
- }
- }
- else if(m_mode==4)
- {
- m_rc.left+=step;
- m_rc.bottom-=step;
-
- {
- if(m_pRc->Width ()<m_pRc->Height () && m_pRc->left)
- {
- m_pRc->left--;
- m_pRc->right--;
- }
- else if(m_pRc->Width ()>m_pRc->Height () && m_pRc->bottom<g_dm.dmPelsHeight)
- {
- m_pRc->top++;
- m_pRc->bottom++;
- }
- }
- }
- else if(m_mode==5)
- {
- m_rc.right-=step;
- m_rc.bottom-=step;
-
- {
- if(m_pRc->Width ()<m_pRc->Height () && m_pRc->right<g_dm.dmPelsWidth)
- {
- m_pRc->left++;
- m_pRc->right++;
- }
- else if(m_pRc->Width ()>m_pRc->Height () && m_pRc->bottom<g_dm.dmPelsHeight)
- {
- m_pRc->top++;
- m_pRc->bottom++;
- }
- }
- }
- else if(m_mode==6)
- {
- m_rc.left+=step;
- m_rc.top+=step;
-
- {
- if(m_pRc->Width ()<m_pRc->Height () && m_pRc->left)
- {
- m_pRc->left--;
- m_pRc->right--;
- }
- else if(m_pRc->Width ()>m_pRc->Height () && m_pRc->top)
- {
- m_pRc->top--;
- m_pRc->bottom--;
- }
- }
- }
- else if(m_mode==7)
- {
- m_rc.right-=step;
- m_rc.top+=step;
-
- {
- if(m_pRc->Width ()<m_pRc->Height () && m_pRc->right<g_dm.dmPelsWidth)
- {
- m_pRc->left++;
- m_pRc->right++;
- }
- else if(m_pRc->Width ()>m_pRc->Height () && m_pRc->top)
- {
- m_pRc->top--;
- m_pRc->bottom--;
- }
- }
- }
- CRect rc,rc2;
- rc.IntersectRect(m_pRc, m_rcneedclear);
- rc2.left =m_rcneedclear.left ;
- rc2.top =rc.top ;
- rc2.right =rc.left ;
- rc2.bottom =rc.bottom ;
- pDC->FillSolidRect (rc2, 0);
- rc2.left =rc.right ;
- rc2.top =rc.top ;
- rc2.right =m_rcneedclear.right ;
- rc2.bottom =rc.bottom ;
- pDC->FillSolidRect (rc2, 0);
- rc2.left =rc.left ;
- rc2.top =m_rcneedclear.top ;
- rc2.right =rc.right ;
- rc2.bottom =rc.top ;
- pDC->FillSolidRect (rc2, 0);
- rc2.left =rc.left ;
- rc2.top =rc.bottom ;
- rc2.right =rc.right ;
- rc2.bottom =m_rcneedclear.bottom ;
- pDC->FillSolidRect (rc2, 0);
- m_rcneedclear=*m_pRc;
-
- if(m_bTerminate)break;
-
- Rect desRect(m_pRc->left , m_pRc->top , m_pRc->Width (), m_pRc->Height ());
- graph.DrawImage(m_pImg, desRect, m_rc.left , m_rc.top , m_rc.Width() , m_rc.Height() ,UnitPixel);
-
-
- // SleepEx( 10 );
- SleepEx( max(10,m_time/160) );
- // Sleep( 10 );
- }
- }
- catch(...)
- {
- }
- }
- BOOL MyAnimateWindow::TerminateThread()
- {
- try
- {
- if ( m_bRunning )
- {
- m_bTerminate=true;
- for( ; ; )
- {
- if ( ::WaitForSingleObject(m_hThread, 0) == WAIT_OBJECT_0 )
- break;
-
- MSG msg;
- while (::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
- {
- if (!AfxGetApp()->PumpMessage())
- break;
- }
- }
- ::CloseHandle(m_hThread);
- }
- if ( m_bRunning2 )
- {
- m_bTerminate2=true;
- for( ; ; )
- {
- if ( ::WaitForSingleObject(m_hThread2, 0) == WAIT_OBJECT_0 )
- break;
-
- MSG msg;
- while (::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
- {
- if (!AfxGetApp()->PumpMessage())
- break;
- }
- }
- ::CloseHandle(m_hThread2);
- }
- if ( m_bRunning3 )
- {
- m_bTerminate3=true;
- for( ; ; )
- {
- if ( ::WaitForSingleObject(m_hThread3, 0) == WAIT_OBJECT_0 )
- break;
-
- MSG msg;
- while (::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
- {
- if (!AfxGetApp()->PumpMessage())
- break;
- }
- }
- ::CloseHandle(m_hThread3);
- }
- return TRUE;
- }
- catch(...)
- {
- }
- }
- BOOL MyAnimateWindow::TerminateThread1()
- {
- try
- {
- if ( m_bRunning )
- {
- m_bTerminate=true;
- for( ; ; )
- {
- if ( ::WaitForSingleObject(m_hThread, 0) == WAIT_OBJECT_0 )
- break;
-
- MSG msg;
- while (::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
- {
- if (!AfxGetApp()->PumpMessage())
- break;
- }
- }
- ::CloseHandle(m_hThread);
- }
- return TRUE;
- }
- catch(...)
- {
- }
- }
- BOOL MyAnimateWindow::TerminateThread2()
- {
- try
- {
- if ( m_bRunning2 )
- {
- m_bTerminate2=true;
- for( ; ; )
- {
- if ( ::WaitForSingleObject(m_hThread2, 0) == WAIT_OBJECT_0 )
- break;
-
- MSG msg;
- while (::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
- {
- if (!AfxGetApp()->PumpMessage())
- break;
- }
- }
- ::CloseHandle(m_hThread2);
- }
- return TRUE;
- }
- catch(...)
- {
- }
- }
- BOOL MyAnimateWindow::TerminateThread3()
- {
- try
- {
- if ( m_bRunning3 )
- {
- m_bTerminate3=true;
- for( ; ; )
- {
- if ( ::WaitForSingleObject(m_hThread3, 0) == WAIT_OBJECT_0 )
- break;
-
- MSG msg;
- while (::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
- {
- if (!AfxGetApp()->PumpMessage())
- break;
- }
- }
- ::CloseHandle(m_hThread3);
- }
- return TRUE;
- }
- catch(...)
- {
- }
- }
|