article. This guy tried numerous things and the best he came up with is this one which requires much more code (for every control) but not as much dealing with owner drawn controls:
#include <Constants
.au3>
#include <Date
.au3>
#include <EditConstants
.au3>
#include <FontConstants
.au3>
#include <GUIConstantsEx
.au3>
#include <WinAPI
.au3>
#include <WindowsConstants
.au3>
Opt("MustDeclareVars", 1
)
If Not IsDeclared("WM_DWMCOMPOSITIONCHANGED") Then Global Const $WM_DWMCOMPOSITIONCHANGED = 0x031E
If Not IsDeclared("WM_PRINT") Then Global Const $WM_PRINT = 0x0317
If Not IsDeclared("WM_PRINTCLIENT") Then Global Const $WM_PRINTCLIENT = 0x0318
If Not IsDeclared("tagBP_PAINTPARAMS") Then Global Const $tagBP_PAINTPARAMS = "uint Size;uint Flags;" & $tagRECT & ";ptr BlendFunction;"
If Not IsDeclared ("tagDWM_BLURBEHIND") Then Global Const $tagDWM_BLURBEHIND = "uint Flags;int Enable;hwnd RgnBlur;int TransitionOnMaximized;"
If Not IsDeclared("tagPAINTSTRUCT") Then Global Const $tagPAINTSTRUCT = "hwnd hDC;int Erase;" & $tagRECT & ";int Restore;int IncUpdate;ubyte Reserved[32]"
If Not IsDeclared("tagDTTOPTS") Then Global Const $tagDTTOPTS = _
"uint Size;uint Flags;uint clrText;uint clrBorder;uint clrShadow;int TextShadowType;" & $tagPOINT & _
";int BorderSize;int FontPropId;int ColorPropId;int StateId;int ApplyOverlay;int GlowSize;ptr DrawTextCallback;int lParam;"
Global Enum $BPBF_COMPATIBLEBITMAP, $BPBF_DIB, $BPBF_TOPDOWNDIB, $BPBF_TOPDOWNMONODIB
Global Const $PRF_CHECKVISIBLE = 0x00000001
Global Const $PRF_NONCLIENT = 0x00000002
Global Const $PRF_CLIENT = 0x00000004
Global Const $PRF_ERASEBKGND = 0x00000008
Global Const $PRF_CHILDREN = 0x00000010
Global Const $PRF_OWNED = 0x00000020
Global Const $DWM_BB_ENABLE = 0x00000001
Global Const $DWM_BB_BLURREGION = 0x00000002
Global Const $DWM_BB_TRANSITIONONMAXIMIZED = 0x00000004
Global Const $DTT_GRAYED = 0x00000001
Global Const $DTT_FLAGS2VALIDBITS = $DTT_GRAYED
Global Const $DTT_TEXTCOLOR = 0x00000001
Global Const $DTT_BORDERCOLOR = 0x00000002
Global Const $DTT_SHADOWCOLOR = 0x00000004
Global Const $DTT_SHADOWTYPE = 0x00000008
Global Const $DTT_SHADOWOFFSET = 0x00000010
Global Const $DTT_BORDERSIZE = 0x00000020
Global Const $DTT_FONTPROP = 0x00000040
Global Const $DTT_COLORPROP = 0x00000080
Global Const $DTT_STATEID = 0x00000100
Global Const $DTT_CALCRECT = 0x00000200
Global Const $DTT_APPLYOVERLAY = 0x00000400
Global Const $DTT_GLOWSIZE = 0x00000800
Global Const $DTT_CALLBACK = 0x00001000
Global Const $DTT_COMPOSITED = 0x00002000
Global Const $DTT_VALIDBITS = BitOR($DTT_TEXTCOLOR, $DTT_BORDERCOLOR, $DTT_SHADOWCOLOR, $DTT_SHADOWTYPE, $DTT_SHADOWOFFSET, $DTT_BORDERSIZE, _
$DTT_FONTPROP, $DTT_COLORPROP, $DTT_STATEID, $DTT_CALCRECT, $DTT_APPLYOVERLAY, $DTT_GLOWSIZE, $DTT_COMPOSITED)
Global $hUxTheme = DllOpen("uxtheme.dll")
Global $hGUI = GUICreate("Test", 300
, 300
)
Global $hTheme = _WinAPI_OpenThemeData
($hGUI, "globals", $hUxTheme)
; Initialize buffered painting for the current thread.
_WinAPI_BufferedPaintInit
($hUxTheme)
Global $Edit = GUICtrlCreateInput("Hello World",20,10,260,25);Wont work
Global $hEdit = GUICtrlGetHandle(-1
)
GUICtrlSetFont(-1
, 15
, 500
)
Global $hEditProc = DllCallbackRegister("_EditProc", "int", "hwnd;uint;wparam;lparam")
Global $hWndProc = _WinAPI_SetWindowLong($hEdit, $GWL_WNDPROC, DllCallbackGetPtr($hEditProc))
GUIRegisterMsg($WM_ERASEBKGND, "_WM_ERASEBKGND")
GUIRegisterMsg($WM_DWMCOMPOSITIONCHANGED, "_WM_DWMCOMPOSITIONCHANGED")
GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND")
_DrawTime
()
_SendMessage($hGUI, $WM_DWMCOMPOSITIONCHANGED)
AdlibEnable("_DrawTime", 1000
)
GUISetState()
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
_WinAPI_CloseThemeData
($hTheme, $hUxTheme)
_WinAPI_SetWindowLong($hEdit, $GWL_WNDPROC, $hWndProc)
DllCallbackFree($hEditProc)
;Closes down buffered painting for the current thread.
_WinAPI_BufferedPaintUnInit
($hUxTheme)
GUIDelete()
Exit
Func _EditProc
($hWnd, $iMsg, $iwParam, $ilParam)
Local $hDC, $hBufferedDC, $hPaintBuffer
Local $tPS, $pPS
Local $tRect
Switch $iMsg
Case $WM_PAINT
$tPS = DllStructCreate($tagPAINTSTRUCT)
$pPS = DllStructGetPtr($tPS)
$hDC = _WinAPI_BeginPaint
($hWnd, $pPS)
$tRect = DllStructCreate($tagRECT)
For $i = 1
To 4
DllStructSetData($tRect, $i, DllStructGetData($tPS, $i+2
))
Next
$hPaintBuffer = _WinAPI_BeginBufferedPaint
($hDC, DllStructGetPtr($tRect), $BPBF_TOPDOWNDIB, 0
, $hBufferedDC, $hUxTheme)
_SendMessage($hWnd, $WM_PRINTCLIENT, $hBufferedDC, $PRF_CLIENT)
_WinAPI_BufferedPaintSetAlpha
($hPaintBuffer, 0
, 255
, $hUxTheme)
If $hPaintBuffer Then _WinAPI_EndBufferedPaint
($hPaintBuffer, True, $hUxTheme)
_WinAPI_EndPaint
($hWnd, $pPS)
Return 0
EndSwitch
Return _WinAPI_CallWindowProc
($hWndProc, $hWnd, $iMsg, $iwParam, $ilParam)
EndFunc
Func _DrawTime
()
Local $hDC = _WinAPI_GetDC($hGUI)
Local $tClientRect = _WinAPI_GetClientRect($hGUI)
Local $tST = _Date_Time_GetLocalTime()
Local $sText = _Date_Time_SystemTimeToTimeStr($tST)
Local $hFont = _WinAPI_CreateFont(40
, 15
, 0
, 0
, 400
, False, False, False, $DEFAULT_CHARSET, _
$OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Arial Black') ; Edit as necessary.
DllStructSetData($tClientRect, "Top", 50
)
_DrawGlowingText
($hDC, $sText, $tClientRect, 10
, $hFont, 0x0000aa
) ; BGR, implementing RGB is easy.
_WinAPI_DeleteObject($hFont)
_WinAPI_ReleaseDC($hGUI, $hDC)
EndFunc
Func _WM_ERASEBKGND
($hWnd, $iMsg, $iwParam, $ilParam)
Local $hDC = $iwParam
Local $tClientRect = _WinAPI_GetClientRect($hWnd)
Local $hBrush = _WinAPI_GetStockObject($BLACK_BRUSH)
_WinAPI_FillRect($hDC, DllStructGetPtr($tClientRect), $hBrush)
_WinAPI_DeleteObject($hBrush)
Return 1
EndFunc
Func _WM_DWMCOMPOSITIONCHANGED
($hWnd, $iMsg, $iwParam, $ilParam)
Local $tMargs = DllStructCreate($tagMARGINS)
If _WinAPI_DwmIsCompositionEnabled
() Then
For $i = 1
To 4
DllStructSetData($tMargs, $i, -1
)
Next
_WinAPI_DwmExtendFrameIntoClientArea
($hWnd, $tMargs)
EndIf
Return 0
EndFunc
Func _WM_COMMAND
($hWnd, $iMsg, $iwParam, $ilParam)
If _WinAPI_HiWord($iwParam) = $EN_CHANGE Then
_WinAPI_InvalidateRect($hWnd, 0
, False)
Return 0
EndIf
Return $GUI_RUNDEFMSG
EndFunc
Func _DrawGlowingText
($hDC, $sText, $tRc, $iGlowSize = 10
, $hFont = 0
, $iTextClr = -1
)
Local $hCDC
Local $hBrush, $hOldBrush
Local $tRcText
Local $tBI, $tDTO
Local $hDIBBmp, $hOldBmp
Local $hOldFont
Local $tST
Local $iFlags = BitOR($DTT_GLOWSIZE, $DTT_COMPOSITED)
$hCDC = _WinAPI_CreateCompatibleDC($hDC)
$tBI = DllStructCreate($tagBITMAPINFO)
DllStructSetData($tBI, "Size", DllStructGetSize($tBI)-4
)
DllStructSetData($tBI, "Width", DllStructGetData($tRc, "Right")-DllStructGetData($tRc, "Left"))
DllStructSetData($tBI, "Height", -(DllStructGetData($tRc, "Bottom")-DllStructGetData($tRc, "Top")))
DllStructSetData($tBI, "Planes", 1
)
DllStructSetData($tBI, "BitCount", 32
)
DllStructSetData($tBI, "Compression", 0) ; BI_RGB
$hDIBBmp = _WinAPI_CreateDIBSection
($hDC, $tBI)
$hOldBmp = _WinAPI_SelectObject($hCDC, $hDIBBmp)
If $hFont Then $hOldFont = _WinAPI_SelectObject($hCDC, $hFont)
$tDTO = DllStructCreate($tagDTTOPTS)
DllStructSetData($tDTO, "Size", DllStructGetSize($tDTO))
If $iTextClr <> -1
Then
$iFlags = BitOR($iFlags, $DTT_TEXTCOLOR)
DllStructSetData($tDTO, "clrText", $iTextClr)
EndIf
DllStructSetData($tDTO, "Flags", $iFlags)
DllStructSetData($tDTO, "GlowSize", $iGlowSize)
_WinAPI_DrawThemeTextEx
($hTheme, $hCDC, 0
, 0
, $sText, _
BitOR($DT_SINGLELINE, $DT_CENTER, $DT_VCENTER, $DT_NOPREFIX), $tRc, $tDTO)
_WinAPI_BitBlt($hDC, DllStructGetData($tRc, "Left"), DllStructGetData($tRc, "Top"), _
DllStructGetData($tRc, "Right")-DllStructGetData($tRc, "Left"), _
DllStructGetData($tRc, "Bottom")-DllStructGetData($tRc, "Top"), $hCDC, 0, 0, 0xCC0020
) ; SRCCOPY
_WinAPI_SelectObject($hCDC, $hOldBmp)
If $hFont Then _WinAPI_SelectObject($hCDC, $hOldFont)
_WinAPI_DeleteObject($hDIBBmp)
_WinAPI_DeleteDC($hCDC)
EndFunc
Func _WinAPI_DwmExtendFrameIntoClientArea
($hWnd, ByRef $tMargins)
Local $aResult = DllCall("dwmapi.dll", "int", "DwmExtendFrameIntoClientArea", "hwnd", $hWnd, "ptr", DllStructGetPtr($tMargins))
If @error Then Return SetError(@error, @extended, -1
)
Return $aResult[0
]
EndFunc
Func _WinAPI_DwmIsCompositionEnabled
()
Local $aResult = DllCall("dwmapi.dll", "int", "DwmIsCompositionEnabled", "int*", 0
)
If @error Then Return SetError(@error, @extended, -1
)
Return SetError($aResult[0
], 0
, $aResult[1
])
EndFunc
Func _WinAPI_DwmEnableBlurBehindWindow
($hWnd, ByRef $tBlurBehind)
Local $aResult = DllCall("dwmapi.dll", "int", "DwmEnableBlurBehindWindow", "hwnd", $hWnd, "ptr", DllStructGetPtr($tBlurBehind))
If @error Then Return SetError(@error, @extended, 0
)
Return SetError(0
, 0
, $aResult[0
] = 0
)
EndFunc
Func _WinAPI_CreateDIBSection
($hDC, Const ByRef $tBmpInfo, $iUsage = 0
, $pBits = 0
, $hSecond = 0
, $iOffset = 0
)
Local $aResult = DllCall("gdi32.dll", "hwnd", "CreateDIBSection", "hwnd", $hDC, "ptr", DllStructGetPtr($tBmpInfo), _
"uint", $iUsage, "ptr", $pBits, "hwnd", $hSecond, "uint", $iOffset)
If @error Then Return SetError(@error, @extended, 0
)
If $aResult[0
] = 87
Then Return SetError(1, 1, 0); 87 = ERROR_INVALID_PARAMETER
If $aResult[0
] = 0
Then Return SetError(1
, 2
, 0
)
Return SetError(0
, 0
, $aResult[0
])
EndFunc
Func _WinAPI_BeginPaint
($hWnd, $pPaintStruct)
Local $aResult = DllCall("user32.dll", "hwnd", "BeginPaint", "hwnd", $hWnd, "ptr", $pPaintStruct)
If @error Then Return SetError(@error, @extended, 0
)
Return SetError(0
, 0
, $aResult[0
])
EndFunc
Func _WinAPI_EndPaint
($hWnd, $pPaintStruct)
Local $aResult = DllCall("user32.dll", "int", "EndPaint", "hwnd", $hWnd, "ptr", $pPaintStruct)
If @error Then Return SetError(@error, @extended, 0
)
Return SetError(0
, 0
, $aResult[0
])
EndFunc
Func _WinAPI_DrawThemeTextEx
($hTheme, $hDC, $iPartId, $iStateId, $sText, $iFlags, ByRef $tRect, Const ByRef $tDTTOPTS)
Local $aResult = DllCall("uxtheme.dll", "int", "DrawThemeTextEx", "ptr", $hTheme, "hwnd", $hDC, "int", $iPartId, "int", $iStateId, _
"wstr", $sText, "int", -1, "uint", $iFlags, "ptr", DllStructGetPtr($tRect), "ptr", DllStructGetPtr($tDTTOPTS))
If @error Then Return SetError(@error, @extended, 0
)
If $aResult[0
] <> 0
Then Return SetError(1
, 0
, 0
)
Return SetError(0
, 0
, $aResult[0
] = 0
)
EndFunc
Func _WinAPI_OpenThemeData
($hWnd, $sClassList, $hDll = "uxtheme.dll")
Local $aResult = DllCall($hDll, "hwnd", "OpenThemeData", "hwnd", $hWnd, "wstr", $sClassList)
If @error Then Return SetError(@error, @extended, 0
)
Return SetError(0
, 0
, $aResult[0
])
EndFunc
Func _WinAPI_CloseThemeData
($hTheme, $hDll = "uxtheme.dll")
Local $aResult = DllCall($hDll, "int", "CloseThemeData", "hwnd", $hTheme)
If @error Then Return SetError(@error, @extended, 0
)
Return SetError(0
, $aResult[0
], $aResult[0
] = 0
)
EndFunc
Func _WinAPI_BufferedPaintInit
($hDll = "uxtheme.dll")
Local $aResult = DllCall($hDll, "int", "BufferedPaintInit")
If @error Then Return SetError(@error, @extended, 0
)
Return SetError(0
, $aResult[0
], $aResult[0
] = 0
)
EndFunc
Func _WinAPI_BufferedPaintUnInit
($hDll = "uxtheme.dll")
Local $aResult = DllCall($hDll, "int", "BufferedPaintUnInit")
If @error Then Return SetError(@error, @extended, 0
)
Return SetError(0
, $aResult[0
], $aResult[0
] = 0
)
EndFunc
Func _WinAPI_BeginBufferedPaint
($hDC, $pRc, $iBufferFormat, $pPaintParams ,ByRef $phDC, $hDll = "uxtheme.dll")
Local $tHDC = DllStructCreate("hwnd")
Local $aResult = DllCall($hDll, "hwnd", "BeginBufferedPaint", "hwnd", $hDC, "ptr", $pRc, "int", $iBufferFormat, "ptr", $pPaintParams, "ptr", DllStructGetPtr($tHDC))
If @error Then Return SetError(@error, @extended, 0
)
$phDC = DllStructGetData($tHDC, 1
)
Return SetError(0
, 0
, $aResult[0
])
EndFunc
Func _WinAPI_EndBufferedPaint
($hPaintBuffer, $fUpdateTarget = True, $hDll = "uxtheme.dll")
Local $aResult = DllCall($hDll, "int", "EndBufferedPaint", "hwnd", $hPaintBuffer, "int", $fUpdateTarget)
If @error Then Return SetError(@error, @extended, 0
)
Return SetError(0
, $aResult[0
], $aResult[0
] = 0
)
EndFunc
Func _WinAPI_BufferedPaintSetAlpha
($hPaintBuffer, $pRc, $bAlpha = 255
, $hDll = "uxtheme.dll")
Local $aResult = DllCall($hDll, "int", "BufferedPaintSetAlpha", "hwnd", $hPaintBuffer, "ptr", $pRc, "ubyte", $bAlpha)
If @error Then Return SetError(@error, @extended, 0
)
Return SetError(0
, $aResult[0
], $aResult[0
] = 0
)
EndFunc
Another simpler method is to handle the basic controls' WM_CTLCOLOREDIT or WM_CTLCOLORBTN (for example), isn't as satisfying, but it's easier:
#include <Constants
.au3>
#include <Date
.au3>
#include <EditConstants
.au3>
#include <FontConstants
.au3>
#include <GUIConstantsEx
.au3>
#include <WinAPI
.au3>
#include <WindowsConstants
.au3>
Opt("MustDeclareVars", 1
)
If Not IsDeclared("WM_DWMCOMPOSITIONCHANGED") Then Global Const $WM_DWMCOMPOSITIONCHANGED = 0x031E
If Not IsDeclared("WM_PRINT") Then Global Const $WM_PRINT = 0x0317
If Not IsDeclared("WM_PRINTCLIENT") Then Global Const $WM_PRINTCLIENT = 0x0318
If Not IsDeclared("WM_CTLCOLOREDIT") Then Global Const $WM_CTLCOLOREDIT = 0x0133
If Not IsDeclared("tagBP_PAINTPARAMS") Then Global Const $tagBP_PAINTPARAMS = "uint Size;uint Flags;" & $tagRECT & ";ptr BlendFunction;"
If Not IsDeclared ("tagDWM_BLURBEHIND") Then Global Const $tagDWM_BLURBEHIND = "uint Flags;int Enable;hwnd RgnBlur;int TransitionOnMaximized;"
If Not IsDeclared("tagPAINTSTRUCT") Then Global Const $tagPAINTSTRUCT = "hwnd hDC;int Erase;" & $tagRECT & ";int Restore;int IncUpdate;ubyte Reserved[32]"
If Not IsDeclared("tagDTTOPTS") Then Global Const $tagDTTOPTS = _
"uint Size;uint Flags;uint clrText;uint clrBorder;uint clrShadow;int TextShadowType;" & $tagPOINT & _
";int BorderSize;int FontPropId;int ColorPropId;int StateId;int ApplyOverlay;int GlowSize;ptr DrawTextCallback;int lParam;"
Global Enum $BPBF_COMPATIBLEBITMAP, $BPBF_DIB, $BPBF_TOPDOWNDIB, $BPBF_TOPDOWNMONODIB
Global Const $PRF_CHECKVISIBLE = 0x00000001
Global Const $PRF_NONCLIENT = 0x00000002
Global Const $PRF_CLIENT = 0x00000004
Global Const $PRF_ERASEBKGND = 0x00000008
Global Const $PRF_CHILDREN = 0x00000010
Global Const $PRF_OWNED = 0x00000020
Global Const $DWM_BB_ENABLE = 0x00000001
Global Const $DWM_BB_BLURREGION = 0x00000002
Global Const $DWM_BB_TRANSITIONONMAXIMIZED = 0x00000004
Global Const $DTT_GRAYED = 0x00000001
Global Const $DTT_FLAGS2VALIDBITS = $DTT_GRAYED
Global Const $DTT_TEXTCOLOR = 0x00000001
Global Const $DTT_BORDERCOLOR = 0x00000002
Global Const $DTT_SHADOWCOLOR = 0x00000004
Global Const $DTT_SHADOWTYPE = 0x00000008
Global Const $DTT_SHADOWOFFSET = 0x00000010
Global Const $DTT_BORDERSIZE = 0x00000020
Global Const $DTT_FONTPROP = 0x00000040
Global Const $DTT_COLORPROP = 0x00000080
Global Const $DTT_STATEID = 0x00000100
Global Const $DTT_CALCRECT = 0x00000200
Global Const $DTT_APPLYOVERLAY = 0x00000400
Global Const $DTT_GLOWSIZE = 0x00000800
Global Const $DTT_CALLBACK = 0x00001000
Global Const $DTT_COMPOSITED = 0x00002000
Global Const $DTT_VALIDBITS = BitOR($DTT_TEXTCOLOR, $DTT_BORDERCOLOR, $DTT_SHADOWCOLOR, $DTT_SHADOWTYPE, $DTT_SHADOWOFFSET, $DTT_BORDERSIZE, _
$DTT_FONTPROP, $DTT_COLORPROP, $DTT_STATEID, $DTT_CALCRECT, $DTT_APPLYOVERLAY, $DTT_GLOWSIZE, $DTT_COMPOSITED)
Global $hUxTheme = DllOpen("uxtheme.dll")
Global $hGUI = GUICreate("Test", 300
, 300
)
Global $hTheme = _WinAPI_OpenThemeData
($hGUI, "globals", $hUxTheme)
Global $hBrush = _WinAPI_CreateSolidBrush(0
)
Global $Edit = GUICtrlCreateInput("Hello World",20
,10
,260
,25
)
Global $hEdit = GUICtrlGetHandle(-1
)
GUICtrlSetFont(-1
, 15
, 500
)
GUIRegisterMsg($WM_ERASEBKGND, "_WM_ERASEBKGND")
GUIRegisterMsg($WM_DWMCOMPOSITIONCHANGED, "_WM_DWMCOMPOSITIONCHANGED")
GUIRegisterMsg($WM_CTLCOLOREDIT, "_WM_CTLCOLOREDIT")
_DrawTime
()
_SendMessage($hGUI, $WM_DWMCOMPOSITIONCHANGED)
AdlibEnable("_DrawTime", 1000
)
GUISetState()
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
_WinAPI_DeleteObject($hBrush)
_WinAPI_CloseThemeData
($hTheme, $hUxTheme)
GUIDelete()
Exit
Func _WM_CTLCOLOREDIT
($hWnd, $iMsg, $iwParam, $ilParam)
Local $hDC = $iwParam
_WinAPI_SetTextColor($hDC, 0x00FFFF
)
_WinAPI_SetBkColor($hDC, 0
)
Return $hBrush
EndFunc
Func _DrawTime
()
Local $hDC = _WinAPI_GetDC($hGUI)
Local $tClientRect = _WinAPI_GetClientRect($hGUI)
Local $tST = _Date_Time_GetLocalTime()
Local $sText = _Date_Time_SystemTimeToTimeStr($tST)
Local $hFont = _WinAPI_CreateFont(40
, 15
, 0
, 0
, 400
, False, False, False, $DEFAULT_CHARSET, _
$OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Arial Black') ; Edit as necessary.
DllStructSetData($tClientRect, "Top", 50
)
_DrawGlowingText
($hDC, $sText, $tClientRect, 10
, $hFont, 0x0000aa
) ; BGR, implementing RGB is easy.
_WinAPI_DeleteObject($hFont)
_WinAPI_ReleaseDC($hGUI, $hDC)
EndFunc
Func _WM_ERASEBKGND
($hWnd, $iMsg, $iwParam, $ilParam)
Local $hDC = $iwParam
Local $tClientRect = _WinAPI_GetClientRect($hWnd)
Local $hBrush = _WinAPI_GetStockObject($BLACK_BRUSH)
_WinAPI_FillRect($hDC, DllStructGetPtr($tClientRect), $hBrush)
_WinAPI_DeleteObject($hBrush)
Return 1
EndFunc
Func _WM_DWMCOMPOSITIONCHANGED
($hWnd, $iMsg, $iwParam, $ilParam)
Local $tMargs = DllStructCreate($tagMARGINS)
If _WinAPI_DwmIsCompositionEnabled
() Then
For $i = 1
To 4
DllStructSetData($tMargs, $i, -1
)
Next
_WinAPI_DwmExtendFrameIntoClientArea
($hWnd, $tMargs)
EndIf
Return 0
EndFunc
Func _WM_COMMAND
($hWnd, $iMsg, $iwParam, $ilParam)
If _WinAPI_HiWord($iwParam) = $EN_CHANGE Then
_WinAPI_InvalidateRect($hWnd, 0
, False)
Return 0
EndIf
Return $GUI_RUNDEFMSG
EndFunc
Func _DrawGlowingText
($hDC, $sText, $tRc, $iGlowSize = 10
, $hFont = 0
, $iTextClr = -1
)
Local $hCDC
Local $hBrush, $hOldBrush
Local $tRcText
Local $tBI, $tDTO
Local $hDIBBmp, $hOldBmp
Local $hOldFont
Local $tST
Local $iFlags = BitOR($DTT_GLOWSIZE, $DTT_COMPOSITED)
$hCDC = _WinAPI_CreateCompatibleDC($hDC)
$tBI = DllStructCreate($tagBITMAPINFO)
DllStructSetData($tBI, "Size", DllStructGetSize($tBI)-4
)
DllStructSetData($tBI, "Width", DllStructGetData($tRc, "Right")-DllStructGetData($tRc, "Left"))
DllStructSetData($tBI, "Height", -(DllStructGetData($tRc, "Bottom")-DllStructGetData($tRc, "Top")))
DllStructSetData($tBI, "Planes", 1
)
DllStructSetData($tBI, "BitCount", 32
)
DllStructSetData($tBI, "Compression", 0) ; BI_RGB
$hDIBBmp = _WinAPI_CreateDIBSection
($hDC, $tBI)
$hOldBmp = _WinAPI_SelectObject($hCDC, $hDIBBmp)
If $hFont Then $hOldFont = _WinAPI_SelectObject($hCDC, $hFont)
$tDTO = DllStructCreate($tagDTTOPTS)
DllStructSetData($tDTO, "Size", DllStructGetSize($tDTO))
If $iTextClr <> -1
Then
$iFlags = BitOR($iFlags, $DTT_TEXTCOLOR)
DllStructSetData($tDTO, "clrText", $iTextClr)
EndIf
DllStructSetData($tDTO, "Flags", $iFlags)
DllStructSetData($tDTO, "GlowSize", $iGlowSize)
_WinAPI_DrawThemeTextEx
($hTheme, $hCDC, 0
, 0
, $sText, _
BitOR($DT_SINGLELINE, $DT_CENTER, $DT_VCENTER, $DT_NOPREFIX), $tRc, $tDTO)
_WinAPI_BitBlt($hDC, DllStructGetData($tRc, "Left"), DllStructGetData($tRc, "Top"), _
DllStructGetData($tRc, "Right")-DllStructGetData($tRc, "Left"), _
DllStructGetData($tRc, "Bottom")-DllStructGetData($tRc, "Top"), $hCDC, 0, 0, 0xCC0020
) ; SRCCOPY
_WinAPI_SelectObject($hCDC, $hOldBmp)
If $hFont Then _WinAPI_SelectObject($hCDC, $hOldFont)
_WinAPI_DeleteObject($hDIBBmp)
_WinAPI_DeleteDC($hCDC)
EndFunc
Func _WinAPI_DwmExtendFrameIntoClientArea
($hWnd, ByRef $tMargins)
Local $aResult = DllCall("dwmapi.dll", "int", "DwmExtendFrameIntoClientArea", "hwnd", $hWnd, "ptr", DllStructGetPtr($tMargins))
If @error Then Return SetError(@error, @extended, -1
)
Return $aResult[0
]
EndFunc
Func _WinAPI_DwmIsCompositionEnabled
()
Local $aResult = DllCall("dwmapi.dll", "int", "DwmIsCompositionEnabled", "int*", 0
)
If @error Then Return SetError(@error, @extended, -1
)
Return SetError($aResult[0
], 0
, $aResult[1
])
EndFunc
Func _WinAPI_DwmEnableBlurBehindWindow
($hWnd, ByRef $tBlurBehind)
Local $aResult = DllCall("dwmapi.dll", "int", "DwmEnableBlurBehindWindow", "hwnd", $hWnd, "ptr", DllStructGetPtr($tBlurBehind))
If @error Then Return SetError(@error, @extended, 0
)
Return SetError(0
, 0
, $aResult[0
] = 0
)
EndFunc
Func _WinAPI_CreateDIBSection
($hDC, Const ByRef $tBmpInfo, $iUsage = 0
, $pBits = 0
, $hSecond = 0
, $iOffset = 0
)
Local $aResult = DllCall("gdi32.dll", "hwnd", "CreateDIBSection", "hwnd", $hDC, "ptr", DllStructGetPtr($tBmpInfo), _
"uint", $iUsage, "ptr", $pBits, "hwnd", $hSecond, "uint", $iOffset)
If @error Then Return SetError(@error, @extended, 0
)
If $aResult[0
] = 87
Then Return SetError(1, 1, 0); 87 = ERROR_INVALID_PARAMETER
If $aResult[0
] = 0
Then Return SetError(1
, 2
, 0
)
Return SetError(0
, 0
, $aResult[0
])
EndFunc
Func _WinAPI_BeginPaint
($hWnd, $pPaintStruct)
Local $aResult = DllCall("user32.dll", "hwnd", "BeginPaint", "hwnd", $hWnd, "ptr", $pPaintStruct)
If @error Then Return SetError(@error, @extended, 0
)
Return SetError(0
, 0
, $aResult[0
])
EndFunc
Func _WinAPI_EndPaint
($hWnd, $pPaintStruct)
Local $aResult = DllCall("user32.dll", "int", "EndPaint", "hwnd", $hWnd, "ptr", $pPaintStruct)
If @error Then Return SetError(@error, @extended, 0
)
Return SetError(0
, 0
, $aResult[0
])
EndFunc
Func _WinAPI_DrawThemeTextEx
($hTheme, $hDC, $iPartId, $iStateId, $sText, $iFlags, ByRef $tRect, Const ByRef $tDTTOPTS)
Local $aResult = DllCall("uxtheme.dll", "int", "DrawThemeTextEx", "ptr", $hTheme, "hwnd", $hDC, "int", $iPartId, "int", $iStateId, _
"wstr", $sText, "int", -1, "uint", $iFlags, "ptr", DllStructGetPtr($tRect), "ptr", DllStructGetPtr($tDTTOPTS))
If @error Then Return SetError(@error, @extended, 0
)
If $aResult[0
] <> 0
Then Return SetError(1
, 0
, 0
)
Return SetError(0
, 0
, $aResult[0
] = 0
)
EndFunc
Func _WinAPI_OpenThemeData
($hWnd, $sClassList, $hDll = "uxtheme.dll")
Local $aResult = DllCall($hDll, "hwnd", "OpenThemeData", "hwnd", $hWnd, "wstr", $sClassList)
If @error Then Return SetError(@error, @extended, 0
)
Return SetError(0
, 0
, $aResult[0
])
EndFunc
Func _WinAPI_CloseThemeData
($hTheme, $hDll = "uxtheme.dll")
Local $aResult = DllCall($hDll, "int", "CloseThemeData", "hwnd", $hTheme)
If @error Then Return SetError(@error, @extended, 0
)
Return SetError(0
, $aResult[0
], $aResult[0
] = 0
)
EndFunc
Func _WinAPI_BufferedPaintInit
($hDll = "uxtheme.dll")
Local $aResult = DllCall($hDll, "int", "BufferedPaintInit")
If @error Then Return SetError(@error, @extended, 0
)
Return SetError(0
, $aResult[0
], $aResult[0
] = 0
)
EndFunc
Func _WinAPI_BufferedPaintUnInit
($hDll = "uxtheme.dll")
Local $aResult = DllCall($hDll, "int", "BufferedPaintUnInit")
If @error Then Return SetError(@error, @extended, 0
)
Return SetError(0
, $aResult[0
], $aResult[0
] = 0
)
EndFunc
Func _WinAPI_BeginBufferedPaint
($hDC, $pRc, $iBufferFormat, $pPaintParams ,ByRef $phDC, $hDll = "uxtheme.dll")
Local $tHDC = DllStructCreate("hwnd")
Local $aResult = DllCall($hDll, "hwnd", "BeginBufferedPaint", "hwnd", $hDC, "ptr", $pRc, "int", $iBufferFormat, "ptr", $pPaintParams, "ptr", DllStructGetPtr($tHDC))
If @error Then Return SetError(@error, @extended, 0
)
$phDC = DllStructGetData($tHDC, 1
)
Return SetError(0
, 0
, $aResult[0
])
EndFunc
Func _WinAPI_EndBufferedPaint
($hPaintBuffer, $fUpdateTarget = True, $hDll = "uxtheme.dll")
Local $aResult = DllCall($hDll, "int", "EndBufferedPaint", "hwnd", $hPaintBuffer, "int", $fUpdateTarget)
If @error Then Return SetError(@error, @extended, 0
)
Return SetError(0
, $aResult[0
], $aResult[0
] = 0
)
EndFunc
Func _WinAPI_BufferedPaintSetAlpha
($hPaintBuffer, $pRc, $bAlpha = 255
, $hDll = "uxtheme.dll")
Local $aResult = DllCall($hDll, "int", "BufferedPaintSetAlpha", "hwnd", $hPaintBuffer, "ptr", $pRc, "ubyte", $bAlpha)
If @error Then Return SetError(@error, @extended, 0
)
Return SetError(0
, $aResult[0
], $aResult[0
] = 0
)
EndFunc
I guess that Vista doesn't make it easy with the old GDI drawing controls. ::