Scrolling credits dialog
This article was contributed by Mark Findlay.
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.
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.
You can have a spiffy looking credits window in about 10 minutes!
The credits go through their cycle and wrap around to the beginning again for a never ending show!
Steps.
- 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.
- 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.
- 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.
- Add the following data members to the credits.h file (or copy and
paste them from the credits.h file provided)
#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;
- Create the following message handlers and functions using the class wizard:
virtual void OnOK(); afx_msg void OnPaint(); virtual BOOL OnInitDialog(); afx_msg void OnTimer(UINT nIDEvent); afx_msg void OnDestroy();
- Cut and paste the functions from the credits.cpp file provided into your newly created functions.
- From another module (your About... dialog perhaps) , invoke the credits
dialog:
CCredits dlgCredits; dlgCredits.DoModal();

Comments
Scrolling Display
Posted by Legacy on 06/27/2002 12:00amOriginally posted by: rajeev
ReplyHow to scroll and change the font, color of the scrolling text simultaneously?
Posted by Legacy on 04/25/2001 12:00amOriginally posted by: Nita
My class derived from form view has the controls for changing the font, color etc. of text which is scrolling.
I have created a modeless dialog within a thread spawned in a message handler function in view class to perform scrolling. I am having a problem in performing the scrolling & changing the font size etc in the view together.
ReplyWhen you load a 2nd dialog, how do you make it show in taskbar?
Posted by Legacy on 10/22/2000 12:00amOriginally posted by: Jack
My project has 2 dialogs and when the user clicks on a button I want the 2nd dialog to open and the first to close. I can do this fine except the 2nd dialog doesn't have an icon and doesn't show in the windows task bar. Any suggestions?
ReplyRepaint does not correct display when another window damages a portion of the dialog
Posted by Legacy on 09/07/2000 12:00amOriginally posted by: Sinisa Ruzin
Hi,
First of all, thank you for the great example!
I noticed that the dialog does not get repainted when another window (like Internet Explorer) moves over parts of the Credits Dialog. I tried to use virtual window to hold actual drawings and copy its bitmap to the dialog in the OnPaint() event, but since I am a beginner, this was too difficult for me to resolve.
Could someone help?
Thanks in advance,
ReplySin
How to add the scrolling credits to the About dialog instead to another dialog?
Posted by Legacy on 08/16/2000 12:00amOriginally posted by: Dini Dahm
ReplyCredit Dialog
Posted by Legacy on 07/31/2000 12:00amOriginally posted by: sujeet
Yesss....it works cooool.
ReplyI cant get it to work
Posted by Legacy on 01/29/2000 12:00amOriginally posted by: Jed
Help please. I am new at Visual C++ and i cant get it to work on my application. if you can help me please e-mail me at jed2010@erols.com or Jtdfx on AOL
Replymissing a OnEraseBkgnd treatment
Posted by Legacy on 10/26/1999 12:00amOriginally posted by: Pedro Soares
when another dialog goes in front of the credits frame and then this one gains the focus, the image of the frame isnt repainted! :(
ReplyIt's great, just one question.
Posted by Legacy on 05/22/1999 12:00amOriginally posted by: Jason M. Greene
How can I make it so that the company name is a link to a web site?
ReplyDOESNT SEEM TO WORK
Posted by Legacy on 03/05/1999 12:00amOriginally posted by: Talal Tayyab
I have tried to use it in a Dialog based Application created by the MFC
ReplyApplication Wizard and nothing seems to happen..
Could somebody Please Help ME!!!!!!!!
(p.s I have done every step and the program also compiles)
E-mail: love_ntt@yahoo.com
thanx
Loading, Please Wait ...