📄 credits_dialog.shtml.htm
字号:
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Author" CONTENT="Zafir Anjum">
<TITLE>Dialog - Scrolling credits dialog</TITLE>
</HEAD>
<body background="../fancyhome/back.gif" tppabs="http://www.codeguru.com/fancyhome/back.gif" bgcolor="#FFFFFF" link="#B50029" vlink="#8E2323" alink="#FF0000">
<table WIDTH="100%">
<tr WIDTH="100%">
<td><td>
</tr>
</table>
<CENTER>
<H3>
<FONT COLOR="#AOAO99">Scrolling credits dialog</FONT></H3></CENTER>
<CENTER>
<H3>
<HR></H3></CENTER>
<p>This article was contributed by Mark Findlay.
<P>The credits dialog is a neat way to display a scrolling credits window
like you see in the movies or in some of the Microsoft product credits
that popup when you hit a hidden key sequence.
<P>This dialog displays text in user defined colors and fonts and also
displays bitmaps in the scrolling display! You simply type the text
you wish to appear in the static array defined in the cpp file and
use user defined escape sequences to designate different fonts, colors
etc.
<P>You can have a spiffy looking credits window in about 10 minutes!
<P>The credits go through their cycle and wrap around to the beginning again
for a never ending show!
<H4> Steps.</H4>
<ol>
<li>Create a dialog using the resource editor and set its style to
WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CAPTION
Put an OK button on it so the user has a way of dismissing the
dialog.
<li>Create the credits display window (make it a good large size :)
as a text box. Call the text box IDC_DISPLAY_STATIC
(or whatever name you like, but if you use a different name you
will need to change the IDC_DISPLAY_STATIC name used in the source
code provided here.
<li>Use the ClassWizard to generate a class wrapper for the dialog. For
purposes of this example we will use the names credits.cpp and credits.h
as the files generated by the class wizard and CCredits as the class
name to generate. Base the class on CDialog.
<li>Add the following data members to the credits.h file (or copy and
paste them from the credits.h file provided)
<PRE><TT><FONT COLOR="#990000"> #define DISPLAY_TIMER_ID 150 timer id
RECT m_ScrollRect,r; // rect of Static Text frame
int nArrIndex,nCounter; // work ints
CString m_szWork; // holds display line
BOOL m_bFirstTime; // first time boolean
BOOL m_bDrawText; // drawing text or bitmap?
int nClip; // clip amount
int nCurrentFontHeight; // current font height
CWnd* m_pDisplayFrame; // output display wnd
CBitmap m_bmpPIE;
CBitmap m_bmpWork;
CBitmap* pBmpOld;
CBitmap* m_bmpCurrent;
HBITMAP m_hBmpOld;
CSize m_size;
CPoint m_pt;
BITMAP m_bmpInfo;
CDC m_dcMem;
BOOL m_bProcessingBitmap;
</FONT></TT></PRE>
<li>Create the following message handlers and functions using the class wizard:
<PRE><TT><FONT COLOR="#990000">
virtual void OnOK();
afx_msg void OnPaint();
virtual BOOL OnInitDialog();
afx_msg void OnTimer(UINT nIDEvent);
afx_msg void OnDestroy();
</FONT></TT></PRE>
<li>Cut and paste the functions from the credits.cpp file provided into your
newly created functions.
<li>From another module (your About... dialog perhaps) , invoke the credits
dialog:
<PRE><TT><FONT COLOR="#990000">
CCredits dlgCredits;
dlgCredits.DoModal();
</FONT></TT></PRE>
</ol>
<A HREF="credits.zip" tppabs="http://www.codeguru.com/dialog/credits.zip">Download source files</A>. 48KB.
<P>
<HR>
<TABLE BORDER=0 WIDTH="100%" >
<TR>
<TD WIDTH="33%"><FONT SIZE=-1><A HREF="../index.htm" tppabs="http://www.codeguru.com/">Goto HomePage</A></FONT></TD>
<TD WIDTH="33%">
<CENTER><FONT SIZE=-2>© 1997 Zafir Anjum</FONT> </CENTER>
</TD>
<TD WIDTH="34%">
<DIV ALIGN=right><FONT SIZE=-1>Contact me: <A HREF="mailto:zafir@home.com">zafir@home.com</A> </FONT></DIV>
</TD>
</TR>
</TABLE>
<CENTER><FONT SIZE=-2>9560</FONT></CENTER>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -