绘制指定矩形内带有阴影的格式化文本.
#Include <WinAPIEx.au3>
_WinAPI_DrawShadowText ( $hDC, $sText, $rgbText, $rgbShadow [, $iXOffset [, $iYOffset [, $tRECT [, $iFlags]]]] )
$hDC | 设备环境句柄. |
$sText | 文本字符串. |
$rgbText | 文本的 RGB 颜色. |
$rgbShadow | 阴影的 RGB 颜色. |
$iXOffset | [可选参数] 文字开始位置的 x 坐标. |
$iYOffset | [可选参数] 文字开始位置的 y 坐标. |
$tRECT | [可选参数] $tagRECT 结构,包含被绘制文本的逻辑坐标 如果此参数为 0, 将与设备环境($hDC)同等大小. |
$iFlags | [可选参数] 此标志指定如何绘制文本. 此参数可以是格式文本常量 ($DT_*) 的组合 |
成功: | 返回 1. |
失败: | 返回 0,并设置@error标志为非 0 值. |
在MSDN中搜索
#Include <APIConstants.au3>
#Include <WinAPIEx.au3>
Opt('MustDeclareVars', 1)
Global Const $STM_SETIMAGE = 0x0172
Global Const $STM_GETIMAGE = 0x0173
Global $hForm, $Pic, $hPic, $tRECT, $Width, $Height, $hObj, $hFont, $hBitmap, $hSource, $hDC, $hDestDC, $hDestSv, $hSrcDC, $hSrcSv
; 创建 GUI
$hForm = GUICreate('MyGUI', 400, 100)
$Pic = GUICtrlCreatePic('', 20, 20, 360, 60)
$hPic = GUICtrlGetHandle($Pic)
; 创建位图
$tRECT = _WinAPI_GetClientRect($hPic)
$Width = DllStructGetData($tRECT, 3) - DllStructGetData($tRECT, 1)
$Height = DllStructGetData($tRECT, 4) - DllStructGetData($tRECT, 2)
$hDC = _WinAPI_GetDC($hPic)
$hDestDC = _WinAPI_CreateCompatibleDC($hDC)
$hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $Width, $Height)
$hDestSv = _WinAPI_SelectObject($hDestDC, $hBitmap)
$hSrcDC = _WinAPI_CreateCompatibleDC($hDC)
$hSource = _WinAPI_CreateCompatibleBitmapEx($hDC, $Width, $Height, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE)))
$hSrcSv = _WinAPI_SelectObject($hSrcDC, $hSource)
$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, $Width, $Height, $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)
;设置位图到控件
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
$hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
_WinAPI_DeleteObject($hBitmap)
EndIf
GUISetState()
Do
Until GUIGetMsg() = -3