Dessine un texte en utilisant la couleur et la police d�finies par le style visuel
#include <WinAPITheme.au3>
_WinAPI_DrawThemeTextEx ( $hTheme, $iPartID, $iStateID, $hDC, $sText, $tRECT, $iFlags, $tDTTOPTS )
$hTheme | Handle des 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 dessin� 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_*). |
$tDTTOPTS | Structure $tagDTTOPTS qui d�finit les options de formatage suppl�mentaires. |
Succ�s: | Retourne 1. |
�chec: | Retourne 0 et d�finit @error <> 0, @extended peut contenir le code d'erreur HRESULT. |
Cette fonction n�cessite Windows Vista ou une version ult�rieure.
Consultez DrawThemeTextEx dans la librairie MSDN.
#include <APIThemeConstants.au3> #include <FontConstants.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <WinAPIGdi.au3> #include <WinAPIGdiDC.au3> #include <WinAPIHObj.au3> #include <WinAPIMisc.au3> #include <WinAPISysWin.au3> #include <WinAPITheme.au3> #include <WindowsConstants.au3> If Not _WinAPI_DwmIsCompositionEnabled() Then MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Erreur', 'N�cessite Windows Vista ou une version ult�rieure avec un th�me Aero install�.') Exit EndIf OnAutoItExitRegister('OnAutoItExit') ; Cr�e une GUI Local $hForm = GUICreate('Test '& StringReplace(@ScriptName, '.au3', '()'), 240, 240) GUICtrlCreateIcon(@ScriptDir & '\Extras\Soccer.ico', 0, 88, 68, 64, 64) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreateLabel('', 70, 130, 100, 30) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetState(-1, $GUI_DISABLE) Global $g_hLabel = GUICtrlGetHandle(-1) GUISetBkColor(0) ; Inscrit une proc�dure fen�tre label Global $g_hDll = DllCallbackRegister('_WinProc', 'ptr', 'hwnd; uint; wparam; lparam ') Local $pDll = DllCallbackGetPtr($g_hDll) Global $g_hProc = _WinAPI_SetWindowLong($g_hLabel, $GWL_WNDPROC, $pDll) ; Cr�e l'effet "feuille de verre" sur la totalit� de la fen�tre. Vous devez appeler cette fonction lorsque la composition DWM est activ�e. _WinAPI_DwmExtendFrameIntoClientArea($hForm) GUISetState(@SW_SHOW) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func _DrawText($hDC, $sText, $tRECT) ; Id�e originale par Authenticity Local $iWidth = DllStructGetData($tRECT, 3) - DllStructGetData($tRECT, 1) Local $iHeight = DllStructGetData($tRECT, 4) - DllStructGetData($tRECT, 2) Local $tDTTOPTS = DllStructCreate($tagDTTOPTS) DllStructSetData($tDTTOPTS, 'Size', DllStructGetSize($tDTTOPTS)) DllStructSetData($tDTTOPTS, 'Flags', BitOR($DTT_TEXTCOLOR, $DTT_GLOWSIZE, $DTT_COMPOSITED)) DllStructSetData($tDTTOPTS, 'clrText', 0x0000C0) DllStructSetData($tDTTOPTS, 'GlowSize', 12) Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC) Local $hBitmap = _WinAPI_CreateDIB($iWidth, -$iHeight) Local $hSv1 = _WinAPI_SelectObject($hMemDC, $hBitmap) Local $hFont = _WinAPI_CreateFont(26, 0, 0, 0, $FW_NORMAL, 0, 0, 0, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, $DEFAULT_PITCH, 'Segoe Script') Local $hSv2 = _WinAPI_SelectObject($hMemDC, $hFont) $tRECT = _WinAPI_CreateRect(0, 0, $iWidth, $iHeight) Local $hTheme = _WinAPI_OpenThemeData($hForm, 'Globals') _WinAPI_DrawThemeTextEx($hTheme, 0, 0, $hMemDC, $sText, $tRECT, BitOR($DT_CENTER, $DT_SINGLELINE, $DT_VCENTER), $tDTTOPTS) _WinAPI_BitBlt($hDC, 0, 0, $iWidth, $iHeight, $hMemDC, 0, 0, $SRCCOPY) _WinAPI_CloseThemeData($hTheme) _WinAPI_SelectObject($hMemDC, $hSv1) _WinAPI_DeleteObject($hBitmap) _WinAPI_SelectObject($hMemDC, $hSv2) _WinAPI_DeleteObject($hFont) _WinAPI_DeleteDC($hMemDC) EndFunc ;== >_DrawText Func _WinProc($hWnd, $iMsg, $wParam, $lParam) Switch $iMsg Case $WM_PAINT Local $tPAINTSTRUCT Local $hDC = _WinAPI_BeginPaint($hWnd, $tPAINTSTRUCT) _DrawText($hDC, 'Soccer', _WinAPI_GetClientRect($hWnd)) _WinAPI_EndPaint($hWnd, $tPAINTSTRUCT) Return 0 EndSwitch Return _WinAPI_CallWindowProc($g_hProc, $hWnd, $iMsg, $wParam, $lParam) EndFunc ;== >_WinProc Func OnAutoItExit() _WinAPI_SetWindowLong($g_hLabel, $GWL_WNDPROC, $g_hProc) DllCallbackFree($g_hDll) EndFunc ;==>OnAutoItExit