Click here to Skip to main content
13,900,479 members
Click here to Skip to main content
Add your own
alternative version


64 bookmarked
Posted 11 Apr 2000

Transparent Scrolling Credits

, 14 Apr 2000
Rate this:
Please Sign up or sign in to vote.
Scroll colored text and bitmaps transparently over a bitmapped background.
<!-- Link to demo file download -->
  • Download demo project - 176 Kb
  • <!-- Article image -->

    Sample Image - ScrollingCredits.gif

    <!-- Add the rest of your HTML here -->


    I wanted to have one of those fancy scrolling credits for an application I have been working on, and I couldn't find anything suitable. So I did what most of us end up doing when we can't find someone else's code to rip... I made my own. I wanted to be able to scroll text and bitmaps transparently over a bitmapped background.

    This code uses the CGDIThread class from the MTGDI MFC sample source code for the interface thread. The transparent blitting is accomplished using the "True Mask Method" explained in the article "Transparent Bitmap - True Mask Method" by Paul Reynolds.

    The text and bitmaps of the credits are printed on a memory bitmapped during initialization. The memory bitmap is then blitted to the screen repeatedly, each time starting at the next row, giving the effect of scrolling.

    The CCreditsThread class does all of the initialization and drawing of the credits. The fonts and colors that will be used are initialized, followed by the actual contents of the credits.

    The demo uses a dialog with an image covering it's entire surface. The credits can be displayed anywhere on the dialog. Whatever is behind the area the credits are displayed in will be used for the background of the scrolling.

    The transparent color in the demo is white, but it can be changed to whatever you like by changing the MASK_RGB #define in the CreditsThread.cpp file. Anything that uses the transparent color will not show up. This includes text and areas on bitmaps. If you wanted to use text that is the same color as the transparent color then use a color that is close to the transparent color.


    RGB(255, 255, 255);   // transparent color
    RGB(250, 250, 250);   // text color

    Any available font face can be used. The fonts are initialized in the InitFonts() function using the LOGFONT structure and are added to an array of CFonts for quick retrieval. This also allows a large number of different fonts to be used.

    The font colors are initialized in the InitColors() function. Font color is independent of the font face being used. Any color can be used with any face, without having to create a new font. The font colors are also added to an array for quick retrieval.

    The actual contents of the credits are initialized in the InitText() function. The credits are stored as text strings describing the attributes and the content of each line.

    void CCreditsThread::InitText()
    	// 1st pair of digits identifies the font to use
    	// 2nd pair of digits identifies the color to use
    	// B = Bitmap
    	// S = Space (moves down the specified number of pixels)
    	CString sTmp;
    	// start at the bottom of the screen
    	sTmp.Format(_T("S:%d"), m_rectScreen.Height());
    	m_arCredits.Add(_T("02:04:Scrolling Credits"));
    	m_arCredits.Add(_T("01:00:Insert Bitmaps"));
    	// pause before repeating

    Text Lines

    If the line in the credits is a text string, it has the following format:
    "02:04:Text to display"

    The first 2 digits are in index into the array of fonts to describe the font face to use for that line. Each line of text must specify the font to use. The font number must always be formatted as a 2 digit number at the beginning of the string. Following the font number is a colon.

    The next pair of digits are an index into the array of font colors, specifying the color to use for that line of text. The color index must also be formatted as a 2 digit number. The color index is followed by a colon.

    The next part of the string is the actual text to display.


    If the line in the credits is a bitmap, it will have the following format:

    The bitmap resource must have a quoted name, like "BALL", instead of the customary style ID like IDB_BALL.


    You can specify the amount of spacing between lines in the credits.

    The number specifies the number of pixels to move down. Lines of text are automatically spaced one line. You can also use spacing to cause the credits to start scrolling from the bottom of the screen initially, or to simulate a pause before the next section of credits is displayed, or until the credits are repeated.

    To use in your own projects

    • Add the following files to your project:
      • GDIThread.cpp
      • GDIThread.h
      • CreditsThread.cpp
      • CreditsThread.h
      • CreditsDlg.cpp
      • CreditsDlg.h
    • Modify the CreditsDlg file to match the dialog you will be using. (ie. set the IDD constant and delete any unused message handlers)
    • Determine where on your dialog the credits will be displayed and set the SCREEN_ #defines in the CreditsDlg.cpp file to indicate this.
    • Edit the font types you will be using in the InitFonts() function in the CreditsThread.cpp file.
    • Edit the font colors you will be using in the InitColors() function in the CreditsThread.cpp file.
    • Edit the text for the credits in the InitText() function in the CreditsThread.cpp file.
    • Add any bitmaps resources you will be using. Remember to give them a quoted name in the "ID:" field.
    • Place the following line in the InitInstance() function of your main application object.


    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

    Jim Connor
    United States United States
    No Biography provided

    You may also be interested in...

    Comments and Discussions

    QuestionVote of 5 Pin
    Jason.LYJ21-Mar-16 15:44
    professionalJason.LYJ21-Mar-16 15:44 
    Generalmemory leak! Pin
    wwstudio_cn7-Dec-08 22:03
    memberwwstudio_cn7-Dec-08 22:03 
    GeneralBuild under VC9 (Orcas) Pin
    rgallahan4-Dec-07 1:48
    memberrgallahan4-Dec-07 1:48 
    General&#35874;&#35874; Pin
    rensheng324-Sep-07 5:24
    memberrensheng324-Sep-07 5:24 
    GeneralGreat work! Pin
    JetDraft13-Mar-07 20:42
    groupJetDraft13-Mar-07 20:42 
    GeneralSmall prob. Pin
    sumit siddheshwar8-Aug-06 19:01
    membersumit siddheshwar8-Aug-06 19:01 
    GeneralThanks, it is a good basis !!! Pin
    2pers7-Mar-06 8:46
    member2pers7-Mar-06 8:46 
    GeneralThanks! Pin
    speedpacer8-Nov-03 6:17
    memberspeedpacer8-Nov-03 6:17 
    QuestionModeless dialog? Pin
    Ogi5-Sep-03 3:38
    memberOgi5-Sep-03 3:38 
    AnswerRe: Modeless dialog? Pin
    Ogi8-Sep-03 6:57
    memberOgi8-Sep-03 6:57 
    QuestionGreat work - its is free?? Pin
    asfur1-Jul-03 6:23
    memberasfur1-Jul-03 6:23 
    AnswerRe: Great work - its is free?? Pin
    Jim Connor1-Jul-03 15:43
    memberJim Connor1-Jul-03 15:43 
    GeneralNice work! Pin
    Alvaro Mendez21-Mar-02 3:51
    memberAlvaro Mendez21-Mar-02 3:51 
    GeneralLooks great Pin
    Giles2-Mar-02 5:19
    memberGiles2-Mar-02 5:19 
    Generalin other window Pin
    kiand2-Oct-00 0:22
    memberkiand2-Oct-00 0:22 
    GeneralTranslucent bitmap Pin
    Jack Z18-Apr-00 9:11
    memberJack Z18-Apr-00 9:11 
    GeneralRe: Translucent bitmap Pin
    Portatofe2-Oct-08 6:02
    memberPortatofe2-Oct-08 6:02 
    GeneralPalette Handling Pin
    Llew16-Apr-00 15:22
    memberLlew16-Apr-00 15:22 
    GeneralRe: Palette Handling Pin
    Aaron Sulwer11-Jul-00 8:29
    memberAaron Sulwer11-Jul-00 8:29 
    GeneralRe: Palette Handling Pin
    lg11-Jul-00 11:27
    memberlg11-Jul-00 11:27 
    GeneralRe: Palette Handling Pin
    Aaron Sulwer12-Jul-00 8:09
    memberAaron Sulwer12-Jul-00 8:09 
    GeneralRe: Palette Handling Pin
    lg12-Jul-00 8:43
    memberlg12-Jul-00 8:43 
    GeneralMake it building under VC50 Pin
    George12-Apr-00 16:58
    memberGeorge12-Apr-00 16:58 

    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.

    Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
    Web05 | 2.8.190306.1 | Last Updated 15 Apr 2000
    Article Copyright 2000 by Jim Connor
    Everything else Copyright © CodeProject, 1999-2019
    Layout: fixed | fluid