Writes a character string at a specified location and expanding tabs to the specified tab-stop positions
#include <WinAPIGdi.au3>
_WinAPI_TabbedTextOut ( $hDC, $iX, $iY, $sText [, $aTab = 0 [, $iStart = 0 [, $iEnd = -1 [, $iOrigin = 0]]]] )
$hDC | A handle to the device context. |
$iX | The x-coordinate of the starting point of the string, in logical units. |
$iY | The y-coordinate of the starting point of the string, in logical units. |
$sText | The character string to draw. |
$aTab | [optional] The array containing the tab-stop positions, in logical units. The tab stops must be sorted in increasing order; the smallest x-value should be the first item in the array. Also, it can be an integer value that is one tab-stop position. In this case, the tab stops are separated by the distance specified by this value. If this parameter is 0, tabs are expanded to eight times the average character width. |
$iStart | [optional] The index of array element that contains the first tab-stop position. |
$iEnd | [optional] The index of array element that contains the last tab-stop position. |
$iOrigin | [optional] The x-coordinate of the starting position from which tabs are expanded, in logical units. This allows an application to call the function several times for a single line. If the application calls the function more than once with the starting position set to the same value each time, the function expands all tabs relative to the position specified by this parameter. |
Success: | 1. |
Failure: | 0. |
The string is written in the currently selected font, background color, and text color.
By default, the current position is not used or updated by this function. If an application needs to update the
current position when it calls the function, the application can call _WinAPI_SetTextAlign() with the $TA_UPDATECP
flag set. Then the system ignores the X and Y parameters on subsequent calls to the _WinAPI_TabbedTextOut()
function, using the current position instead.
Call _WinAPI_GetExtended() to retrieve a $tagSIZE structure containing the dimensions of the string.
Search TabbedTextOut in MSDN Library.
#include <FontConstants.au3>
#include <SendMessage.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WinAPIGdiDC.au3>
#include <WinAPIHObj.au3>
#include <WinAPISysWin.au3>
#include <WindowsConstants.au3>
; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 400)
Local $idPic = GUICtrlCreatePic('', 0, 0, 400, 400)
Local $hPic = GUICtrlGetHandle($idPic)
; Create bitmap
Local $hDev = _WinAPI_GetDC($hPic)
Local $hDC = _WinAPI_CreateCompatibleDC($hDev)
Local $hSource = _WinAPI_CreateCompatibleBitmapEx($hDev, 400, 400, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE)))
Local $hSv = _WinAPI_SelectObject($hDC, $hSource)
; Draw objects
Local $hOldBrush = _WinAPI_SelectObject($hDC, _WinAPI_GetStockObject($DC_BRUSH))
Local $hOldPen = _WinAPI_SelectObject($hDC, _WinAPI_GetStockObject($DC_PEN))
_WinAPI_SetTextColor($hDC, 0xCD0091)
_WinAPI_SetBkMode($hDC, $TRANSPARENT)
Local $hFont = _WinAPI_CreateFont(12, 0, 0, 0, $FW_NORMAL, 0, 0, 0, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $ANTIALIASED_QUALITY, $DEFAULT_PITCH, 'Arial Black')
Local $hObj = _WinAPI_SelectObject($hDC, $hFont)
_WinAPI_TextOut($hDC, 10, 15, 'Simple Text')
Local $sTabbedTextOut = 'Tabbed ' & @TAB & 'Text ' & @TAB & 'Out'
_WinAPI_TextOut($hDC, 10, 35, $sTabbedTextOut)
_WinAPI_TabbedTextOut($hDC, 10, 65, $sTabbedTextOut)
_WinAPI_SelectObject($hDC, $hObj)
_WinAPI_DeleteObject($hFont)
; ; Merge bitmap
Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDev, 400, 400)
Local $hBrush = _WinAPI_SelectObject($hDC, $hOldBrush)
_WinAPI_DeleteObject($hBrush)
Local $hPen = _WinAPI_SelectObject($hDC, $hOldPen)
_WinAPI_DeleteObject($hPen)
_WinAPI_SelectObject($hDC, $hBitmap)
_WinAPI_DrawBitmap($hDC, 0, 0, $hSource, $MERGECOPY)
_WinAPI_ReleaseDC($hPic, $hDev)
_WinAPI_SelectObject($hDC, $hSv)
_WinAPI_DeleteObject($hSource)
_WinAPI_DeleteDC($hDC)
; Set bitmap to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
$hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
_WinAPI_DeleteObject($hBitmap)
EndIf
GUISetState(@SW_SHOW)
Do
Until GUIGetMsg() = -3