Click here to Skip to main content
Click here to Skip to main content

Digital Display CStatic control

, 9 Nov 2002
Rate this:
Please Sign up or sign in to vote.
An article on the Digital Display Control

Sample Image

Introduction

This control is derived from CStatic. It is bitmap-based to make it easy for the user to alter the character set. Three sized character sets are provided as can be seen in the example above. Features are:

  • Bitmapped based for easy altering of character set.
  • Single or multilined displays.
  • Scrolling left, right, up or down at various speeds.
  • Class is derived from CStatic and is easy to use.
  • All colours can be very easily changed.
  • Three character sizes are provided
  • Optional automatic sizing of CStatic control
  • Optional auto padding of strings with a supplied character
  • Support for altering format of supplied bitmap.

Class Members

MatrixStatic::SetAutoPadding

This function pads the internal display string (set with the SetText() function) with a supplied character so that it equals the length of the value supplied in the SetXCharsPerLine() function.

void SetAutoPadding(
   bool pad,
   char ch = ' ');

Parameters

pad - A C++ boolean variable. true = Strings will be automatically padded with the given character to equal the value supplied to the class in the SetXCharsPerLine() function. false = No auto padding will occur.

ch - a char variable. This parameter is optional as it defaults to a space character. This is the character used to pad the string if the above parameter is true.

Return Value

None

MatrixStatic::GetText

This function fills a supplied buffer with the text that was set in the SetText() function.

int GetText(
	char *string,  
	int size);

Parameters

string - A pointer to a buffer the requested text will be placed in to.

size - An integer containing the length of the supplied buffer.

Return Value

Function returns an integer of the number of characters placed in the buffer.

MatrixStatic::SetDisplayColors

This function sets all three colours of the display characters in a single function call.

void SetDisplayColors(
	COLORREF bk,  
	COLORREF on,  
	COLORREF off);

Parameters

bk - A COLORREF variable which supplies the RGB(x, x, x) value of the background colour of the display.

on - A COLORREF variable which supplies the RGB(x, x, x) value of the on colour of the display.

off - A COLORREF variable which supplies the RGB(x, x, x) value of the off colour of the display.

Return Value

None

MatrixStatic::SetBkColor

This function sets the background colour of the display.

void SetBkColor(
	COLORREF bk);

Parameters

bk - A COLORREF variable which supplies the RGB(x, x, x) value of the background colour of the display.

Return Value

None

MatrixStatic::SetColor

This function sets the on and off colours of the display.

void SetColor( COLORREF off, COLORREF on);

Parameters

on - A COLORREF variable which supplies the RGB(x, x, x) value of the on colour of the display.

off - A COLORREF variable which supplies the RGB(x, x, x) value of the off colour of the display.

Return Value

None

MatrixStatic::SetBitmapResource

This function is optional. It allows for an alternate bitmap resource to be supplied. (See the supplied resource bitmaps which can be used as a template for new character formats.) There are three bitmap resources supplied that the program requires. The correct one to use is set when you call the SetSize() function. They must have the ID's of IDB_MATRIXLARGE, IDB_MATRIXSMALL and IDB_MATRIXTINY.

If this function is used to supply a new or different bitmap, even if the format is the same, you must also call the MatrixStatic::SetCustomCharSizes function to supply information about this bitmap.

void SetBitmapResource(
	UINT bitmap);

Parameters

bitmap - Resource identifier of the bitmap resource.

Return Value

None.

See Also

SetSize which identifies the different size bitmaps supported.

SetCustomCharSizes() which allows different format bitmaps.

MatrixStatic::SetText

This function supplies the text that is to be displayed. Once called your supplied string can be deleted, the text is stored in a member CString variable.

void SetText(
	LPCTSTR lpszText);

Parameters

lpszText - A 32-bit pointer to a constant character string

Return Value

None.

MatrixStatic::SetSize

This function identifies which of the three supported sized bitmaps was supplied in the SetBitMapResource() function.

void SetSize(
	int size = SMALL);

Parameters

size - an integer variable that identifies which of the three bitmap sizes supported was given in the SetBitMapResource() function. Possible values are LARGE, SMALL & TINY, which a defined within the class as 0, 1 and 2 integers respectively.

Return Value

None.

See Also

See the three supplied bitmap templates as an example of this.

