函数参考


_WinAPI_DrawThemeText

绘制由视觉样式定义颜色和字体的文本.

#Include <WinAPIEx.au3>
_WinAPI_DrawThemeText ( $hTheme, $iPartId, $iStateId, $hDC, $sText, $tRECT, $iFlags )

参数

$hTheme 指定主题数据的窗口句柄.
$iPartId 文本的外观.
如果此值为 0,文本绘制为默认字体;或设备环境选择的字体.
$iStateId 文本外观状态.
$hDC 设备环境句柄.
$sText 包含文本的字符串.
$tRECT $tagRECT 结构,包含绘制文本的矩形.
$iFlags 字符串的格式. 参数可以是一或多个 $DT_* 值.

返回值

成功: 返回 1.
失败: 返回 0,设置 @error 标志为非 0 值, @extended 标志可能包含一个系统错误代码.

注意/说明

None

相关

详情参考

在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, $hTheme, $hObj, $hFont, $hBitmap, $hSource, $hDC, $hDev, $hSv

; 创建 GUI
$hForm = GUICreate('MyGUI', 160, 199)
$Pic = GUICtrlCreatePic('', 0, 0, 160, 199)
$hPic = GUICtrlGetHandle($Pic)

; 创建位图
$hDev = _WinAPI_GetDC($hPic)
$hDC = _WinAPI_CreateCompatibleDC($hDev)
$hSource = _WinAPI_CreateCompatibleBitmapEx($hDev, 160, 199, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE)))
$hSv = _WinAPI_SelectObject($hDC, $hSource)

; 描绘对象
$tRECT = _WinAPI_CreateRectEx(25, 25, 110, 25)
$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)
$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

; 合并位图
$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)

; 设置位图到控件
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
$hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
    _WinAPI_DeleteObject($hBitmap)
EndIf

GUISetState()

Do
Until GUIGetMsg() = -3