Specifying the Font Color


In this next example, we show how you can control the font color for the text in the list box. The owner draw specification for controlling the font color is:

{C=Unselected Color, Selected Color [,Disabled Color]}

In the script below, we define two variables, "fontcolor1" and "fontcolor2". "Fontcolor1" sets the unselected color to Dark Blue, and the selected color to White. Notice that we do not bother to define the disabled color because it is meaningless in the context of a list box. "Fontcolor2" sets the color to black for unselected text, and white for selected text. In the code that defines the "data" variable, you see that we prefix line 1 of the data with "fontcolor1". This causes the row to be shown in Dark Blue when it is not selected, and in White when it is selected. Line 2 is prefixed with "fontcolor2", which causes line to be shown in the default colors of black for unselected and white for selected. Note that it is not required to specify the default font color for line 2 as Alpha Anywhere automatically resets the font color on each new line.

tab1 = "{T=1}"
tab2 = "{T=2}"
font2 = "{F=Arial,8,B}"
font1 = "{F=Arial,8}"
fontcolor1 = "{C=Dark Blue,White}"
fontcolor2 = "{C=Black,White}"
dim data_selected as N
data_selected = 1
data = fontcolor1+font2+"Boston"+font1+tab1+"Red Sox"+tab2+"Baseball" + crlf()+\
       fontcolor2+"Boston"+tab1+"Celtics"+tab2+"Basketball" + crlf()+\
       "Boston"+tab1+"Patriots"+tab2+"Football" + crlf()+\
       font2+"New York"+font1+tab1+"Yankees"+tab2+"Baseball" + crlf()

This script produces this dialog:

images/XD_Specifying the font color for data.gif


Desktop applications only

See Also