SetCustomCharSizes() which allows custom format bitmaps.

MatrixStatic::StopScroll

This function ceases the scrolling of the display.

void StopScroll();

Parameters

None.

Return Value

None.

MatrixStatic::DoScroll

This function starts the display scrolling in the supplied direction. This is not a pixel scroll but a character scroll.

void DoScroll(
	int speed, 
	BOOL dir);

Parameters

speed - Speed of the scrolling in milliseconds. This is the same value you would supply to the Windows SetTimer() function.

dir - Direction of scroll. Possible values are:

Single Line Display: (SetNumberOfLines was supplied a value of 1) LEFT or RIGHT, defined within the class as boolean 0 or 1 respectively.

Multiline Display: (SetNumberOfLines was supplied a value greater than 1) UP, DOWN, LEFT or RIGHT, defined within the class as 0, 1, 2 or 3 respectively.

Return Value

None.

MatrixStatic::SetCustomCharSizes

This function allows you to use custom format bitmaps. It sets the pixel sizes of each character and the vertical and horizontal spacing.

These values are automatically filled in for the three internally supported sizes of bitmaps.

void SetCustomCharSizes(
	int width, 
	int height, 
	int xspace,  
	int yspace);

Parameters

width - An integer of the width of each character in pixels.

height - An integer of the height of each character in pixels.

xspace - An integer of the space between each character horizontally in pixels.

yspace - An integer of the space between each character vertically in pixels.

Return Value

None.

MatrixStatic::AdjustClientYToSize

This function allows the CStatic object to be automatically sized vertically for you to a given number of characters.

void AdjustClientYToSize(
	int size);

Parameters

size - number of vertical display lines you want the object sized to.

Return Value

None.

See Also

SetNumberOfLines()

SetXCharsPerLine()

SetAutoPadding()

AdjustClientXToSize

MatrixStatic::AdjustClientXToSize

This function allows the CStatic object to be automatically sized horizontally for you a given number of characters.

void AdjustClientXToSize(
	int size);

Parameters

size - number of characters you want the object sized to.

Return Value

None.

See Also

SetNumberOfLines()

SetXCharsPerLine()

SetAutoPadding()

AdjustClientYToSize()

MatrixStatic::SetNumberOfLines

This function sets the number of vertical display lines you want. It does not have to equal the length of the string divided by the MaxXChars value. This is useful for vertical scrolling. If the string is longer than the number of characters shown in a multiline display and vertical scrolling is enabled, the display will scroll through the string showing all characters. An example of this is in the project example.

void SetNumberOfLines(
	int max = 0);

Parameters

max - An integer that supplies the number of lines you want on the display.

Return Value

None.

See Also

SetXCharsPerLine()

SetAutoPadding()

AdjustClientXToSize

AdjustClientYToSize

MatrixStatic::SetXCharsPerLine

This function sets the number of characters horizontally in the display. In a single line display it sets how many characters can be seen in the display at one time. On multiline displays it sets how many horizontal characters are to be used on each line.

For example: If you wanted three lines of ten characters each, a string of 30 characters would be supplied in the SetText() function. This parameter would be set to 10, and the SetNumberOfLines() function would be supplied with 3.

The difference between single and multiline is: Single line displays can have a string longer than the supplied parameter and only the number of characters supplied here will be shown. Multiline displays cannot, The next line displayed starts at the character following the number of characters supplied here.

void SetXCharsPerLine(
	int max = 0);

Parameters

None.

max - An integer that supplies the number horizontal characters to display.

Return Value

None.

See Also

SetNumberOfLines()

SetAutoPadding()

AdjustClientXToSize()

AdjustClientYToSize()

History

V1.0 initial release 11th November 2002

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Nic Wilson
Web Developer
Australia Australia
No Biography provided

