MyAnimateWindow.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980
  1. // MyAnimateWindow.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "LYFZIPManage.h"
  5. #include "MyAnimateWindow.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // MyAnimateWindow dialog
  13. bool SleepEx( DWORD dwMilliseconds )
  14. {
  15. if( dwMilliseconds == 0 ) return TRUE;
  16. DWORD t1 = GetTickCount();
  17. while(1)
  18. {
  19. DWORD t2 = GetTickCount();
  20. if( t2 < t1 || (t2 - t1) > dwMilliseconds )break;
  21. MSG msg;
  22. if( PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) )
  23. {
  24. GetMessage( &msg, NULL, 0, 0 );
  25. TranslateMessage(&msg);
  26. DispatchMessage(&msg);
  27. }
  28. else
  29. {
  30. Sleep(1);
  31. }
  32. }
  33. return TRUE;
  34. }
  35. //---------------------------------------------------
  36. //from leftbottom to righttop
  37. //-------------------------------------------------
  38. bool MyAnimateWindow::MagicFun20( Image *hSrcDC , int x , int y , HDC hDestDC , int xd , int yd , int width , int height , int nDelay, int nStep)
  39. {
  40. try
  41. {
  42. int nSize = nStep;
  43. int Max = width>height?width:height;
  44. Graphics graph(hDestDC);
  45. while( nSize < Max )
  46. {
  47. if(m_bTerminate3)return 1;
  48. int nX = x+width-nSize;
  49. int nY = nSize;
  50. if( nX < 0 ) nX = 0;
  51. if( nY > height ) nY = height;
  52. // Rect desRect(xd , yd+height-nY , min(width,nSize) ,min(width,nSize)*height/width);
  53. Rect desRect(xd , yd+height-nY , min(width,nSize) ,min(width,nSize)*height/width);
  54. graph.DrawImage(hSrcDC, desRect, x , y , hSrcDC->GetWidth(), hSrcDC->GetHeight() ,UnitPixel);
  55. SleepEx( nDelay );
  56. nSize += nStep;
  57. }
  58. if(m_bTerminate3)return 1;
  59. Rect desRect(xd , yd , width , height);
  60. graph.DrawImage(hSrcDC, desRect, x , y , hSrcDC->GetWidth(), hSrcDC->GetHeight() ,UnitPixel);
  61. return TRUE;
  62. }
  63. catch(...)
  64. {
  65. }
  66. }
  67. bool MyAnimateWindow::MagicFun16( Image *hSrcDC , int x , int y , HDC hDestDC , int xd , int yd , int width , int height , int nDelay, int nStep )
  68. {
  69. try
  70. {
  71. Graphics graph(hDestDC);
  72. for( int i=0; i< width/nStep; i++ )
  73. {
  74. if(m_bTerminate2)return 1;
  75. Rect desRect(xd+width-(i+1)*nStep , yd , (i+1)*nStep , height);
  76. graph.DrawImage(hSrcDC, desRect, x , y , (i+1)*nStep, hSrcDC->GetHeight() ,UnitPixel);
  77. SleepEx( nDelay );
  78. }
  79. if(m_bTerminate2)return 1;
  80. Rect desRect(xd , yd , width , height);
  81. graph.DrawImage(hSrcDC, desRect, x , y , hSrcDC->GetWidth(), hSrcDC->GetHeight() ,UnitPixel);
  82. /* ·­Êé
  83. Graphics graph(hDestDC);
  84. for( int i=0; i< width/nStep; i++ )
  85. {
  86. Rect desRect(xd+width-(i+1)*nStep , yd , (i+1)*nStep , height);
  87. graph.DrawImage(hSrcDC, desRect, x , y , hSrcDC->GetWidth(), hSrcDC->GetHeight() ,UnitPixel);
  88. SleepEx( nDelay );
  89. }
  90. Rect desRect(xd , yd , width , height);
  91. graph.DrawImage(hSrcDC, desRect, x , y , hSrcDC->GetWidth(), hSrcDC->GetHeight() ,UnitPixel);
  92. */
  93. return TRUE;
  94. }
  95. catch(...)
  96. {
  97. }
  98. }
  99. MyAnimateWindow::MyAnimateWindow(CWnd* pParent /*=NULL*/)
  100. : CDialog(MyAnimateWindow::IDD, pParent)
  101. {
  102. //{{AFX_DATA_INIT(MyAnimateWindow)
  103. // NOTE: the ClassWizard will add member initialization here
  104. //}}AFX_DATA_INIT
  105. m_pImg=NULL;
  106. m_mode=-1;
  107. m_mode2=-1;
  108. m_time=3000;
  109. m_effect=1;
  110. m_bTerminate=false;
  111. m_bRunning=false;
  112. m_hThread = NULL;
  113. m_bTerminate2=false;
  114. m_bRunning2=false;
  115. m_hThread2 = NULL;
  116. m_bTerminate3=false;
  117. m_bRunning3=false;
  118. m_hThread3 = NULL;
  119. }
  120. void MyAnimateWindow::DoDataExchange(CDataExchange* pDX)
  121. {
  122. CDialog::DoDataExchange(pDX);
  123. //{{AFX_DATA_MAP(MyAnimateWindow)
  124. // NOTE: the ClassWizard will add DDX and DDV calls here
  125. //}}AFX_DATA_MAP
  126. }
  127. BEGIN_MESSAGE_MAP(MyAnimateWindow, CDialog)
  128. //{{AFX_MSG_MAP(MyAnimateWindow)
  129. ON_WM_ERASEBKGND()
  130. ON_WM_PAINT()
  131. ON_WM_TIMER()
  132. //}}AFX_MSG_MAP
  133. END_MESSAGE_MAP()
  134. /////////////////////////////////////////////////////////////////////////////
  135. // MyAnimateWindow message handlers
  136. BOOL MyAnimateWindow::OnEraseBkgnd(CDC* pDC)
  137. {
  138. try
  139. {
  140. // TODO: Add your message handler code here and/or call default
  141. if(m_pImg==NULL)
  142. return 1;
  143. // TODO: Add your message handler code here
  144. if(m_effect==1 || m_effect==2)
  145. {
  146. CRect rc;
  147. GetClientRect(rc);
  148. Graphics graph(m_pbmp);
  149. graph.Clear(Color(255,0,0,0));
  150. Rect desRect(m_pRc->left , m_pRc->top , m_pRc->Width (), m_pRc->Height ());
  151. graph.DrawImage(m_pImg, desRect, m_rc.left , m_rc.top , m_rc.Width() , m_rc.Height() ,UnitPixel);
  152. Graphics graph2(pDC->GetSafeHdc ());
  153. graph2.DrawImage(m_pbmp,0,0);
  154. }
  155. return 1;
  156. }
  157. catch(...)
  158. {
  159. }
  160. }
  161. void MyAnimateWindow::OnOK()
  162. {
  163. // TODO: Add extra validation here
  164. }
  165. void MyAnimateWindow::OnCancel()
  166. {
  167. // TODO: Add extra cleanup here
  168. }
  169. BOOL MyAnimateWindow::OnInitDialog()
  170. {
  171. CDialog::OnInitDialog();
  172. // TODO: Add extra initialization here
  173. return TRUE; // return TRUE unless you set the focus to a control
  174. // EXCEPTION: OCX Property Pages should return FALSE
  175. }
  176. void MyAnimateWindow::OnPaint()
  177. {
  178. CPaintDC dc(this); // device context for painting
  179. if(m_pImg==NULL)
  180. return;
  181. // TODO: Add your message handler code here
  182. if(m_effect==0)
  183. {
  184. /* Graphics graph(m_pbmp);
  185. graph.Clear(Color(255,0,0,0));
  186. Rect desRect(m_pRc->left , m_pRc->top , m_pRc->Width (), m_pRc->Height ());
  187. graph.DrawImage(m_pImg, desRect, m_rc.left , m_rc.top , m_rc.Width() , m_rc.Height() ,UnitPixel);
  188. Graphics graph2(dc.GetSafeHdc ());
  189. graph2.DrawImage(m_pbmp,0,0);*/
  190. try
  191. {
  192. if(m_rcneedclear.IsRectEmpty ())
  193. GetClientRect(m_rcneedclear);
  194. CDC *pDC=&dc;
  195. CRect rc,rc2;
  196. rc.IntersectRect(m_pRc, m_rcneedclear);
  197. rc2.left =m_rcneedclear.left ;
  198. rc2.top =rc.top ;
  199. rc2.right =rc.left ;
  200. rc2.bottom =rc.bottom ;
  201. pDC->FillSolidRect (rc2, 0);
  202. rc2.left =rc.right ;
  203. rc2.top =rc.top ;
  204. rc2.right =m_rcneedclear.right ;
  205. rc2.bottom =rc.bottom ;
  206. pDC->FillSolidRect (rc2, 0);
  207. rc2.left =rc.left ;
  208. rc2.top =m_rcneedclear.top ;
  209. rc2.right =rc.right ;
  210. rc2.bottom =rc.top ;
  211. pDC->FillSolidRect (rc2, 0);
  212. rc2.left =rc.left ;
  213. rc2.top =rc.bottom ;
  214. rc2.right =rc.right ;
  215. rc2.bottom =m_rcneedclear.bottom ;
  216. pDC->FillSolidRect (rc2, 0);
  217. m_rcneedclear=*m_pRc;
  218. Graphics graph(dc.GetSafeHdc ());
  219. graph.Clear(Color(255,0,0,0));
  220. Rect desRect(m_pRc->left , m_pRc->top , m_pRc->Width (), m_pRc->Height ());
  221. graph.DrawImage(m_pImg, desRect, m_rc.left , m_rc.top , m_rc.Width() , m_rc.Height() ,UnitPixel);
  222. }
  223. catch(...)
  224. {
  225. }
  226. }
  227. // Do not call CDialog::OnPaint() for painting messages
  228. }
  229. void MyAnimateWindow::SetImage(Image *img)
  230. {
  231. m_pImg=img;
  232. }
  233. void MyAnimateWindow::MyExit()
  234. {
  235. AnimateWindow(GetSafeHwnd(), 500, AW_BLEND | AW_HIDE);
  236. }
  237. unsigned __stdcall DrawEffect1Thread(LPVOID lpParam)
  238. {
  239. try
  240. {
  241. MyAnimateWindow *pThis=(MyAnimateWindow*)lpParam;
  242. CDC *pDC=pThis->GetDC();
  243. pThis->DrawEffect1(pDC);
  244. pThis->ReleaseDC(pDC);
  245. if(pThis->m_bTerminate==0)
  246. pThis->m_pParent->SetTimer(1, 1, NULL);
  247. pThis->m_bRunning=false;
  248. pThis->m_bTerminate=false;
  249. return 0;
  250. }
  251. catch(...)
  252. {
  253. }
  254. }
  255. unsigned __stdcall DrawEffect2Thread(LPVOID lpParam)
  256. {
  257. try
  258. {
  259. MyAnimateWindow *pThis=(MyAnimateWindow*)lpParam;
  260. CDC *pDC=pThis->GetDC();
  261. pThis->ShowWindow(SW_SHOW);
  262. CRect rc;
  263. pThis->GetClientRect(rc);
  264. pDC->FillSolidRect (rc,0);
  265. if(pThis->m_time<2000)
  266. 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 );
  267. else if(pThis->m_time<3000)
  268. 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 );
  269. else
  270. 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 );
  271. pThis->ReleaseDC(pDC);
  272. if(pThis->m_bTerminate2==0)
  273. pThis->m_pParent->SetTimer(1, pThis->m_time, NULL);
  274. pThis->m_bRunning2=false;
  275. pThis->m_bTerminate2=false;
  276. return 0;
  277. }
  278. catch(...)
  279. {
  280. }
  281. }
  282. unsigned __stdcall DrawEffect3Thread(LPVOID lpParam)
  283. {
  284. try
  285. {
  286. MyAnimateWindow *pThis=(MyAnimateWindow*)lpParam;
  287. CDC *pDC=pThis->GetDC();
  288. pThis->ShowWindow(SW_SHOW);
  289. CRect rc;
  290. pThis->GetClientRect(rc);
  291. pDC->FillSolidRect (rc,0);
  292. if(pThis->m_time<2000)
  293. 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 );
  294. else if(pThis->m_time<3000)
  295. 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 );
  296. else
  297. 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 );
  298. pThis->ReleaseDC(pDC);
  299. if(pThis->m_bTerminate3==0)
  300. pThis->m_pParent->SetTimer(1, pThis->m_time, NULL);
  301. pThis->m_bRunning3=false;
  302. pThis->m_bTerminate3=false;
  303. return 0;
  304. }
  305. catch(...)
  306. {
  307. }
  308. }
  309. void MyAnimateWindow::ShowAlpha()
  310. {
  311. try
  312. {
  313. m_rc=CRect(0,0,m_pImg->GetWidth(),m_pImg->GetHeight());
  314. if(m_effect==1)
  315. {
  316. m_times=0;
  317. m_mode2++;
  318. if(m_mode2>7)m_mode2=0;
  319. switch(m_mode2)
  320. {
  321. case 0:
  322. m_mode=0;
  323. break;
  324. case 1:
  325. m_mode=4;
  326. break;
  327. case 2:
  328. m_mode=1;
  329. break;
  330. case 3:
  331. m_mode=5;
  332. break;
  333. case 4:
  334. m_mode=2;
  335. break;
  336. case 5:
  337. m_mode=6;
  338. break;
  339. case 6:
  340. m_mode=3;
  341. break;
  342. case 7:
  343. m_mode=7;
  344. break;
  345. }
  346. if(m_mode==0)
  347. {
  348. m_rc.left+=80;
  349. m_rc.bottom-=80;
  350. }
  351. else if(m_mode==1)
  352. {
  353. m_rc.right-=80;
  354. m_rc.bottom-=80;
  355. }
  356. else if(m_mode==2)
  357. {
  358. m_rc.left+=80;
  359. m_rc.top+=80;
  360. }
  361. else if(m_mode==3)
  362. {
  363. m_rc.right-=80;
  364. m_rc.top+=80;
  365. }
  366. // SetTimer(1, max(10,m_time/80), NULL);
  367. if(m_time<2000)
  368. AnimateWindow(GetSafeHwnd(), 200, AW_BLEND);
  369. else if(m_time<3000)
  370. AnimateWindow(GetSafeHwnd(), 400, AW_BLEND);
  371. else
  372. AnimateWindow(GetSafeHwnd(), 600, AW_BLEND);
  373. // Invalidate();
  374. }
  375. else if(m_effect==2)
  376. {
  377. if(m_time<2000)
  378. AnimateWindow(GetSafeHwnd(), 200, AW_BLEND);
  379. else if(m_time<3000)
  380. AnimateWindow(GetSafeHwnd(), 400, AW_BLEND);
  381. else
  382. AnimateWindow(GetSafeHwnd(), 600, AW_BLEND);
  383. m_pParent->SetTimer(1, m_time, NULL);
  384. }
  385. else if(m_effect==3)
  386. {
  387. TerminateThread2();
  388. }
  389. else if(m_effect==4)
  390. {
  391. TerminateThread3();
  392. }
  393. else
  394. {
  395. ShowWindow(SW_SHOW);
  396. Invalidate();
  397. m_pParent->SetTimer(1, m_time, NULL);
  398. }
  399. }
  400. catch(...)
  401. {
  402. }
  403. }
  404. BOOL MyAnimateWindow::PreTranslateMessage(MSG* pMsg)
  405. {
  406. // TODO: Add your specialized code here and/or call the base class
  407. return m_pParent->PreTranslateMessage(pMsg);
  408. // return CDialog::PreTranslateMessage(pMsg);
  409. }
  410. void MyAnimateWindow::OnTimer(UINT nIDEvent)
  411. {
  412. // TODO: Add your message handler code here and/or call default
  413. /*if(nIDEvent==1)
  414. {
  415. m_times++;
  416. if(ChenkOver())return;
  417. if(m_mode==0)
  418. {
  419. m_rc.left--;
  420. m_rc.bottom++;
  421. // if(m_times%3==0)
  422. {
  423. if(m_pRc->Width ()<m_pRc->Height () && m_pRc->right<g_dm.dmPelsWidth)
  424. {
  425. m_pRc->left++;
  426. m_pRc->right++;
  427. }
  428. else if(m_pRc->Width ()>m_pRc->Height () && m_pRc->top)
  429. {
  430. m_pRc->top--;
  431. m_pRc->bottom--;
  432. }
  433. }
  434. }
  435. else if(m_mode==1)
  436. {
  437. m_rc.right++;
  438. m_rc.bottom++;
  439. {
  440. if(m_pRc->Width ()<m_pRc->Height () && m_pRc->left)
  441. {
  442. m_pRc->left--;
  443. m_pRc->right--;
  444. }
  445. else if(m_pRc->Width ()>m_pRc->Height () && m_pRc->top)
  446. {
  447. m_pRc->top--;
  448. m_pRc->bottom--;
  449. }
  450. }
  451. }
  452. else if(m_mode==2)
  453. {
  454. m_rc.left--;
  455. m_rc.top--;
  456. {
  457. if(m_pRc->Width ()<m_pRc->Height () && m_pRc->right<g_dm.dmPelsWidth)
  458. {
  459. m_pRc->left++;
  460. m_pRc->right++;
  461. }
  462. else if(m_pRc->Width ()>m_pRc->Height () && m_pRc->bottom<g_dm.dmPelsHeight)
  463. {
  464. m_pRc->top++;
  465. m_pRc->bottom++;
  466. }
  467. }
  468. }
  469. else if(m_mode==3)
  470. {
  471. m_rc.right++;
  472. m_rc.top--;
  473. {
  474. if(m_pRc->Width ()<m_pRc->Height () && m_pRc->left)
  475. {
  476. m_pRc->left--;
  477. m_pRc->right--;
  478. }
  479. else if(m_pRc->Width ()>m_pRc->Height () && m_pRc->bottom<g_dm.dmPelsHeight)
  480. {
  481. m_pRc->top++;
  482. m_pRc->bottom++;
  483. }
  484. }
  485. }
  486. else if(m_mode==4)
  487. {
  488. m_rc.left++;
  489. m_rc.bottom--;
  490. {
  491. if(m_pRc->Width ()<m_pRc->Height () && m_pRc->left)
  492. {
  493. m_pRc->left--;
  494. m_pRc->right--;
  495. }
  496. else if(m_pRc->Width ()>m_pRc->Height () && m_pRc->bottom<g_dm.dmPelsHeight)
  497. {
  498. m_pRc->top++;
  499. m_pRc->bottom++;
  500. }
  501. }
  502. }
  503. else if(m_mode==5)
  504. {
  505. m_rc.right--;
  506. m_rc.bottom--;
  507. {
  508. if(m_pRc->Width ()<m_pRc->Height () && m_pRc->right<g_dm.dmPelsWidth)
  509. {
  510. m_pRc->left++;
  511. m_pRc->right++;
  512. }
  513. else if(m_pRc->Width ()>m_pRc->Height () && m_pRc->bottom<g_dm.dmPelsHeight)
  514. {
  515. m_pRc->top++;
  516. m_pRc->bottom++;
  517. }
  518. }
  519. }
  520. else if(m_mode==6)
  521. {
  522. m_rc.left++;
  523. m_rc.top++;
  524. {
  525. if(m_pRc->Width ()<m_pRc->Height () && m_pRc->left)
  526. {
  527. m_pRc->left--;
  528. m_pRc->right--;
  529. }
  530. else if(m_pRc->Width ()>m_pRc->Height () && m_pRc->top)
  531. {
  532. m_pRc->top--;
  533. m_pRc->bottom--;
  534. }
  535. }
  536. }
  537. else if(m_mode==7)
  538. {
  539. m_rc.right--;
  540. m_rc.top++;
  541. {
  542. if(m_pRc->Width ()<m_pRc->Height () && m_pRc->right<g_dm.dmPelsWidth)
  543. {
  544. m_pRc->left++;
  545. m_pRc->right++;
  546. }
  547. else if(m_pRc->Width ()>m_pRc->Height () && m_pRc->top)
  548. {
  549. m_pRc->top--;
  550. m_pRc->bottom--;
  551. }
  552. }
  553. }
  554. Invalidate();
  555. }*/
  556. }
  557. BOOL MyAnimateWindow::ChenkOver()
  558. {
  559. if(m_times<80)return 0;
  560. m_pParent->SetTimer(1, 1, NULL);
  561. return 1;
  562. }
  563. void MyAnimateWindow::DrawEffect1(CDC *pDC)
  564. {
  565. try
  566. {
  567. GetClientRect(m_rcneedclear);
  568. // Graphics graph(m_pbmp);
  569. Graphics graph(pDC->GetSafeHdc ());
  570. int step=5;
  571. if(m_time<2000)
  572. step=5;
  573. else if(m_time<3000)
  574. step=3;
  575. else if(m_time<4000)
  576. step=2;
  577. else
  578. step=1;
  579. for(int i=0; i<80/step; i++)
  580. {
  581. if(m_bTerminate)break;
  582. // graph.Clear(Color(255,0,0,0));
  583. if(m_mode==0)
  584. {
  585. m_rc.left-=step;
  586. m_rc.bottom+=step;
  587. // if(m_times%3==0)
  588. {
  589. if(m_pRc->Width ()<m_pRc->Height () && m_pRc->right<g_dm.dmPelsWidth)
  590. {
  591. m_pRc->left++;
  592. m_pRc->right++;
  593. }
  594. else if(m_pRc->Width ()>m_pRc->Height () && m_pRc->top)
  595. {
  596. m_pRc->top--;
  597. m_pRc->bottom--;
  598. }
  599. }
  600. }
  601. else if(m_mode==1)
  602. {
  603. m_rc.right+=step;
  604. m_rc.bottom+=step;
  605. {
  606. if(m_pRc->Width ()<m_pRc->Height () && m_pRc->left)
  607. {
  608. m_pRc->left--;
  609. m_pRc->right--;
  610. }
  611. else if(m_pRc->Width ()>m_pRc->Height () && m_pRc->top)
  612. {
  613. m_pRc->top--;
  614. m_pRc->bottom--;
  615. }
  616. }
  617. }
  618. else if(m_mode==2)
  619. {
  620. m_rc.left-=step;
  621. m_rc.top-=step;
  622. {
  623. if(m_pRc->Width ()<m_pRc->Height () && m_pRc->right<g_dm.dmPelsWidth)
  624. {
  625. m_pRc->left++;
  626. m_pRc->right++;
  627. }
  628. else if(m_pRc->Width ()>m_pRc->Height () && m_pRc->bottom<g_dm.dmPelsHeight)
  629. {
  630. m_pRc->top++;
  631. m_pRc->bottom++;
  632. }
  633. }
  634. }
  635. else if(m_mode==3)
  636. {
  637. m_rc.right+=step;
  638. m_rc.top-=step;
  639. {
  640. if(m_pRc->Width ()<m_pRc->Height () && m_pRc->left)
  641. {
  642. m_pRc->left--;
  643. m_pRc->right--;
  644. }
  645. else if(m_pRc->Width ()>m_pRc->Height () && m_pRc->bottom<g_dm.dmPelsHeight)
  646. {
  647. m_pRc->top++;
  648. m_pRc->bottom++;
  649. }
  650. }
  651. }
  652. else if(m_mode==4)
  653. {
  654. m_rc.left+=step;
  655. m_rc.bottom-=step;
  656. {
  657. if(m_pRc->Width ()<m_pRc->Height () && m_pRc->left)
  658. {
  659. m_pRc->left--;
  660. m_pRc->right--;
  661. }
  662. else if(m_pRc->Width ()>m_pRc->Height () && m_pRc->bottom<g_dm.dmPelsHeight)
  663. {
  664. m_pRc->top++;
  665. m_pRc->bottom++;
  666. }
  667. }
  668. }
  669. else if(m_mode==5)
  670. {
  671. m_rc.right-=step;
  672. m_rc.bottom-=step;
  673. {
  674. if(m_pRc->Width ()<m_pRc->Height () && m_pRc->right<g_dm.dmPelsWidth)
  675. {
  676. m_pRc->left++;
  677. m_pRc->right++;
  678. }
  679. else if(m_pRc->Width ()>m_pRc->Height () && m_pRc->bottom<g_dm.dmPelsHeight)
  680. {
  681. m_pRc->top++;
  682. m_pRc->bottom++;
  683. }
  684. }
  685. }
  686. else if(m_mode==6)
  687. {
  688. m_rc.left+=step;
  689. m_rc.top+=step;
  690. {
  691. if(m_pRc->Width ()<m_pRc->Height () && m_pRc->left)
  692. {
  693. m_pRc->left--;
  694. m_pRc->right--;
  695. }
  696. else if(m_pRc->Width ()>m_pRc->Height () && m_pRc->top)
  697. {
  698. m_pRc->top--;
  699. m_pRc->bottom--;
  700. }
  701. }
  702. }
  703. else if(m_mode==7)
  704. {
  705. m_rc.right-=step;
  706. m_rc.top+=step;
  707. {
  708. if(m_pRc->Width ()<m_pRc->Height () && m_pRc->right<g_dm.dmPelsWidth)
  709. {
  710. m_pRc->left++;
  711. m_pRc->right++;
  712. }
  713. else if(m_pRc->Width ()>m_pRc->Height () && m_pRc->top)
  714. {
  715. m_pRc->top--;
  716. m_pRc->bottom--;
  717. }
  718. }
  719. }
  720. CRect rc,rc2;
  721. rc.IntersectRect(m_pRc, m_rcneedclear);
  722. rc2.left =m_rcneedclear.left ;
  723. rc2.top =rc.top ;
  724. rc2.right =rc.left ;
  725. rc2.bottom =rc.bottom ;
  726. pDC->FillSolidRect (rc2, 0);
  727. rc2.left =rc.right ;
  728. rc2.top =rc.top ;
  729. rc2.right =m_rcneedclear.right ;
  730. rc2.bottom =rc.bottom ;
  731. pDC->FillSolidRect (rc2, 0);
  732. rc2.left =rc.left ;
  733. rc2.top =m_rcneedclear.top ;
  734. rc2.right =rc.right ;
  735. rc2.bottom =rc.top ;
  736. pDC->FillSolidRect (rc2, 0);
  737. rc2.left =rc.left ;
  738. rc2.top =rc.bottom ;
  739. rc2.right =rc.right ;
  740. rc2.bottom =m_rcneedclear.bottom ;
  741. pDC->FillSolidRect (rc2, 0);
  742. m_rcneedclear=*m_pRc;
  743. if(m_bTerminate)break;
  744. Rect desRect(m_pRc->left , m_pRc->top , m_pRc->Width (), m_pRc->Height ());
  745. graph.DrawImage(m_pImg, desRect, m_rc.left , m_rc.top , m_rc.Width() , m_rc.Height() ,UnitPixel);
  746. // SleepEx( 10 );
  747. SleepEx( max(10,m_time/160) );
  748. // Sleep( 10 );
  749. }
  750. }
  751. catch(...)
  752. {
  753. }
  754. }
  755. BOOL MyAnimateWindow::TerminateThread()
  756. {
  757. try
  758. {
  759. if ( m_bRunning )
  760. {
  761. m_bTerminate=true;
  762. for( ; ; )
  763. {
  764. if ( ::WaitForSingleObject(m_hThread, 0) == WAIT_OBJECT_0 )
  765. break;
  766. MSG msg;
  767. while (::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
  768. {
  769. if (!AfxGetApp()->PumpMessage())
  770. break;
  771. }
  772. }
  773. ::CloseHandle(m_hThread);
  774. }
  775. if ( m_bRunning2 )
  776. {
  777. m_bTerminate2=true;
  778. for( ; ; )
  779. {
  780. if ( ::WaitForSingleObject(m_hThread2, 0) == WAIT_OBJECT_0 )
  781. break;
  782. MSG msg;
  783. while (::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
  784. {
  785. if (!AfxGetApp()->PumpMessage())
  786. break;
  787. }
  788. }
  789. ::CloseHandle(m_hThread2);
  790. }
  791. if ( m_bRunning3 )
  792. {
  793. m_bTerminate3=true;
  794. for( ; ; )
  795. {
  796. if ( ::WaitForSingleObject(m_hThread3, 0) == WAIT_OBJECT_0 )
  797. break;
  798. MSG msg;
  799. while (::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
  800. {
  801. if (!AfxGetApp()->PumpMessage())
  802. break;
  803. }
  804. }
  805. ::CloseHandle(m_hThread3);
  806. }
  807. return TRUE;
  808. }
  809. catch(...)
  810. {
  811. }
  812. }
  813. BOOL MyAnimateWindow::TerminateThread1()
  814. {
  815. try
  816. {
  817. if ( m_bRunning )
  818. {
  819. m_bTerminate=true;
  820. for( ; ; )
  821. {
  822. if ( ::WaitForSingleObject(m_hThread, 0) == WAIT_OBJECT_0 )
  823. break;
  824. MSG msg;
  825. while (::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
  826. {
  827. if (!AfxGetApp()->PumpMessage())
  828. break;
  829. }
  830. }
  831. ::CloseHandle(m_hThread);
  832. }
  833. return TRUE;
  834. }
  835. catch(...)
  836. {
  837. }
  838. }
  839. BOOL MyAnimateWindow::TerminateThread2()
  840. {
  841. try
  842. {
  843. if ( m_bRunning2 )
  844. {
  845. m_bTerminate2=true;
  846. for( ; ; )
  847. {
  848. if ( ::WaitForSingleObject(m_hThread2, 0) == WAIT_OBJECT_0 )
  849. break;
  850. MSG msg;
  851. while (::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
  852. {
  853. if (!AfxGetApp()->PumpMessage())
  854. break;
  855. }
  856. }
  857. ::CloseHandle(m_hThread2);
  858. }
  859. return TRUE;
  860. }
  861. catch(...)
  862. {
  863. }
  864. }
  865. BOOL MyAnimateWindow::TerminateThread3()
  866. {
  867. try
  868. {
  869. if ( m_bRunning3 )
  870. {
  871. m_bTerminate3=true;
  872. for( ; ; )
  873. {
  874. if ( ::WaitForSingleObject(m_hThread3, 0) == WAIT_OBJECT_0 )
  875. break;
  876. MSG msg;
  877. while (::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
  878. {
  879. if (!AfxGetApp()->PumpMessage())
  880. break;
  881. }
  882. }
  883. ::CloseHandle(m_hThread3);
  884. }
  885. return TRUE;
  886. }
  887. catch(...)
  888. {
  889. }
  890. }