Text Input Boxes - Text and Background Colour

© 2002 by Ray Fisher

rmfisher@talk21.com OR

rmfisher@btinternet.com

Home

Use of Color in Graphics

Bitmap Graphics Tutorial

Bitmap Color Formats

Bmp Dimensions

SCAN vs WAIT

Text Input Boxes

An Easy Calendar Control

Shareware Marketing

Date/Time Picker

Text Line-Wrap

Combining Commands

Newsletter help

Index


For some time I have wanted more control over the colour of the text and the background in text input boxes. Liberty BASIC allows you to control the background of text boxes, but limits you to 16 colours. Also you can set the text colour (16 colours only) but the colour set then applies to all controls (static text, list boxes etc.).

I wanted to be able to set the text and the background to any colour for each individual text input control. By using a rich edit control I was able to do this.

The first step was to load the rich edit library, see Note 1.

The second step was to create a function which would get an instance handle of the window which is to contain the control, see Note 2.

The third step was to create a function that would open a rich edit control, using parameters to set the size and position of the control, see Note 3.

The fourth step was to create a function to limit the # of chars that can be entered so that the rich edit control can act as a single line TextBox, see Note 4.

Before creating the colour functions it was necessary to create a function to convert RGB hex values, see Note 5.

The sixth step was to create a function to set the background or paper colour of the rich edit control, see Note 6.

The next step was to create a function to set the fore- ground or ink colour of the rich edit control, see Note 7. This function requires a structure which is placed near the top of the program, see Note 8.

The final step was to create a single function that would call all these individual functions, so that in the main part of any program only this function would need to be called each time a new instance of a full-colour text input box was to be created, see note 9.

The following is all of the above functions incorporated into a small demonstration program.

[editor's note: the demo program, colored_textboxes.bas is included in the zip file that is attached to this newsletter to avoid accidental line-wraps that might occur in an email client.]


Home

Use of Color in Graphics

Bitmap Graphics Tutorial

Bitmap Color Formats

Bmp Dimensions

SCAN vs WAIT

Text Input Boxes

An Easy Calendar Control

Shareware Marketing

Date/Time Picker

Text Line-Wrap

Combining Commands

Newsletter help

Index