LONG TabbedTextOut(hdc, xPosStart, yPosStart, lpszString, cbString, cTabStops, lpnTabPositions, nTabOrigin) | |||||
HDC hdc; | /* handle of device context | */ | |||
int xPosStart; | /* x-coordinate of starting position | */ | |||
int yPosStart; | /* y-coordinate of starting position | */ | |||
LPCSTR lpszString; | /* address of string | */ | |||
int cbString; | /* number of characters in string | */ | |||
int cTabStops; | /* number of tabs in array | */ | |||
int FAR* lpnTabPositions; | /* address of array with tab positions | */ | |||
int nTabOrigin; | /* x-coordinate for tab expansion | */ |
The TabbedTextOut function writes a character string at the specified location, expanding tabs to the values specified in the array of tab-stop positions. The function writes text in the currently selected font.
hdc
Identifies the device context.
xPosStart
Specifies the logical x-coordinate of the starting point of the string.
yPosStart
Specifies the logical y-coordinate of the starting point of the string.
lpszString
Points to the character string to be drawn.
cbString
Specifies the number of characters in the string.
cTabStops
Specifies the number of values in the array of tab-stop positions.
lpnTabPositions
Points to an array containing the tab-stop positions, in device units. The tab stops must be sorted in increasing order; the smallest x-value should be the first item in the array.
nTabOrigin
Specifies the logical x-coordinate of the starting position from which tabs are expanded.
The return value is the dimensions of the string, in logical units, if the function is successful. The low-order word contains the string width; the high-order word contains the string height. Otherwise, the return value is zero.
If the cTabStops parameter is zero and the lpnTabPositions parameter is NULL, tabs are expanded to eight times the average character width.
If cTabStops is 1, the tab stops are separated by the distance specified by the first value in the lpnTabPositions array.
If the lpnTabPositions array contains more than one value, a tab stop is set for each value in the array, up to the number specified by cTabStops.
The nTabOrigin parameter allows an application to call the TabbedTextOut function several times for a single line. If the application calls TabbedTextOut more than once with the nTabOrigin set to the same value each time, the function expands all tabs relative to the position specified by nTabOrigin.
By default, the current position is not used or updated by the TabbedTextOut function. If an application must update the current position when calling TabbedTextOut, it can call the SetTextAlign function with the wFlags parameter set to TA_UPDATECP. When this flag is set, Windows ignores the xPosStart and yPosStart parameters on subsequent calls to the TabbedTextOut function, using the current position instead.
The following example expands tabs from the same x-coordinate as the string's starting point:
LPSTR lpszTabbedText = "Column 1\tColumn 2\tTest of TabbedTextOut";
int aTabs[2] = { 150, 300 };
int iStartXPos = 100;
int iStartYPos = 100;
TabbedTextOut(hdc, /* handle of device context */
iStartXPos, iStartYPos, /* starting coordinates */
lpszTabbedText, /* address of text */
lstrlen(lpszTabbedText), /* number of characters */
sizeof(aTabs) / sizeof(int), /* number of tabs in array */
aTabs, /* array for tab positions */
iStartXPos); /* x-coord. for tab expanding */