Credits.cpp
资源名称:08.zip [点击查看]
上传用户:ynjin1970
上传日期:2014-10-13
资源大小:6438k
文件大小:12k
源码类别:
中间件编程
开发平台:
Visual C++
- #include "stdafx.h"
- #include "resource.h"
- #include "credits.h"
- #include <dos.h>
- #include <direct.h>
- #ifdef _DEBUG
- #undef THIS_FILE
- static char BASED_CODE THIS_FILE[] = __FILE__;
- #endif
- #define SCROLLAMOUNT -1
- #define DISPLAY_SLOW 70
- #define DISPLAY_MEDIUM 10
- #define DISPLAY_FAST 10
- #define DISPLAY_SPEED 30//DISPLAY_MEDIUM
- #define RED RGB(255,0,0)
- #define GREEN RGB(0,255,0)
- #define BLUE RGB(0,0,255)
- #define WHITE RGB(255,255,255)
- #define YELLOW RGB(255,255,0)
- #define TURQUOISE RGB(0,255,255)
- #define PURPLE RGB(255,0,255)
- #define BLACK RGB(0,0,0)
- #define BACKGROUND_COLOR BLACK
- #define TOP_LEVEL_TITLE_COLOR RED
- #define TOP_LEVEL_GROUP_COLOR YELLOW
- #define GROUP_TITLE_COLOR TURQUOISE
- #define NORMAL_TEXT_COLOR WHITE
- // You can set font heights here to suit your taste
- #define TOP_LEVEL_TITLE_HEIGHT 21
- #define TOP_LEVEL_GROUP_HEIGHT 19
- #define GROUP_TITLE_HEIGHT 17
- #define NORMAL_TEXT_HEIGHT 15
- #define TOP_LEVEL_TITLE 'n'
- #define TOP_LEVEL_GROUP 'r'
- #define GROUP_TITLE 't'
- #define NORMAL_TEXT 'f'
- #define DISPLAY_BITMAP 'b'
- #define ARRAYCOUNT 71
- char *pArrCredit[] = { "基于线程的多任务 n",
- "",
- "ZZJTHREADMANGER n",
- "",
- "",
- "Copyright (c) 2004 f",
- "",
- "锦州拓新电力电子公司 f",
- "",
- "All Rights Reserved f",
- "",
- "",
- "",
- "Serial of Product t",
- "",
- "",
- "ZZJ2004-0421 f",
- "",
- "",
- "BITMAP2b", // MYBITMAP is a quoted bitmap resource
- "",
- "",
- "Project Manager t",
- "",
- "张中军 f",
- "",
- "",
- "Program Designer t",
- "",
- "张中军 f",
- "",
- "",
- "Engineer t",
- "",
- "韩琳琳 张中军 f",
- "",
- "",
- "",
- "Address of Office t",
- "",
- "辽宁省锦州市凌河区和平路4段6号 f",
- "",
- "",
- "PostCode t",
- "",
- "121000 f",
- "",
- "",
- "Phone t",
- "",
- "0416-2141880 f",
- "",
- "",
- "Fax t",
- "",
- "0416-2124887 f",
- "",
- "",
- "BITMAP1b",
- "",
- "",
- "Thank for you to accept our products! t",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- ""
- };
- /////////////////////////////////////////////////////////////////////////////
- // CCredits dialog
- CCredits::CCredits(CWnd* pParent /*=NULL*/)
- : CDialog(CCredits::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CCredits)
- m_total = _T("");
- m_freedisk = _T("");
- //}}AFX_DATA_INIT
- }
- void CCredits::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CCredits)
- DDX_Text(pDX, IDC_TATOL, m_total);
- DDX_Text(pDX, IDC_FREEDISK, m_freedisk);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CCredits, CDialog)
- //{{AFX_MSG_MAP(CCredits)
- ON_WM_PAINT()
- ON_WM_TIMER()
- ON_WM_DESTROY()
- ON_WM_LBUTTONUP()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CCredits message handlers
- void CCredits::OnOK()
- {
- KillTimer(DISPLAY_TIMER_ID);
- CDialog::OnOK();
- }
- BOOL CCredits::OnInitDialog()
- {
- CDialog::OnInitDialog();
- BOOL bRet;
- UINT nRet;
- CString strFmt;
- MEMORYSTATUS MemStat;
- MemStat.dwLength = sizeof(MEMORYSTATUS);
- GlobalMemoryStatus(&MemStat);
- strFmt.LoadString(CG_IDS_PHYSICAL_MEM);
- m_total.Format(strFmt, MemStat.dwTotalPhys / 1024L);
- //m_used.Format(strFmt,MemStat.dwMemoryLoad);///1024L);
- //m_free.Format(strFmt,MemStat.dwAvailPhys);///MemStat.dwTotalPhys*1000);
- //TODO: Add a static control to your About Box to receive the memory
- // information. Initialize the control with code like this:
- // SetDlgItemText(IDC_PHYSICAL_MEM, strFreeMemory);
- // Fill disk free information
- struct _diskfree_t diskfree;
- int nDrive = _getdrive(); // use current default drive
- if (_getdiskfree(nDrive, &diskfree) == 0)
- {
- strFmt.LoadString(CG_IDS_DISK_SPACE);
- m_freedisk.Format(strFmt,
- (DWORD)diskfree.avail_clusters *
- (DWORD)diskfree.sectors_per_cluster *
- (DWORD)diskfree.bytes_per_sector / (DWORD)1024L / (DWORD)1024L,
- nDrive-1 + _T('A'));
- }
- else
- m_freedisk.LoadString(CG_IDS_DISK_SPACE_UNAVAIL);
- UpdateData(FALSE);
- nCurrentFontHeight = NORMAL_TEXT_HEIGHT;
- CClientDC dc(this);
- bRet = m_dcMem.CreateCompatibleDC(&dc);
- m_bProcessingBitmap=FALSE;
- nArrIndex=0;
- nCounter=1;
- nClip=0;
- m_bFirstTime=TRUE;
- m_bDrawText=FALSE;
- m_hBmpOld = 0;
- number=0;
- m_pDisplayFrame=(CWnd*)GetDlgItem(IDC_DISPLAY_STATIC);
- _ASSERTE(m_pDisplayFrame);
- m_pDisplayFrame->GetClientRect(&m_ScrollRect);
- nRet = SetTimer(DISPLAY_TIMER_ID,DISPLAY_SPEED,NULL);
- _ASSERTE(nRet != 0);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void CCredits::OnTimer(UINT nIDEvent)
- {
- if (nIDEvent != DISPLAY_TIMER_ID)
- {
- CDialog::OnTimer(nIDEvent);
- return;
- }
- if (!m_bProcessingBitmap)
- if (nCounter++ % nCurrentFontHeight == 0) // every x timer events, show new line
- {
- nCounter=1;
- m_szWork = pArrCredit[nArrIndex++];
- if (nArrIndex > ARRAYCOUNT-1)
- {
- number++;
- if(number==2)
- {
- KillTimer(DISPLAY_TIMER_ID);
- CDialog::OnOK();
- return;
- }
- nArrIndex=0;
- }
- nClip = 0;
- m_bDrawText=TRUE;
- }
- m_pDisplayFrame->ScrollWindow(0,SCROLLAMOUNT,&m_ScrollRect,&m_ScrollRect);
- nClip = nClip + abs(SCROLLAMOUNT);
- CRect r;
- CWnd* pWnd = GetDlgItem(IDC_DISPLAY_STATIC);
- ASSERT_VALID(pWnd);
- pWnd->GetClientRect(&r);
- pWnd->ClientToScreen(r);
- ScreenToClient(&r);
- InvalidateRect(r,FALSE); // FALSE does not erase background
- CDialog::OnTimer(nIDEvent);
- }
- void CCredits::OnPaint()
- {
- CPaintDC dc(this); // device context for painting
- PAINTSTRUCT ps;
- CDC* pDc = m_pDisplayFrame->BeginPaint(&ps);
- pDc->SetBkMode(TRANSPARENT);
- int flag=0;
- //*********************************************************************
- // FONT SELECTION
- CFont m_fntArial;
- CFont* pOldFont;
- BOOL bSuccess;
- BOOL bUnderline;
- BOOL bItalic;
- if (!m_szWork.IsEmpty())
- switch (m_szWork[m_szWork.GetLength()-1] )
- {
- case NORMAL_TEXT:
- default:
- bItalic = FALSE;
- bUnderline = FALSE;
- nCurrentFontHeight = NORMAL_TEXT_HEIGHT;
- bSuccess = m_fntArial.CreateFont(NORMAL_TEXT_HEIGHT, 0, 0, 0,
- FW_THIN, bItalic, bUnderline, 0,
- ANSI_CHARSET,
- OUT_DEFAULT_PRECIS,
- CLIP_DEFAULT_PRECIS,
- PROOF_QUALITY,
- VARIABLE_PITCH | 0x04 | FF_DONTCARE,
- (LPSTR)"Arial");
- pDc->SetTextColor(NORMAL_TEXT_COLOR);
- pOldFont = pDc->SelectObject(&m_fntArial);
- break;
- case TOP_LEVEL_GROUP:
- bItalic = FALSE;
- bUnderline = FALSE;
- nCurrentFontHeight = TOP_LEVEL_GROUP_HEIGHT;
- bSuccess = m_fntArial.CreateFont(TOP_LEVEL_GROUP_HEIGHT, 0, 0, 0,
- FW_BOLD, bItalic, bUnderline, 0,
- ANSI_CHARSET,
- OUT_DEFAULT_PRECIS,
- CLIP_DEFAULT_PRECIS,
- PROOF_QUALITY,
- VARIABLE_PITCH | 0x04 | FF_DONTCARE,
- (LPSTR)"Arial");
- pDc->SetTextColor(TOP_LEVEL_GROUP_COLOR);
- pOldFont = pDc->SelectObject(&m_fntArial);
- break;
- case GROUP_TITLE:
- bItalic = FALSE;
- bUnderline = FALSE;
- nCurrentFontHeight = GROUP_TITLE_HEIGHT;
- bSuccess = m_fntArial.CreateFont(GROUP_TITLE_HEIGHT, 0, 0, 0,
- FW_BOLD, bItalic, bUnderline, 0,
- ANSI_CHARSET,
- OUT_DEFAULT_PRECIS,
- CLIP_DEFAULT_PRECIS,
- PROOF_QUALITY,
- VARIABLE_PITCH | 0x04 | FF_DONTCARE,
- (LPSTR)"Arial");
- pDc->SetTextColor(GROUP_TITLE_COLOR);
- pOldFont = pDc->SelectObject(&m_fntArial);
- break;
- case TOP_LEVEL_TITLE:
- bItalic = FALSE;
- bUnderline = TRUE;
- nCurrentFontHeight = TOP_LEVEL_TITLE_HEIGHT;
- bSuccess = m_fntArial.CreateFont(TOP_LEVEL_TITLE_HEIGHT, 0, 0, 0,
- FW_BOLD, bItalic, bUnderline, 0,
- ANSI_CHARSET,//DEFAULT_CHARSET,//
- OUT_CHARACTER_PRECIS,CLIP_CHARACTER_PRECIS,
- OUT_DEFAULT_PRECIS,
- CLIP_DEFAULT_PRECIS,
- //DEFAULT_QUALITY,DEFAULT_PITCH|FF_DONTCARE,
- //PROOF_QUALITY,
- //VARIABLE_PITCH | 0x04 | FF_DONTCARE,
- (LPSTR)"华文彩云");//隶书");//The New Times");//
- pDc->SetTextColor(TOP_LEVEL_TITLE_COLOR);
- pOldFont = pDc->SelectObject(&m_fntArial);
- /*
- bItalic = FALSE;
- bUnderline = TRUE;
- nCurrentFontHeight = TOP_LEVEL_TITLE_HEIGHT;
- bSuccess = m_fntArial.CreateFont(TOP_LEVEL_TITLE_HEIGHT, 0, 0, 0,
- FW_BOLD, bItalic, bUnderline, 0,
- ANSI_CHARSET,
- OUT_DEFAULT_PRECIS,
- CLIP_DEFAULT_PRECIS,
- PROOF_QUALITY,
- VARIABLE_PITCH | 0x04 | FF_DONTCARE,
- (LPSTR)"华文彩云");
- pDc->SetTextColor(TOP_LEVEL_TITLE_COLOR);
- pOldFont = pDc->SelectObject(&m_fntArial);
- */
- break;
- case DISPLAY_BITMAP:
- if (!m_bProcessingBitmap)
- {
- CString szBitmap = m_szWork.Left(m_szWork.GetLength()-1);
- if (!m_bmpWork.LoadBitmap((const char *)szBitmap))
- {
- CString str;
- str.Format("Could not find bitmap resource "%s". "
- "Be sure to assign the bitmap a QUOTED resource name", szBitmap);
- KillTimer(DISPLAY_TIMER_ID);
- MessageBox(str);
- return;
- }
- m_bmpCurrent = &m_bmpWork;
- m_bmpCurrent->GetObject(sizeof(BITMAP), &m_bmpInfo);
- m_size.cx = m_bmpInfo.bmWidth; // width of dest rect
- RECT workRect;
- m_pDisplayFrame->GetClientRect(&workRect);
- m_pDisplayFrame->ClientToScreen(&workRect);
- ScreenToClient(&workRect);
- // upper left point of dest
- m_pt.x = (workRect.right -
- ((workRect.right-workRect.left)/2) - (m_bmpInfo.bmWidth/2));
- m_pt.y = workRect.bottom;
- pBmpOld = m_dcMem.SelectObject(m_bmpCurrent);
- if (m_hBmpOld == 0)
- m_hBmpOld = (HBITMAP) pBmpOld->GetSafeHandle();
- m_bProcessingBitmap = TRUE;
- }
- flag=1;
- break;
- }
- CBrush bBrush(BLACK);
- CBrush* pOldBrush;
- pOldBrush = pDc->SelectObject(&bBrush);
- // Only fill rect comprised of gap left by bottom of scrolling window
- r=m_ScrollRect;
- r.top = r.bottom-abs(SCROLLAMOUNT);
- pDc->DPtoLP(&r);
- if (m_bFirstTime)
- {
- m_bFirstTime=FALSE;
- pDc->FillRect(&m_ScrollRect,&bBrush);
- }
- else
- pDc->FillRect(&r,&bBrush);
- r=m_ScrollRect;
- r.top = r.bottom-nClip;
- if (!m_bProcessingBitmap)
- {
- int x = pDc->DrawText((const char *)m_szWork,m_szWork.GetLength()-1,&r,DT_TOP|DT_CENTER|
- DT_NOPREFIX | DT_SINGLELINE);
- m_bDrawText=FALSE;
- }
- else
- {
- dc.StretchBlt( m_pt.x, m_pt.y-nClip, m_size.cx, nClip,
- &m_dcMem, 0, 0, m_bmpInfo.bmWidth-1, nClip,
- SRCCOPY );
- if (nClip > m_bmpInfo.bmHeight)
- {
- m_bmpWork.DeleteObject();
- m_bProcessingBitmap = FALSE;
- nClip=0;
- m_szWork.Empty();
- nCounter=1;
- }
- pDc->SelectObject(pOldBrush);
- bBrush.DeleteObject();
- m_pDisplayFrame->EndPaint(&ps);
- return;
- }
- pDc->SelectObject(pOldBrush);
- bBrush.DeleteObject();
- if (!m_szWork.IsEmpty())
- {
- pDc->SelectObject(pOldFont);
- m_fntArial.DeleteObject();
- }
- m_pDisplayFrame->EndPaint(&ps);
- // Do not call CDialog::OnPaint() for painting messages
- }
- void CCredits::OnDestroy()
- {
- CDialog::OnDestroy();
- m_dcMem.SelectObject(CBitmap::FromHandle(m_hBmpOld));
- m_bmpWork.DeleteObject();
- }
- void CCredits::OnLButtonUp(UINT nFlags, CPoint point)
- {
- // TODO: Add your message handler code here and/or call default
- CDialog::OnLButtonUp(nFlags, point);
- KillTimer(DISPLAY_TIMER_ID);
- CDialog::OnOK();
- }