A Simple Owner-Draw List Box

Description

In this example, we will add a bitmap to the entries in an array. First consider the following simple dialog box that displays a list box of drive letters. This dialog does not display bitmaps in the list box.

dim drives[20] as C
data = <<%dlg%
C:
D:
E:
F:
G:
H:
%dlg%
drives.initialize(data)
result = ui_dlg_box("Select a Drive",<<%dlg%
{region}
[.10,10driveletter^#drives]
{endregion};

%dlg%)

This script produces the following dialog:

images/XD_Select a drive.gif

Now let's add a drive icon next to each entry in the list box.

dim drives[20] as C
data = <<%dlg%
C:
D:
E:
F:
G:
H:
%dlg%
drives.initialize(data)
result = ui_dlg_box("Select a Drive",<<%dlg%
{region}
[%I=filebox:3:8;O={I=1} {@1}%.10,10driveletter^#drives]
{endregion};

%dlg%)

This script produces the following dialog:

images/XD_List_box_O_directive.gif

In the above script the list box format specification includes two parts. The first part defines the image list. In this case there is only one image. We are using the built-in Alpha Anywhere system image called "filebox". This image has 8 sub-images. We are using the 3 rd of the 8 sub-images.

  • The second part is the owner-draw string. Let's analyze the string O={I=1} {@1} :

  • {I=1} - display the first image in the image list

  • space - include a space after the image

  • {@1} - display the input value, starting with position 1.

Limitations

Desktop applications only.

See Also