SAMPLE: Setting Tab Stops in a Windows List BoxLast reviewed: February 15, 1996Article ID: Q66652 |
The information in this article applies to:
SUMMARYTab stops can be used in a list box to align columns of information. This article describes how to set tab stops in a list box and provides a code example that demonstrates the process.
MORE INFORMATIONTo set tab stops in a list box, perform the following three steps:
ExampleBelow is an example of the process. Tab stops are set at character positions 16, 32, 58, and 84.
int TabStopList[TOTAL_TABS]; /* Array to store tabs */ TabStopList[0] = 16 * 4; /* 16 spaces */ TabStopList[1] = 32 * 4; /* 32 spaces */ TabStopList[2] = 58 * 4; /* 58 spaces */ TabStopList[3] = 84 * 4; /* 84 spaces */ SendMessage(GetDlgItem(hDlg, IDD_LISTBOX), LB_SETTABSTOPS, TOTAL_TABS, (LONG)(LPSTR)TabStopList);NOTE: For Win32, use LPARAM instead of LONG. If the desired unit of measure is character position, then specifying tab positions in dialog units is recommended. Dialog units are independent of the current font; they are loosely based on the average width of the system font. Each character takes approximately four dialog units. NOTE: Under Windows 95, dialog base units for dialogs based on non-system fonts are calculated in a different way than under Windows 3.1. For more information, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q125681 TITLE : How to Calculate Dialog Base Units with Non-system-based FontFor more control over the exact placement of a tab stop, the desired position should be converted to a pixel offset and this offset should be converted into dialog units. The following formula will take a pixel position and convert it into the first tab stop position before (or at) the desired pixel position:
TabStopList[n] = 4 * DesiredPixelPosition / LOWORD(GetDialogBaseUnits());There is a sample application named TABSTOPS in the Microsoft Software Library that demonstrates how tab stops are set and used in a list box. Download TABSTOPS.EXE, a self-extracting file, from the Microsoft Software Library (MSL) on the following services:
|
Additional reference words: 3.00 3.10 3.50 4.00 softlib
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |