CodeGuru
Earthweb Search
Login Forums Wireless Jars Gamelan Developer.com
CodeGuru Navigation
RSS Feeds

RSSAll

RSSVC++/C++

RSS.NET/C#

RSSVB

See more EarthWeb Network feeds

follow us on Twitter

Member Sign In
User ID:
Password:
Remember Me:
Forgot Password?
Not a member?
Click here for more information and to register.

Become a Marketplace Partner

jobs.internet.com

internet.commerce
Partners & Affiliates
















Home >> Visual C++ / C++ >> Windows & Dialogs >> Dialog >> Credits Dialog


Scrolling credits dialog
Rating: none

Mark Findlay (view profile)
August 7, 1998


This article was contributed by Mark Findlay.
(continued)




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.

  1. 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.
  2. 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.
  3. 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.
  4. 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;
    
  5. 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();
    
  6. Cut and paste the functions from the credits.cpp file provided into your newly created functions.
  7. From another module (your About... dialog perhaps) , invoke the credits dialog:
    	CCredits dlgCredits;
    	dlgCredits.DoModal();
    
Download source files. 48KB.

Tools:
Add www.codeguru.com to your favorites
Add www.codeguru.com to your browser search box
IE 7 | Firefox 2.0 | Firefox 1.5.x
Receive news via our XML/RSS feed







RATE THIS ARTICLE:   Excellent  Very Good  Average  Below Average  Poor  

(You must be signed in to rank an article. Not a member? Click here to register)

Latest Comments:
How to scroll a Dialog Box - Legacy CodeGuru (11/08/2002)
Scrolling Display - Legacy CodeGuru (06/27/2002)
not refreshed!! - Legacy CodeGuru (10/08/2001)
How do you create a summary page - Legacy CodeGuru (07/31/2001)
How to scroll and change the font, color of the scrolling text simultaneously? - Legacy CodeGuru (04/25/2001)

View All Comments
Add a Comment:
Title:
Comment:
Pre-Formatted: Check this if you want the text to display with the formatting as typed (good for source code)



(You must be signed in to comment on an article. Not a member? Click here to register)

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs