Virtual Developer Workshop: Containerized Development with Docker

Download source file or demo project.

This static subclass is based on the Scrolling credits dialog by Mark Findlay. I have made some modifications to enable the use of resource strings, and added some functionality to make the background look more professional. By implementing the functionality through a CStatic subclass it is no longer dependant on a dialog and can more easily be used in different circumstances.

The control lets you scroll text and bitmaps in an like you see in movies. It will continue to loop the text for as long as it is active. The speed of the scrolling can be set by the programmer. The control has the following features:

  • The text/bitmap sequence can be set using a character string or through am ID to a string table entry.
  • The text/bitmap sequence is formatted with different colours and fonts through using special characters in the text. The mapping between the special characters and given colours and fonts can be set by the programmer

    NB! The bitmaps are given as quoted bitmap resources (ID as "IDB_BITMAP" instead of just IDB_BITMAP).
  • The background can be given a special colour or a background bitmap can be set.

    NB! While bitmaps in the text/bitmap sequence are restricted to 16 colours, the background bitmap have no such restriction.)

    If a solid colour background is used, it can be given a gradient to black or white, left-to-right or vice-versa.
  • The background of the bitmaps in the text/bitmap sequence can be made transparent to allow for non-square shapes. By setting a flag, the parts of the bitmaps that have the standard dialog colour (RGB(192,192,192)) will be transparent.

    NB! There is a slight difference in how this functionality is implemented when using a background image instead of colour. Because of the way the addition of a background image is implemented all parts of the text/sequence that have the standard dialog colour will be transparent, not only the bitmaps. Also, when the transparent colour is _not_ set, all parts of the text/bitmap sequence that match the otherwise not active background colour, will be transparent as well. So, to disallow transparency when using a background image, set the background colour so an unused colour.

    NB! Because there is several bitblt's involved when using a background image, the scrolling is slowed down considerably. But it does look good!! (If anyone can find ways of speeding up this process, please contact me!)
  • If not scrolling is started, a still picture of the text/bitmap sequence is displayed (That's how the figure was created).

    Beware of the following differences between this implementation and the one of Mark Findlay:
  • Instead of an array of strings, this control uses a single string. This is to allow the use of resource strings.

    A delimiter character (standard '|') is given to mark the beginning of a new line.
  • The special character denoting "normal" text has been removed. A line without any special character will be formatted according to the "normal text" rules.
  • Several of the default special characters have been changed, This was necessary because the string table resources did not understand all the original escape sequences.

To use CCreditStatic a member variable must be added to the dialog:
CCreditStatic m_static;

In OnInitDialog the static control is subclassed and the credit text is added. Optionally a background image can be added:

char *pArrCredit = { "NETBAS FOR WINDOWS NT\t||Copyright (c) 1998|"
        "Test Data AS|All Rights Reserved||"
        "BITMAP1^|||"    // this is a quoted bitmap resource 
        "Project Lead\r||Kjetil Kvamme|||"
        "Technical Lead\r||Kjetil Kvamme|||"
        "Engineering Lead\r||Paul K. Tonder|||"
        "Product Lead\r||Tom Rotting|||"
        "Engineering\r||Paul K. Tonder,  Rolf T. Wold,  Sigbjorn Helset|"
        "Reidar Ognedal,  Kjetil Kvamme, Arne Bakken|||"
        "BITMAP2^|||"  // this is a quoted bitmap resource 
        "QA\r||Mary Hech,  Sam Bamnm,  Ron Fonn,  Steve Waeve|"
        "Igor Borisnoff,  FellaB |||"
        "Arvid Molnvik,  Joanne Hone,  Annette Fune|||"
        "Technical Program Office\r||Burf Murphy, Foll Roller||||"
        "Systems Support\r||Bendy Land|||"
        "Administrative Support\r||Donna Fonna|||"
        "* * * * * * * * *\t|||"
        "Project Manager\r||Dwain Kinghorn|||"
        "Hank Bank,  Ray Fay,  Bill Sill,  Mark Dark,  Peter Leter|"
        "Lev Bef|||Quality Assurance\r||"
        "Biff Bin||||"

BOOL CMyDialog::OnInitDialog() 
        // m_static.SetCredits(IDS_CREDITS);  // Use with string resource
        m_static.SetColor(BACKGROUND_COLOR, RGB(0, 0, 255)); // Background Colour
        m_static.SetTransparent(); // Set parts of bitmaps with RGB(192,192,192) transparent
        m_static.SetGradient(GRADIENT_RIGHT_DARK);  // Background goes from blue to black from left to right
        // m_static.SetBkImage(IDB_BITMAP1); // Background image
        return TRUE;  // return TRUE unless you set the focus to a control
                      // EXCEPTION: OCX Property Pages should return FALSE

Note: Keith Rule was kind enough to fix a number of resource leaks that can bring the App down on Windows95. The fixes have mostly been to select the original GDI objects back into the device context.

The example project shows one use of the control. A Credits dialog is displayed when the user double-click in the view window. In addition to showing the basics for using the control, the project also shows how cycling of background images can be implemented. The background image is periodically switched (every 5 seconds). This background image cycling management is implemented in the dialog box rather than in the control itself. The background image is switched through repeated calls to the BkImage method of the CCreditStatic object.


  • Can change the background from bitmap to a movie ?

    Posted by martinet on 03/29/2007 05:19pm

    It's very good! But can it change the background bitmaps to a wmv file,and the Text is still transparent ? I need the effect !! Thanks a lot !

  • CPU intensive. Can it be improved?

    Posted by Legacy on 07/21/2003 07:00am

    Originally posted by: austin

    I just tried to run the sample and found it taking > 90% CPU processing time. Can it be improved?
    I wouldn't mind this if only used in the acknowledging as in the credit dialog, as it is intended.

    I tested "Hyperlink and Scroll CStatic Class by George Ter-Saakov or Zhibin Cao?" and found it taking no CPU time.
    I go for this one, cause I need my CPU time to do other thing.

  • none

    Posted by Legacy on 11/29/2002 08:00am

    Originally posted by: Slayer

    Very, very good. Easy to use!!! Works without any problems.
    Realy nice! Thaks.

  • It is very good

    Posted by Legacy on 12/29/2001 08:00am

    Originally posted by: lemon.zc

    I changed to a ActiveX control. *.OCX

  • Can not SetFont for this static

    Posted by Legacy on 09/14/2001 07:00am

    Originally posted by: Tran The Lan

    I can not use the SetFont function of this static class, how can I do that

  • Scrolling credits using CStatic in Java Code

    Posted by Legacy on 03/14/1999 08:00am

    Originally posted by: Tu Tran

    Do you have any information where I can find this SCrolling credits in Java? Any information is appreciated.


    Tu Tran

  • Background gradient not working

    Posted by Legacy on 12/02/1998 08:00am

    Originally posted by: Shiraz Esat

    Hi Guys!
    For some reason I can't get the background gradient to work.
    I'd like my gradient to appear just like the in the pic at the top of web-page http://www.codeguru.com/staticctrl/credit_static.shtml, and I've used the code from the same page, but all I just get 3 columns [light blue, dark blue, black].
    What have I done wrong?

    Please help!

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date