Broad Network


Windows List Box

Windows Predefined Controls – Part 15

Volume - Windows User Interface

Forward: In this part of the series, we look at Windows List Box.

By: Chrysanthus Date Published: 29 Aug 2012

Introduction

This is part 15 of my series, Windows Predefined Controls. In order to understand this tutorial, you most have read all the previous tutorials of the series. In this part of the series, we look at Windows List Box.

Note: If you cannot see the code or if you think anything is missing (broken link, image absent), just contact me at forchatrans@yahoo.com. That is, contact me for the slightest problem you have about what you are reading.

A List Box
A list box is a control that has a list of items that the user can choose from. The user chooses an item by selecting it. The user selects an item by clicking it. It is possible to select an item using the keyboard (see later). In this series we shall talk about list boxes whose items are strings (texts). A list box can provide a scroll bar if the items are too many for the space provided for the number of items. Selecting a list item changes its text color and its background color. In other words, selecting a list item highlights the item.

Creating a List Box
You can create a list box using the CreateWindowEx function. The class is, LISTBOX. Do not forget to type WS_CHILD since it is a child window.

Types of List Boxes
There are two types of list boxes: single-selection and multiple-selection. Single-selection is the default. In a single-selection list box, the user can select only one item at a time. In a multiple-selection list box, the user can select more than one item at a time. If you want the multiple-selection list box, use the LBS_EXTENDEDSEL style. You do not need to type any special style if you want the single-selection list box.

Coding
You can create a List box using the CreateWindowEx function. After that you have to send each item string to the box using the SendMessage function. I have dedicated a whole tutorial for this. Before we arrive at that tutorial, we shall first look at list box styles, notifications and messages.

Zero-Based Indexing
The items in the list box are numbered counting from zero at the first item. Each of these numbers is called an index

That is it for this part of the series. We stop here and continue in the next part.

Chrys

Related Courses

C++ Course
Relational Database and Sybase
Windows User Interface
Computer Programmer – A Jack of all Trade – Poem
NEXT

Comments

Become the Writer's Fan
Send the Writer a Message