绘制指定控件的部分边界,并依据视觉样式的定义填充.
#Include <WinAPIEx.au3>
_WinAPI_DrawThemeBackground ( $hTheme, $iPartId, $iStateId, $hDC, $tRECT [, $tCLIP] )
$hTheme | 指定主题数据的窗口句柄. |
$iPartId | 提请绘制的部分. |
$iStateId | 提请绘制部分的状态. |
$hDC | 设备环境句柄. |
$tRECT | $tagRECT 结构,包含绘制背景图像的矩形. |
$tCLIP | [可选参数] $tagRECT 结构,包含一个剪辑矩形. |
成功: | 返回 1. |
失败: | 返回 0,设置 @error 标志为非 0 值, @extended 标志可能包含一个系统错误代码. |
在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