Credits.cpp
上传用户:ynjin1970
上传日期:2014-10-13
资源大小:6438k
文件大小:12k
源码类别:

中间件编程

开发平台:

Visual C++

  1. #include "stdafx.h"
  2. #include "resource.h"
  3. #include "credits.h"
  4. #include <dos.h>
  5. #include <direct.h>
  6. #ifdef _DEBUG
  7. #undef THIS_FILE
  8. static char BASED_CODE THIS_FILE[] = __FILE__;
  9. #endif
  10. #define SCROLLAMOUNT -1
  11. #define DISPLAY_SLOW 70
  12. #define DISPLAY_MEDIUM 10
  13. #define DISPLAY_FAST 10
  14. #define DISPLAY_SPEED 30//DISPLAY_MEDIUM
  15. #define RED RGB(255,0,0)
  16. #define GREEN RGB(0,255,0)
  17. #define BLUE RGB(0,0,255)
  18. #define WHITE    RGB(255,255,255)
  19. #define YELLOW   RGB(255,255,0)
  20. #define TURQUOISE  RGB(0,255,255)
  21. #define PURPLE   RGB(255,0,255)
  22. #define BLACK        RGB(0,0,0)
  23. #define BACKGROUND_COLOR        BLACK
  24. #define TOP_LEVEL_TITLE_COLOR RED
  25. #define TOP_LEVEL_GROUP_COLOR   YELLOW
  26. #define GROUP_TITLE_COLOR       TURQUOISE
  27. #define NORMAL_TEXT_COLOR WHITE
  28. // You can set font heights here to suit your taste
  29. #define TOP_LEVEL_TITLE_HEIGHT 21
  30. #define TOP_LEVEL_GROUP_HEIGHT  19     
  31. #define GROUP_TITLE_HEIGHT     17     
  32. #define NORMAL_TEXT_HEIGHT 15
  33. #define TOP_LEVEL_TITLE 'n'
  34. #define TOP_LEVEL_GROUP         'r'
  35. #define GROUP_TITLE            't'
  36. #define NORMAL_TEXT 'f' 
  37. #define DISPLAY_BITMAP 'b'
  38. #define ARRAYCOUNT 71
  39. char *pArrCredit[] = {  "基于线程的多任务 n",
  40. "",
  41. "ZZJTHREADMANGER n",
  42. "",
  43. "",
  44. "Copyright (c) 2004 f",
  45. "",
  46. "锦州拓新电力电子公司 f",
  47. "",
  48. "All Rights Reserved f",
  49. "",
  50. "",
  51. "",
  52. "Serial of Product t",
  53. "",
  54. "",
  55. "ZZJ2004-0421 f",
  56. "",
  57. "",
  58. "BITMAP2b",    // MYBITMAP is a quoted bitmap resource 
  59. "",
  60. "",
  61. "Project Manager t",
  62. "",
  63. "张中军 f", 
  64. "",
  65. "",
  66. "Program Designer t",
  67. "",
  68. "张中军 f",
  69. "",
  70. "",
  71. "Engineer t",
  72. "",
  73. "韩琳琳  张中军 f",
  74. "",
  75. "",
  76. "",
  77. "Address of Office t",
  78. "",
  79. "辽宁省锦州市凌河区和平路4段6号 f",
  80. "",
  81. "",
  82. "PostCode t",
  83. "",
  84. "121000 f",
  85. "",
  86. "",
  87. "Phone t",
  88. "",
  89. "0416-2141880 f",
  90. "",
  91. "",
  92. "Fax t",
  93. "",
  94. "0416-2124887 f",
  95. "",
  96. "",
  97. "BITMAP1b",
  98. "",
  99. "",
  100. "Thank for you to accept our products! t",
  101. "",
  102. "",
  103. "",
  104. "",
  105. "",
  106. "",
  107. "",
  108. ""
  109. };
  110. /////////////////////////////////////////////////////////////////////////////
  111. // CCredits dialog
  112. CCredits::CCredits(CWnd* pParent /*=NULL*/)
  113. : CDialog(CCredits::IDD, pParent)
  114. {
  115. //{{AFX_DATA_INIT(CCredits)
  116. m_total = _T("");
  117. m_freedisk = _T("");
  118. //}}AFX_DATA_INIT
  119. }
  120. void CCredits::DoDataExchange(CDataExchange* pDX)
  121. {
  122. CDialog::DoDataExchange(pDX);
  123. //{{AFX_DATA_MAP(CCredits)
  124. DDX_Text(pDX, IDC_TATOL, m_total);
  125. DDX_Text(pDX, IDC_FREEDISK, m_freedisk);
  126. //}}AFX_DATA_MAP
  127. }
  128. BEGIN_MESSAGE_MAP(CCredits, CDialog)
  129. //{{AFX_MSG_MAP(CCredits)
  130. ON_WM_PAINT()
  131. ON_WM_TIMER()
  132. ON_WM_DESTROY()
  133. ON_WM_LBUTTONUP()
  134. //}}AFX_MSG_MAP
  135. END_MESSAGE_MAP()
  136. /////////////////////////////////////////////////////////////////////////////
  137. // CCredits message handlers
  138. void CCredits::OnOK() 
  139. {
  140. KillTimer(DISPLAY_TIMER_ID);
  141. CDialog::OnOK();
  142. }
  143. BOOL CCredits::OnInitDialog() 
  144. {
  145. CDialog::OnInitDialog();
  146. BOOL bRet;
  147.     UINT nRet;
  148. CString strFmt;
  149. MEMORYSTATUS MemStat;
  150. MemStat.dwLength = sizeof(MEMORYSTATUS);
  151. GlobalMemoryStatus(&MemStat);
  152. strFmt.LoadString(CG_IDS_PHYSICAL_MEM);
  153. m_total.Format(strFmt, MemStat.dwTotalPhys / 1024L);
  154. //m_used.Format(strFmt,MemStat.dwMemoryLoad);///1024L);
  155. //m_free.Format(strFmt,MemStat.dwAvailPhys);///MemStat.dwTotalPhys*1000);
  156. //TODO: Add a static control to your About Box to receive the memory
  157. //      information.  Initialize the control with code like this:
  158. // SetDlgItemText(IDC_PHYSICAL_MEM, strFreeMemory);
  159. // Fill disk free information
  160. struct _diskfree_t diskfree;
  161. int nDrive = _getdrive(); // use current default drive
  162. if (_getdiskfree(nDrive, &diskfree) == 0)
  163. {
  164. strFmt.LoadString(CG_IDS_DISK_SPACE);
  165. m_freedisk.Format(strFmt,
  166. (DWORD)diskfree.avail_clusters *
  167. (DWORD)diskfree.sectors_per_cluster *
  168. (DWORD)diskfree.bytes_per_sector / (DWORD)1024L / (DWORD)1024L,
  169. nDrive-1 + _T('A'));
  170. }
  171. else
  172. m_freedisk.LoadString(CG_IDS_DISK_SPACE_UNAVAIL);
  173. UpdateData(FALSE);
  174. nCurrentFontHeight = NORMAL_TEXT_HEIGHT;
  175. CClientDC dc(this); 
  176. bRet = m_dcMem.CreateCompatibleDC(&dc);
  177. m_bProcessingBitmap=FALSE;
  178. nArrIndex=0;
  179. nCounter=1;
  180. nClip=0;
  181. m_bFirstTime=TRUE;
  182. m_bDrawText=FALSE;
  183. m_hBmpOld = 0;
  184. number=0;
  185. m_pDisplayFrame=(CWnd*)GetDlgItem(IDC_DISPLAY_STATIC);
  186. _ASSERTE(m_pDisplayFrame);
  187.  
  188. m_pDisplayFrame->GetClientRect(&m_ScrollRect);
  189. nRet = SetTimer(DISPLAY_TIMER_ID,DISPLAY_SPEED,NULL);
  190.     _ASSERTE(nRet != 0);
  191. return TRUE;  // return TRUE unless you set the focus to a control
  192.               // EXCEPTION: OCX Property Pages should return FALSE
  193. }
  194. void CCredits::OnTimer(UINT nIDEvent) 
  195. {
  196. if (nIDEvent != DISPLAY_TIMER_ID)
  197. {
  198. CDialog::OnTimer(nIDEvent);
  199. return;
  200. }
  201. if (!m_bProcessingBitmap)
  202. if (nCounter++ % nCurrentFontHeight == 0)  // every x timer events, show new line
  203. {
  204. nCounter=1;
  205. m_szWork = pArrCredit[nArrIndex++];
  206. if (nArrIndex > ARRAYCOUNT-1)
  207. {
  208. number++;
  209. if(number==2)
  210. {
  211. KillTimer(DISPLAY_TIMER_ID);
  212. CDialog::OnOK();
  213. return;
  214. }
  215. nArrIndex=0;
  216. }
  217. nClip = 0;
  218. m_bDrawText=TRUE;
  219. }
  220. m_pDisplayFrame->ScrollWindow(0,SCROLLAMOUNT,&m_ScrollRect,&m_ScrollRect);
  221. nClip = nClip + abs(SCROLLAMOUNT);
  222.     CRect r;
  223.     CWnd* pWnd = GetDlgItem(IDC_DISPLAY_STATIC);
  224.     ASSERT_VALID(pWnd);
  225.     pWnd->GetClientRect(&r);
  226.     pWnd->ClientToScreen(r);
  227.     ScreenToClient(&r);
  228.     InvalidateRect(r,FALSE); // FALSE does not erase background
  229. CDialog::OnTimer(nIDEvent);
  230. }
  231. void CCredits::OnPaint() 
  232. {
  233. CPaintDC dc(this); // device context for painting
  234. PAINTSTRUCT ps;
  235. CDC* pDc = m_pDisplayFrame->BeginPaint(&ps);
  236. pDc->SetBkMode(TRANSPARENT);
  237. int flag=0;
  238. //*********************************************************************
  239. // FONT SELECTION
  240.      CFont m_fntArial;
  241. CFont* pOldFont;
  242. BOOL bSuccess;
  243. BOOL bUnderline;
  244. BOOL bItalic;
  245. if (!m_szWork.IsEmpty())
  246. switch (m_szWork[m_szWork.GetLength()-1] )
  247. {
  248. case NORMAL_TEXT:
  249. default:
  250. bItalic = FALSE;
  251. bUnderline = FALSE;
  252. nCurrentFontHeight = NORMAL_TEXT_HEIGHT;
  253.     bSuccess = m_fntArial.CreateFont(NORMAL_TEXT_HEIGHT, 0, 0, 0, 
  254.     FW_THIN, bItalic, bUnderline, 0, 
  255.     ANSI_CHARSET,
  256.                                 OUT_DEFAULT_PRECIS,
  257.                                 CLIP_DEFAULT_PRECIS,
  258.                                 PROOF_QUALITY,
  259.                                 VARIABLE_PITCH | 0x04 | FF_DONTCARE,
  260.                                 (LPSTR)"Arial");
  261. pDc->SetTextColor(NORMAL_TEXT_COLOR);
  262. pOldFont  = pDc->SelectObject(&m_fntArial);
  263. break;
  264. case TOP_LEVEL_GROUP:
  265. bItalic = FALSE;
  266. bUnderline = FALSE;
  267. nCurrentFontHeight = TOP_LEVEL_GROUP_HEIGHT;
  268.     bSuccess = m_fntArial.CreateFont(TOP_LEVEL_GROUP_HEIGHT, 0, 0, 0, 
  269.     FW_BOLD, bItalic, bUnderline, 0, 
  270.     ANSI_CHARSET,
  271.                                 OUT_DEFAULT_PRECIS,
  272.                                 CLIP_DEFAULT_PRECIS,
  273.                                 PROOF_QUALITY,
  274.                                 VARIABLE_PITCH | 0x04 | FF_DONTCARE,
  275.                                 (LPSTR)"Arial");
  276. pDc->SetTextColor(TOP_LEVEL_GROUP_COLOR);
  277. pOldFont  = pDc->SelectObject(&m_fntArial);
  278. break;
  279. case GROUP_TITLE:
  280. bItalic = FALSE;
  281. bUnderline = FALSE;
  282. nCurrentFontHeight = GROUP_TITLE_HEIGHT;
  283.     bSuccess = m_fntArial.CreateFont(GROUP_TITLE_HEIGHT, 0, 0, 0, 
  284.     FW_BOLD, bItalic, bUnderline, 0, 
  285.     ANSI_CHARSET,
  286.                                 OUT_DEFAULT_PRECIS,
  287.                                 CLIP_DEFAULT_PRECIS,
  288.                                 PROOF_QUALITY,
  289.                                 VARIABLE_PITCH | 0x04 | FF_DONTCARE,
  290.                                 (LPSTR)"Arial");
  291. pDc->SetTextColor(GROUP_TITLE_COLOR);
  292. pOldFont  = pDc->SelectObject(&m_fntArial);
  293. break;
  294. case TOP_LEVEL_TITLE:
  295. bItalic = FALSE;
  296. bUnderline = TRUE;
  297. nCurrentFontHeight = TOP_LEVEL_TITLE_HEIGHT;
  298. bSuccess = m_fntArial.CreateFont(TOP_LEVEL_TITLE_HEIGHT, 0, 0, 0, 
  299. FW_BOLD, bItalic, bUnderline, 0, 
  300. ANSI_CHARSET,//DEFAULT_CHARSET,//
  301.                             OUT_CHARACTER_PRECIS,CLIP_CHARACTER_PRECIS,
  302. OUT_DEFAULT_PRECIS,
  303.                             CLIP_DEFAULT_PRECIS,
  304.                             //DEFAULT_QUALITY,DEFAULT_PITCH|FF_DONTCARE,
  305. //PROOF_QUALITY,
  306.                             //VARIABLE_PITCH | 0x04 | FF_DONTCARE,
  307.                             (LPSTR)"华文彩云");//隶书");//The New Times");//
  308. pDc->SetTextColor(TOP_LEVEL_TITLE_COLOR);
  309. pOldFont  = pDc->SelectObject(&m_fntArial);
  310. /*
  311. bItalic = FALSE;
  312. bUnderline = TRUE;
  313. nCurrentFontHeight = TOP_LEVEL_TITLE_HEIGHT;
  314. bSuccess = m_fntArial.CreateFont(TOP_LEVEL_TITLE_HEIGHT, 0, 0, 0, 
  315. FW_BOLD, bItalic, bUnderline, 0, 
  316. ANSI_CHARSET,
  317.                             OUT_DEFAULT_PRECIS,
  318.                             CLIP_DEFAULT_PRECIS,
  319.                             PROOF_QUALITY,
  320.                             VARIABLE_PITCH | 0x04 | FF_DONTCARE,
  321.                             (LPSTR)"华文彩云");
  322. pDc->SetTextColor(TOP_LEVEL_TITLE_COLOR);
  323. pOldFont  = pDc->SelectObject(&m_fntArial);
  324.     */
  325.  break;
  326. case DISPLAY_BITMAP:
  327. if (!m_bProcessingBitmap)
  328. {
  329. CString szBitmap = m_szWork.Left(m_szWork.GetLength()-1);
  330.     if (!m_bmpWork.LoadBitmap((const char *)szBitmap))
  331. {
  332. CString str; 
  333. str.Format("Could not find bitmap resource "%s". "
  334.                                "Be sure to assign the bitmap a QUOTED resource name", szBitmap); 
  335. KillTimer(DISPLAY_TIMER_ID); 
  336. MessageBox(str); 
  337. return; 
  338. }
  339. m_bmpCurrent = &m_bmpWork;
  340.     m_bmpCurrent->GetObject(sizeof(BITMAP), &m_bmpInfo);
  341. m_size.cx = m_bmpInfo.bmWidth; // width  of dest rect
  342. RECT workRect;
  343. m_pDisplayFrame->GetClientRect(&workRect);
  344. m_pDisplayFrame->ClientToScreen(&workRect);
  345. ScreenToClient(&workRect);
  346. // upper left point of dest
  347. m_pt.x = (workRect.right - 
  348. ((workRect.right-workRect.left)/2) - (m_bmpInfo.bmWidth/2));
  349. m_pt.y = workRect.bottom;
  350. pBmpOld = m_dcMem.SelectObject(m_bmpCurrent);
  351. if (m_hBmpOld == 0)
  352. m_hBmpOld = (HBITMAP) pBmpOld->GetSafeHandle();
  353. m_bProcessingBitmap = TRUE;
  354. }
  355. flag=1;
  356. break;
  357. }
  358. CBrush bBrush(BLACK);
  359. CBrush* pOldBrush;
  360. pOldBrush  = pDc->SelectObject(&bBrush);
  361. // Only fill rect comprised of gap left by bottom of scrolling window
  362. r=m_ScrollRect;
  363. r.top = r.bottom-abs(SCROLLAMOUNT); 
  364. pDc->DPtoLP(&r);
  365. if (m_bFirstTime)
  366. {
  367. m_bFirstTime=FALSE;
  368. pDc->FillRect(&m_ScrollRect,&bBrush);
  369. }
  370. else
  371. pDc->FillRect(&r,&bBrush);
  372. r=m_ScrollRect;
  373. r.top = r.bottom-nClip;
  374. if (!m_bProcessingBitmap)
  375. {
  376. int x = pDc->DrawText((const char *)m_szWork,m_szWork.GetLength()-1,&r,DT_TOP|DT_CENTER|
  377. DT_NOPREFIX | DT_SINGLELINE);
  378. m_bDrawText=FALSE;
  379. }
  380. else
  381. {
  382.      dc.StretchBlt( m_pt.x, m_pt.y-nClip, m_size.cx, nClip, 
  383.                     &m_dcMem, 0, 0, m_bmpInfo.bmWidth-1, nClip,
  384.                     SRCCOPY );
  385. if (nClip > m_bmpInfo.bmHeight)
  386. {
  387. m_bmpWork.DeleteObject();
  388. m_bProcessingBitmap = FALSE;
  389. nClip=0;
  390. m_szWork.Empty();
  391. nCounter=1;
  392. }
  393. pDc->SelectObject(pOldBrush);
  394. bBrush.DeleteObject();
  395. m_pDisplayFrame->EndPaint(&ps);
  396. return;
  397. }
  398. pDc->SelectObject(pOldBrush);
  399. bBrush.DeleteObject();
  400. if (!m_szWork.IsEmpty())
  401. {
  402. pDc->SelectObject(pOldFont);
  403. m_fntArial.DeleteObject();
  404. }
  405. m_pDisplayFrame->EndPaint(&ps);
  406. // Do not call CDialog::OnPaint() for painting messages
  407. }
  408. void CCredits::OnDestroy() 
  409. {
  410. CDialog::OnDestroy();
  411.     m_dcMem.SelectObject(CBitmap::FromHandle(m_hBmpOld));
  412.     m_bmpWork.DeleteObject();
  413. }
  414. void CCredits::OnLButtonUp(UINT nFlags, CPoint point) 
  415. {
  416. // TODO: Add your message handler code here and/or call default
  417. CDialog::OnLButtonUp(nFlags, point);
  418. KillTimer(DISPLAY_TIMER_ID);
  419. CDialog::OnOK();
  420. }