Comments and Discussions

 
BugTry to display char ':' but result to ';' Pinmembereeyrw25-Jul-14 18:09 
GeneralMy vote of 5 Pinmemberevan36921-Jun-11 16:46 
Answersolution for display no text PinmemberAchillean4-Sep-08 3:29 
I have the same problem with others that only show BKcolor without text.
I test many block of code then find problem is SetSize() and only setsize LARGE will show no text.
So i change if-else to switch-case then the problem is gone.
I don't know why even i have traced the code step-by-step.
I use VC 2008. Ascii mode and Debug mode.
finally forgive me bad english :P
GeneralFlicker free paint Pinmembermijalko19-Apr-06 1:26 
GeneralGreat code but..... PinmemberTim Moody5-Aug-05 4:55 
GeneralRe: Great code but..... Pinmembernewstar00821-Nov-05 23:24 
GeneralRe: Great code but..... Pinmemberliu08131-Dec-05 1:22 
GeneralRe: Great code but..... Pinmembergehlhajo13-Feb-06 1:57 
GeneralGreat code, but..... PinmemberTim Moody4-Aug-05 10:39 
Questionhow to export to a bitmap? PinmemberBloobird023-May-05 22:34 
AnswerRe: how to export to a bitmap? PinmemberNic Wilson3-Jun-05 12:06 
GeneralDo have ActiveX version for VB Pinmembersanong25-Dec-04 5:52 
Questionhow does it map? Pinmemberabstarsss6-Nov-04 12:07 
AnswerRe: how does it map? PinmemberNic Wilson8-Nov-04 13:47 
GeneralRe: how does it map? Pinmemberabstarsss10-Nov-04 19:55 
GeneralIn chinese PinsussAnonymous18-Jul-04 5:32 
GeneralRe: In chinese PinmemberNic Wilson4-Aug-04 15:35 
GeneralRe: In chinese Pinmembernewstar0081-Nov-05 15:43 
QuestionGraphic capability? PinsussAnonymous13-Jul-04 10:29 
AnswerRe: Graphic capability? PinmemberNic Wilson13-Jul-04 12:10 
GeneralTo use more then ASCII codes PinmemberEugene Pustovoyt27-Apr-04 1:34 
GeneralThats Wonder!!! PinmemberBalkrishna Talele16-Feb-04 22:51 
GeneralAbsolutely Fantastic PinmemberPeter Coppinger21-Nov-03 8:17 
GeneralGreat Work! PinsussAnonymous12-Oct-03 4:02 
GeneralRe: Great Work! Pinmemberliu08131-Dec-05 1:46 
GeneralRe: Great Work! Pinmembershivrajbhosale24-Jul-07 3:36 
QuestionBUG? Pinmembermachiav14-May-03 23:49 
AnswerRe: BUG? Pinmemberrunawaya21-Mar-11 20:50 
QuestionHow to use this function? PinmemberHoward.Hsu26-Mar-03 21:05 
AnswerRe: How to use this function? PinmemberHoward.Hsu27-Mar-03 15:18 
GeneralDynamically create Static control and show image PinmemberAWebDude17-Mar-03 7:42 
GeneralTrouble Using it CPropertySheet Pinmemberqbert6553613-Dec-02 19:16 
GeneralRe: Trouble Using it CPropertySheet Pinmemberqbert6553613-Dec-02 19:24 
GeneralCan't display Unicode character PinmemberGolden Lee8-Dec-02 15:49 
GeneralThank you PinmemberSylvain CROZET20-Nov-02 3:22 
Questioncolon and semicolon reversed? PinmemberDavid Troendle19-Nov-02 18:24 
AnswerRe: colon and semicolon reversed? PinmemberAndre123426-Jan-05 2:43 
GeneralCool !! Really cool !! PinmemberWREY12-Nov-02 2:48 
GeneralDownload not work Pinmemberr.guerzoni11-Nov-02 9:16 
GeneralRe: Download not work PinmemberNic Wilson11-Nov-02 10:49 
GeneralRe: Download not work PinsussAnonymous11-Nov-02 12:17 
GeneralRe: Download not work Pinmemberr.guerzoni11-Nov-02 20:42 
GeneralBrilliant ! PinmemberStlan10-Nov-02 23:12 
GeneralIt't right : Download not work PinsussAnonymous10-Nov-02 21:59 
GeneralRe: It't right : Download not work PinmemberSteveKing11-Nov-02 1:14 
GeneralDownload not work PinsussAnonymous10-Nov-02 20:28 
GeneralRe: Download not work PinmemberNic Wilson10-Nov-02 21:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    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 | Mobile
Web01 | 2.8.140827.1 | Last Updated 10 Nov 2002
Article Copyright 2002 by Nic Wilson
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid