Click here to Skip to main content
12,556,922 members (50,112 online)
Click here to Skip to main content
Add your own
alternative version


39 bookmarked

A Scrolling Credits Dialog

, 6 Dec 2002
Rate this:
Please Sign up or sign in to vote.
Scrolling credits the easy way, under MFC.

Scrolling Credits Screenshot


A 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!


  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 the 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;

Have fun!...


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Mark Findlay
United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralThanks Pin
Mike Gaskey18-Nov-12 9:48
memberMike Gaskey18-Nov-12 9:48 
GeneralNice ,can i have scrolling in horizontal way Pin
Atif Mushtaq2-Jul-04 2:55
memberAtif Mushtaq2-Jul-04 2:55 
GeneralA different approach... Pin
Darren S. Gonzales3-Jan-01 5:19
memberDarren S. Gonzales3-Jan-01 5:19 
See my implementation:

GeneralRe: A different approach... Pin
zhoujun7-Dec-02 21:17
memberzhoujun7-Dec-02 21:17 
GeneralRe: A different approach... Pin
Anthony_Yio14-Dec-03 14:31
memberAnthony_Yio14-Dec-03 14:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.161026.1 | Last Updated 7 Dec 2002
Article Copyright 1999 by Mark Findlay
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid