Dessine un texte en utilisant la couleur et la police, définies par le style visuel
#include <WinAPITheme.au3>
_WinAPI_DrawThemeText ( $hTheme, $iPartID, $iStateID, $hDC, $sText, $tRECT, $iFlags )
$hTheme | Handle de données du thème de fenêtre spécifié. |
$iPartID | La partie qui a l'apparence de texte souhaité. Si cette valeur est 0, le texte est rédigé dans la police par défaut, ou une police sélectionnée dans le contexte de périphérique. |
$iStateID | L'état de la partie. |
$hDC | Handle du contexte de périphérique à utiliser pour le dessin. |
$sText | La chaîne qui contient le texte à dessiner. |
$tRECT | Structure $tagRECT qui contient le rectangle dans lequel le texte doit être dessiné. |
$iFlags | Les flags de formatage de la chaîne ($DT_*). |
Succès: | Retourne 1. |
Échec: | Retourne 0 et définit @error <> 0, @extended peut contenir le code d'erreur HRESULT. |
Consultez DrawThemeText dans la librairie MSDN.
#include <FontConstants.au3> #include <GUIConstantsEx.au3> #include <SendMessage.au3> #include <StaticConstants.au3> #include <WinAPIGdi.au3> #include <WinAPIGdiDC.au3> #include <WinAPIHObj.au3> #include <WinAPIMisc.au3> #include <WinAPISysWin.au3> #include <WinAPITheme.au3> #include <WindowsConstants.au3> ; Crée une GUI Local $hForm = GUICreate('Test '& StringReplace(@ScriptName, '.au3', '()'), 160, 199) Local $idPic = GUICtrlCreatePic('', 0, 0, 160, 199) Local $hPic = GUICtrlGetHandle($idPic) ; Crée un bitmap Local $hDev = _WinAPI_GetDC($hPic) Local $hDC = _WinAPI_CreateCompatibleDC($hDev) Local $hSource = _WinAPI_CreateCompatibleBitmapEx($hDev, 160, 199, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE))) Local $hSv = _WinAPI_SelectObject($hDC, $hSource) ; Dessine des objets Local $tRECT = _WinAPI_CreateRectEx(25, 25, 110, 25) Local $hFont = _WinAPI_CreateFont(12, 0, 0, 0, $FW_NORMAL, 0, 0, 0, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, $DEFAULT_PITCH, 'MS Shell Dlg') _WinAPI_SetBkMode($hDC, $TRANSPARENT) _WinAPI_SelectObject($hDC, $hFont) Local $hTheme = _WinAPI_OpenThemeData($hForm, 'Button') If Not @error Then For $i = 1 To 5 _WinAPI_DrawThemeBackground($hTheme, 1, $i, $hDC, $tRECT) _WinAPI_DrawThemeText($hTheme, 1, $i, $hDC, 'OK', $tRECT, BitOR($DT_CENTER, $DT_SINGLELINE, $DT_VCENTER)) _WinAPI_OffsetRect($tRECT, 0, 31) Next _WinAPI_CloseThemeData($hTheme) EndIf ; Fusionne le bitmap Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDev, 160, 199) _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) ; Définit le bitmap dans le contrôle _SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap) Local $hObj = _SendMessage($hPic, $STM_GETIMAGE) If $hObj <> $hBitmap Then _WinAPI_DeleteObject($hBitmap) EndIf GUISetState(@SW_SHOW) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE