UDF > WinAPIEx > GDI > Paint & Draw >


_WinAPI_DrawShadowText

Dessine du texte formaté dans un rectangle spécifié avec une ombre portée

#include <WinAPIGdi.au3>
_WinAPI_DrawShadowText ( $hDC, $sText, $iRGBText, $iRGBShadow [, $iXOffset = 0 [, $iYOffset = 0 [, $tRECT = 0 [, $iFlags = 0]]]] )

Paramètres

$hDC Handle du contexte de périphérique.
$sText La chaîne qui contient le texte à dessiner.
$iRGBText La couleur du texte, en RGB.
$iRGBShadow La couleur de l'ombre, en RGB.
$iXOffset [optionnel] La coordonnée x de l'emplacemen où le texte doit commencer. Par défaut, 0.
$iYOffset [optionnel] La coordonnée y de l'emplacement où le texte doit commencer. Par défaut, 0.
$tRECT [optionnel] La structure $tagRECT qui contient, en coordonnées logiques, le rectangle dans lequel le texte sera dessiné.
Si ce paramètre est 0 (valeur par défaut), la taille sera égale à la taille du contexte de périphérique ($hDC).
$iFlags [optionnel] Les flags qui spécifient comment le texte doit être dessiné. Ce paramètre doit être une combinaison des constantes de texte formaté ($DT_*).

Valeur de retour

Succès: Retourne True
Échec: Retourne False

Voir aussi

Consultez DrawShadowText dans la librairie MSDN.

Exemple

#include <FontConstants.au3>
#include <GUIConstantsEx.au3>
#include <SendMessage.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WinAPIGdiDC.au3>
#include <WinAPIHObj.au3>
#include <WinAPISysWin.au3>
#include <WindowsConstants.au3>

; Crée une GUI
Local $hForm = GUICreate('Test '& StringReplace(@ScriptName, '.au3', '()'), 400, 100)
Local $idPic = GUICtrlCreatePic('', 20, 20, 360, 60)
Local $hPic = GUICtrlGetHandle($idPic)

; Crée un bitmap
Local $tRECT = _WinAPI_GetClientRect($hPic)
Local $iWidth = DllStructGetData($tRECT, 3) - DllStructGetData($tRECT, 1)
Local $iHeight = DllStructGetData($tRECT, 4) - DllStructGetData($tRECT, 2)
Local $hDC = _WinAPI_GetDC($hPic)
Local $hDestDC = _WinAPI_CreateCompatibleDC($hDC)
Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $iWidth, $iHeight)
Local $hDestSv = _WinAPI_SelectObject($hDestDC, $hBitmap)
Local $hSrcDC = _WinAPI_CreateCompatibleDC($hDC)
Local $hSource = _WinAPI_CreateCompatibleBitmapEx($hDC, $iWidth, $iHeight, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE)))
Local $hSrcSv = _WinAPI_SelectObject($hSrcDC, $hSource)
Local $hFont = _WinAPI_CreateFont(65, 0, 0, 0, $FW_NORMAL, 0, 0, 0, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $ANTIALIASED_QUALITY, $DEFAULT_PITCH, 'Arial')
_WinAPI_SelectObject($hSrcDC, $hFont)
_WinAPI_DrawShadowText($hSrcDC, 'Shadow Text', 0xF06000, 0x808080, 3, 3, $tRECT, BitOR($DT_CENTER, $DT_SINGLELINE, $DT_VCENTER))
_WinAPI_BitBlt($hDestDC, 0, 0, $iWidth, $iHeight, $hSrcDC, 0, 0, $MERGECOPY)

_WinAPI_ReleaseDC($hPic, $hDC)
_WinAPI_SelectObject($hDestDC, $hDestSv)
_WinAPI_DeleteDC($hDestDC)
_WinAPI_SelectObject($hSrcDC, $hSrcSv)
_WinAPI_DeleteDC($hSrcDC)
_WinAPI_DeleteObject($hSource)
_WinAPI_DeleteObject($hFont)

; Définit le bitmap dans le contrôle Picture
_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