/*******************************************************************************
JMatrixCtrl.h
To use this class, simply create it and call AddTextLine() for each
line of text to display. You can specify a page break with a line
that looks like "\x01 T", where T is a positive integer specifying
how long to wait before starting on the next page.
The default behavior is as close to the actual Matrix credits as I
could manager. You can obtain a range of different effects with
the following settings:
SetIntervals(const int intro, const int restart)
Specifies how many seconds to wait before displaying the first
page, and how long to wait before restarting after all pages
have been displayed.
SetCursor(const BOOL show, const BOOL solid)
With no cursor, each line is drawn all at once and then begins
to phase in. Otherwise, the text appears as the cursor moves.
If the cursor is not solid, it is a randomly changing character.
SetMaxPhaseCount(const int maxCount)
Specifies the maximum number of iterations before a character
is forced to the correct value. A character stops changing when
it hits the correct value or exceeds maxCount. Specify a huge
value to let the characters phase in "naturally". Specify zero
to simply display the text.
AllowEuropeanChars(const BOOL allow)
The disadvantage of allowing European characters is that it takes
*much* longer for the text to phase in when SetMaxPhaseCount()
is called with a very large value.
Written by John Lindal.
http://www.alumni.caltech.edu/~jafl/
Inspired by CMatrixCtrl written by Pablo van der Meer.
http://www.pablovandermeer.nl
License: Do what ever you want with it.
If you improve it, please let me know.
*******************************************************************************/
#include "StdAfx.h"
#include "JMatrixCtrl.h"
#include <float.h>
// The following parameters can be tweaked to produce different effects.
// They are not included in the API because they are too obscure for the
// casual user.
const int kColSpacing = 2; // pixels between columns
const int kAnimateTextInterval = 10; // milliseconds
const int kMoveCursorInterval = 40; // milliseconds
const int kAnimateBkgdInterval = 80; // milliseconds
const float kSpinCharFraction = 0.2f; // fraction of columns with spinning character
const int kMinSpinCount = 300; // centiseconds
const int kMaxSpinCount = 800; // centiseconds
const COLORREF kTextColor = RGB(128, 255, 128);
const int kBrightGreen = 255; // out of 255
const int kMinGreen = 75; // out of 255
const int kMaxGreen = 150; // out of 255
/*
const COLORREF kTextColor = RGB(0, 255, 0);
const int kBrightGreen = 210; // out of 255
const int kMinGreen = 60; // out of 255
const int kMaxGreen = 100; // out of 255
*/
const char kPageBreak = '\x01';
const char kBlockCursorChar = '\x01';
enum
{
kInitTextID,
kUpdateTextID,
kUpdateCursorID,
kUpdateBackgroundID,
kUpdateSpinID // only runs when kUpdateTextID does not run to minimize redraws
};
#define getrandom(min,max) ((rand()%(int)(((max)+1)-(min)))+(min))
/*******************************************************************************
Constructor
*******************************************************************************/
JMatrixCtrl::JMatrixCtrl()
:
m_MaxChar('\xFF'),
m_IntroInterval(5),
m_RestartInterval(5),
m_nMaxPhaseCount(20),
m_bShowCursor(TRUE),
m_CursorChar(kBlockCursorChar),
m_nPageStartLine(0),
m_nActiveLine(-1),
m_pFontOld(NULL),
m_pBitmapOld(NULL),
m_pMatrixColumns(NULL),
m_nActiveColumns(0),
m_pSpinChars(NULL),
m_nActiveSpins(0),
m_nTotalSpins(0),
m_pBackFontOld(NULL),
m_pBackBitmapOld(NULL)
{
srand((unsigned int) time(NULL));
}
/*******************************************************************************
Destructor
*******************************************************************************/
JMatrixCtrl::~JMatrixCtrl()
{
if (m_pBitmapOld != NULL)
{
m_DC.SelectObject(m_pBitmapOld);
}
if (m_pFontOld != NULL)
{
m_DC.SelectObject(m_pFontOld);
}
if (m_pBackBitmapOld != NULL)
{
m_BackDC.SelectObject(m_pBackBitmapOld);
}
if (m_pBackFontOld != NULL)
{
m_BackDC.SelectObject(m_pBackFontOld);
}
delete [] m_pMatrixColumns;
delete [] m_pSpinChars;
}
/*******************************************************************************
Create
*******************************************************************************/
BOOL
JMatrixCtrl::Create
(
DWORD dwStyle,
const RECT& rect,
CWnd* pParentWnd,
UINT nID
)
{
static CString className = AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW);
const BOOL result = CreateEx(WS_EX_CLIENTEDGE, className, NULL, dwStyle, rect,
pParentWnd, nID);
CRect r;
GetClientRect(r);
const int h = r.Height();
const int w = r.Width();
m_Font.CreateFont(14, 0, 0, 0, FW_BOLD,
FALSE, FALSE, 0, ANSI_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY,
DEFAULT_PITCH|FF_SWISS, "Courier");
// create main DC that gets copied to window
CClientDC dc(this);
m_DC.CreateCompatibleDC(&dc);
m_Bitmap.CreateCompatibleBitmap(&dc, w, h);
m_pBitmapOld = m_DC.SelectObject(&m_Bitmap);
m_pFontOld = m_DC.SelectObject(&m_Font);
TEXTMETRIC tm;
m_DC.GetTextMetrics(&tm);
m_nTextWidth = tm.tmAveCharWidth + kColSpacing;
m_nTextHeight= tm.tmHeight;
m_nCols = w/m_nTextWidth + 1;
m_nRows = h/m_nTextHeight + 1;
// create background DC that stores rain animation
m_BackDC.CreateCompatibleDC(&dc);
m_BackBitmap.CreateCompatibleBitmap(&dc, w, h);
m_pBackBitmapOld = m_BackDC.SelectObject(&m_BackBitmap);
m_pBackFontOld = m_BackDC.SelectObject(&m_Font);
m_BackDC.FillSolidRect(0,0, w,h, RGB(0,0,0));
m_pMatrixColumns = new MatrixColumn[ m_nCols ];
for (int i=0; i<m_nCols; i++)
{
m_pMatrixColumns[i].bActive = FALSE;
}
m_nTotalSpins = (int) (m_nCols * kSpinCharFraction);
m_pSpinChars = new SpinChar[ m_nTotalSpins ];
for (i=0; i<m_nTotalSpins; i++)
{
m_pSpinChars[i].bActive = FALSE;
}
SetTimer(kInitTextID, m_IntroInterval * 1000, NULL);
SetTimer(kUpdateBackgroundID, kAnimateBkgdInterval, NULL);
Invalidate(FALSE);
return result;
}
/*******************************************************************************
SetCursor
If the cursor is not solid, it is a randomly changing character.
*******************************************************************************/
void
JMatrixCtrl::SetCursor
(
const BOOL show,
const BOOL solid
)
{
m_bShowCursor = show;
m_CursorChar = (solid ? kBlockCursorChar : 'a');
}
/*******************************************************************************
Message map
*******************************************************************************/
BEGIN_MESSAGE_MAP(JMatrixCtrl, CWnd)
//{{AFX_MSG_MAP(JMatrixCtrl)
ON_WM_PAINT()
ON_WM_TIMER()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/*******************************************************************************
OnPaint
*******************************************************************************/
void
JMatrixCtrl::OnPaint()
{
if (m_pBitmapOld != NULL)
{
CRect r;
GetClientRect(&r);
CPaintDC dc(this);
dc.BitBlt(0, 0, r.Width(), r.Height(), &m_DC, 0, 0, SRCCOPY);
}
}
/*******************************************************************************
OnTimer
*******************************************************************************/
void
JMatrixCtrl::OnTimer
(
UINT nEventID
)
{
if (nEventID == kIn
没有合适的资源?快使用搜索试试~ 我知道了~
Cool_Credits_Ctrl.rar_Cool
共15个文件
h:5个
cpp:4个
rc:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 188 浏览量
2022-09-24
16:12:21
上传
评论
收藏 26KB RAR 举报
温馨提示
Visual C++ 关于对话框中很Cool的Credits,显示。
资源推荐
资源详情
资源评论
收起资源包目录
Cool_Credits_Ctrl.rar (15个子文件)
JMatrixCtrl
matrixDlg.h 531B
Release
matrix.exe 28KB
JMatrixCtrl.h 5KB
JMatrixCtrl.cpp 19KB
res
matrix.rc2 398B
matrix.aps 18KB
matrix.dsw 535B
matrix.cpp 1KB
StdAfx.cpp 202B
resource.h 591B
matrixDlg.cpp 2KB
StdAfx.h 1KB
matrix.dsp 4KB
matrix.h 518B
matrix.rc 4KB
共 15 条
- 1
资源评论
刘良运
- 粉丝: 68
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功