Jump to content

How do I use DrawThemeTextEx to get glowing text on aero glass?


Recommended Posts

How would I use DrawThemeTextEx() to draw glowing text on aero glass in my AutoIt app?

Found some info about it Here and Here

Edited by Vadersapien
Try Pacfox, my Firefox theme.Try Power Eject, my windows gadget that allows you to eject most drives.Using AutoIt 3.3.4.0, Windows 7 Premium, Intel Core 2 Quad CPU @ 2.66ghz, 4gb RAM, Nvidia GeForce 9500GT Graphics Card & Samsung 22" Monitor.
Link to comment
Share on other sites

Without "Ex" is something like this.

#Include <WinAPI.au3>
#Include <WindowsConstants.au3>

Global Const $BP_GROUPBOX = 4
Global Const $GBS_NORMAL = 1

$hForm = GUICreate('MyGUI', 400, 400)
$Group = GUICtrlCreateGroup('Group', 20, 20, 360, 360)
$hGroup = GUICtrlGetHandle(-1)
GUISetState()

$hDC = _WinAPI_GetDC($hForm)
$tRect = _WinAPI_GetClientRect($hForm)
$hTheme = DllCall('uxtheme.dll', 'ptr', 'OpenThemeData', 'hwnd', $hGroup, 'wstr', 'BUTTON')
DllCall('uxtheme.dll', 'lresult', 'DrawThemeText', 'ptr', $hTheme[0], 'ptr', $hDC, 'int', $BP_GROUPBOX, 'int', $GBS_NORMAL, 'wstr', 'Simple Text', 'int', -1, 'dword', BitOR($DT_CENTER, $DT_VCENTER, $DT_SINGLELINE), 'dword', 0, 'ptr', DllStructGetPtr($tRect))
DllCall('uxtheme.dll', 'lresult', 'CloseThemeData', 'ptr', $hTheme[0])
_WinAPI_ReleaseDC($hForm, $hDC)

Do
Until GUIGetMsg() = -3
Link to comment
Share on other sites

I don't really know too much about DLL calls to do it myself...and the glow is really important...

In case it helps, the first "Here" link actually works now...

Try Pacfox, my Firefox theme.Try Power Eject, my windows gadget that allows you to eject most drives.Using AutoIt 3.3.4.0, Windows 7 Premium, Intel Core 2 Quad CPU @ 2.66ghz, 4gb RAM, Nvidia GeForce 9500GT Graphics Card & Samsung 22" Monitor.
Link to comment
Share on other sites

#include <Date.au3>
#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
Opt("MustDeclareVars", 1)

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)

If Not IsDeclared("WM_DWMCOMPOSITIonchangeD") Then Global Const $WM_DWMCOMPOSITIonchangeD = 0x031E
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 $hGUI = GUICreate("Test", 300, 300)
Global $hTheme = _WinAPI_OpenThemeData($hGUI, "globals")

GUIRegisterMsg($WM_ERASEBKGND, "_WM_ERASEBKGND")
GUIRegisterMsg($WM_DWMCOMPOSITIonchangeD, "_WM_DWMCOMPOSITIonchangeD")
GUISetState()

_SendMessage($hGUI, $WM_DWMCOMPOSITIonchangeD)
AdlibEnable("_DrawTime", 1000)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

_WinAPI_CloseThemeData($hTheme)
GUIDelete()
Exit


Func _DrawTime()
    Local $hDC = _WinAPI_GetDC($hGUI)
    Local $tClientRect = _WinAPI_GetClientRect($hGUI)
    Local $tST = _Date_Time_GetLocalTime()
    Local $sText = _Date_Time_SystemTimeToTimeStr($tST)
    
    _DrawGlowingText($hDC, $sText, $tClientRect, 10)
    
    _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)
    
    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 _DrawGlowingText($hDC, $sText, $tRc, $iGlowSize)
    Local $hCDC
    Local $tRcText
    Local $tBI, $tDTO
    Local $hDIBBmp, $hOldBmp
    Local $tST
    
    $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)
    
    $tDTO = DllStructCreate($tagDTTOPTS)
    DllStructSetData($tDTO, "Size", DllStructGetSize($tDTO))
    DllStructSetData($tDTO, "Flags", BitOR($DTT_GLOWSIZE, $DTT_COMPOSITED))
    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)
    _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_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_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)
    Local $aResult = DllCall("uxtheme.dll", "hwnd", "OpenThemeData", "hwnd", $hWnd, "wstr", $sClassList)
    
    If @error Then Return SetError(@error, @extended, 0)
    If $aResult[0] = 0 Then Return SetError(1, 0, 0)
    Return SetError(0, 0, $aResult[0])
EndFunc

Func _WinAPI_CloseThemeData($hTheme)
    Local $aResult = DllCall("uxtheme.dll", "int", "CloseThemeData", "hwnd", $hTheme)
    
    If @error Then Return SetError(@error, @extended, 0)
    Return SetError(0, 0, $aResult[0] = 0)
EndFunc

Link to comment
Share on other sites

Wow...you should get those custom _WinAPI_ functions included in the next version of AutoIt!

One more thing...how can I make the text use the font "Segoe UI" in size 9?

Try Pacfox, my Firefox theme.Try Power Eject, my windows gadget that allows you to eject most drives.Using AutoIt 3.3.4.0, Windows 7 Premium, Intel Core 2 Quad CPU @ 2.66ghz, 4gb RAM, Nvidia GeForce 9500GT Graphics Card & Samsung 22" Monitor.
Link to comment
Share on other sites

#include <Date.au3>
#include <FontConstants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
Opt("MustDeclareVars", 1)

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)

If Not IsDeclared("WM_DWMCOMPOSITIonchangeD") Then Global Const $WM_DWMCOMPOSITIonchangeD = 0x031E
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 $hGUI = GUICreate("Test", 300, 300)
Global $hTheme = _WinAPI_OpenThemeData($hGUI, "globals")

GUIRegisterMsg($WM_ERASEBKGND, "_WM_ERASEBKGND")
GUIRegisterMsg($WM_DWMCOMPOSITIonchangeD, "_WM_DWMCOMPOSITIonchangeD")
GUISetState()

_SendMessage($hGUI, $WM_DWMCOMPOSITIonchangeD)
AdlibEnable("_DrawTime", 1000)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

_WinAPI_CloseThemeData($hTheme)
GUIDelete()
Exit


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(15, 5, 0, 0, 400, False, False, False, $DEFAULT_CHARSET, _
        $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Segoe UI') ; Edit as necessary.
    
    _DrawGlowingText($hDC, $sText, $tClientRect, 10, $hFont, 0xFF0000) ; BGR, implementing RGB is easy.
    
    _WinAPI_DeleteObject($hFont)
    _WinAPI_ReleaseDC($hGUI, $hDC)
EndFunc

Func _WM_ERASEBKGND($hWnd, $iMsg, $iwParam, $ilParam)
    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 _DrawGlowingText($hDC, $sText, $tRc, $iGlowSize = 10, $hFont = 0, $iTextClr = -1)
    Local $hCDC
    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_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_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)
    Local $aResult = DllCall("uxtheme.dll", "hwnd", "OpenThemeData", "hwnd", $hWnd, "wstr", $sClassList)
    
    If @error Then Return SetError(@error, @extended, 0)
    If $aResult[0] = 0 Then Return SetError(1, 0, 0)
    Return SetError(0, 0, $aResult[0])
EndFunc

Func _WinAPI_CloseThemeData($hTheme)
    Local $aResult = DllCall("uxtheme.dll", "int", "CloseThemeData", "hwnd", $hTheme)
    
    If @error Then Return SetError(@error, @extended, 0)
    Return SetError(0, 0, $aResult[0] = 0)
EndFunc

The DrawThemeTextEx is how the system does this it's own way. I think that it's more fun using GDIPlus.au3.

Link to comment
Share on other sites

With the DrawThemeTextEx method, which bit sets the position of the text? (I've had a look around but can't seem to figure it out :))

Try Pacfox, my Firefox theme.Try Power Eject, my windows gadget that allows you to eject most drives.Using AutoIt 3.3.4.0, Windows 7 Premium, Intel Core 2 Quad CPU @ 2.66ghz, 4gb RAM, Nvidia GeForce 9500GT Graphics Card & Samsung 22" Monitor.
Link to comment
Share on other sites

The seventh parameter, the rect struct. The flags are also changing the text's position within the rectangle, or to draw the string in a single line, or perhaps to break it into the next line to fit the rectangle dimensions. Read _WinAPI_DrawText for more information.

Edit: If you change the rectangle you should change the _WM_ERASEBKGND handler:

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)

    Return 1
EndFunc
Edited by Authenticity
Link to comment
Share on other sites

Maybe this will be useful for you.

#Include <FontConstants.au3>
#Include <WinAPI.au3>
#Include <WindowsConstants.au3>

$hForm = GUICreate('MyGUI', 400, 100)
GUISetState()

$hDC = _WinAPI_GetDC($hForm)
$hFont = _WinAPI_CreateFont(65, 0, 0, 0, $FW_NORMAL , 0, 0, 0, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $ANTIALIASED_QUALITY, BitOR($DEFAULT_PITCH, $FF_DONTCARE), 'Arial')
$hSv = _WinAPI_SelectObject($hDC, $hFont)
_WinAPI_DrawShadowText($hDC, 'Shadow Text', 0xF06000, 0xFFFFFF, 3, 3, 0, BitOR($DT_CENTER, $DT_SINGLELINE, $DT_VCENTER))
$hSv = _WinAPI_SelectObject($hDC, $hSv)
_WinAPI_ReleaseDC($hForm, $hDC)

Do
Until GUIGetMsg() = -3

; #FUNCTION# ====================================================================================================================
; Name...........: _WinAPI_DrawShadowText
; Description....: Draws formatted text in the specified rectangle with a drop shadow.
; Syntax.........: _WinAPI_DrawShadowText ( $hDC, $sText, $rgbText, $rgbShadow [, $iXOffset [, $iYOffset [, $tRECT [, $iFlags]]]] )
; Parameters.....: $hDC       - Handle to a device context.
;                  $sText     - The string that contains the text to be drawn.
;                  $rgbText   - The color of the text, in RGB.
;                  $rgbShadow - The color of the shadow, in RGB.
;                  $iXOffset  - The x-coordinate of where the text should begin.
;                  $iYOffset  - The y-coordinate of where the text should begin.
;                  $tRECT     - $tagRECT structure that contains, in logical coordinates, the rectangle in which the text is to
;                               be drawn. If this parameter is 0, the size will be equal size of the device context ($hDC).
;                  $iFlags    - The flags that specifies how the text is to be drawn. This parameter can be a combination of
;                               the formatting text constants ($DT_...).
; Return values..: Success    - 1.
;                  Failure    - 0 and sets the @error flag to non-zero.
; Author.........: Rover
; Modified.......: Yashied
; Remarks........: None
; Related........:
; Link...........: @@MsdnLink@@ DrawShadowText
; Example........: Yes
; ===============================================================================================================================

Func _WinAPI_DrawShadowText($hDC, $sText, $rgbText, $rgbShadow, $iXOffset = 0, $iYOffset = 0, $tRECT = 0, $iFlags = 0)

    Local $Ret

    If Not IsDllStruct($tRECT) Then
        $tRECT = DllStructCreate($tagRECT)
        $Ret = DllCall('user32.dll', 'int', 'GetClientRect', 'hwnd', _WinAPI_WindowFromDC($hDC), 'ptr', DllStructGetPtr($tRECT))
        If (@error) Or ($Ret[0] = 0) Then
            Return SetError(1, 0, 0)
        EndIf
    EndIf
    $Ret = DllCall('comctl32.dll', 'int', 'DrawShadowText', 'hwnd', $hDC, 'wstr', $sText, 'uint', -1, 'ptr', DllStructGetPtr($tRECT), 'dword', $iFlags, 'int', _WinAPI_SwitchColor($rgbText), 'int', _WinAPI_SwitchColor($rgbShadow), 'int', $iXOffset, 'int', $iYOffset)
    If (@error) Or ($Ret[0] = 0) Then
        Return SetError(1, 0, 0)
    EndIf
    Return 1
EndFunc   ;==>_WinAPI_DrawShadowText

Func _WinAPI_SwitchColor($iColor)
    Return BitOR(BitAND($iColor, 0x00FF00), BitShift(BitAND($iColor, 0x0000FF), -16), BitShift(BitAND($iColor, 0xFF0000), 16))
EndFunc   ;==>_WinAPI_SwitchColor

Func _WinAPI_WindowFromDC($hDC)

    Local $Ret = DllCall('user32.dll', 'hwnd', 'WindowFromDC', 'hwnd', $hDC)

    If @error Then
        Return SetError(1, 0, 0)
    EndIf
    Return $Ret[0]
EndFunc   ;==>_WinAPI_WindowFromDC
Link to comment
Share on other sites

#Include <FontConstants.au3>
#Include <WinAPI.au3>
#Include <WindowsConstants.au3>

$hForm = GUICreate('MyGUI', 800, 600)
GUISetState()

$hDC = _WinAPI_GetDC($hForm)
$hFont = _WinAPI_CreateFont(65, 0, 0, 0, $FW_NORMAL , 0, 0, 0, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $ANTIALIASED_QUALITY, BitOR($DEFAULT_PITCH, $FF_DONTCARE), 'Arial')
$hSv = _WinAPI_SelectObject($hDC, $hFont)
$tRect = DllStructCreate($tagRECT)
DllStructSetData($tRect, 1, 400)
DllStructSetData($tRect, 2, 500)
DllStructSetData($tRect, 3, 400 + 360)
DllStructSetData($tRect, 4, 500 + 60)
_WinAPI_DrawShadowText($hDC, 'Shadow Text', 0xF06000, 0xFFFFFF, 3, 3, $tRect, 0)
_WinAPI_SelectObject($hDC, $hSv)
_WinAPI_ReleaseDC($hForm, $hDC)

Do
Until GUIGetMsg() = -3

Func _WinAPI_DrawShadowText($hDC, $sText, $rgbText, $rgbShadow, $iXOffset = 0, $iYOffset = 0, $tRECT = 0, $iFlags = 0)

    Local $Ret

    If Not IsDllStruct($tRECT) Then
        $tRECT = DllStructCreate($tagRECT)
        $Ret = DllCall('user32.dll', 'int', 'GetClientRect', 'hwnd', _WinAPI_WindowFromDC($hDC), 'ptr', DllStructGetPtr($tRECT))
        If (@error) Or ($Ret[0] = 0) Then
            Return SetError(1, 0, 0)
        EndIf
    EndIf
    $Ret = DllCall('comctl32.dll', 'int', 'DrawShadowText', 'hwnd', $hDC, 'wstr', $sText, 'uint', -1, 'ptr', DllStructGetPtr($tRECT), 'dword', $iFlags, 'int', _WinAPI_SwitchColor($rgbText), 'int', _WinAPI_SwitchColor($rgbShadow), 'int', $iXOffset, 'int', $iYOffset)
    If (@error) Or ($Ret[0] = 0) Then
        Return SetError(1, 0, 0)
    EndIf
    Return 1
EndFunc   ;==>_WinAPI_DrawShadowText

Func _WinAPI_SwitchColor($iColor)
    Return BitOR(BitAND($iColor, 0x00FF00), BitShift(BitAND($iColor, 0x0000FF), -16), BitShift(BitAND($iColor, 0xFF0000), 16))
EndFunc   ;==>_WinAPI_SwitchColor

Func _WinAPI_WindowFromDC($hDC)

    Local $Ret = DllCall('user32.dll', 'hwnd', 'WindowFromDC', 'hwnd', $hDC)

    If @error Then
        Return SetError(1, 0, 0)
    EndIf
    Return $Ret[0]
EndFunc   ;==>_WinAPI_WindowFromDC

Edited by Yashied
Link to comment
Share on other sites

This is better.

#Include <Constants.au3>
#Include <FontConstants.au3>
#Include <GUIConstantsEx.au3>
#Include <WinAPIEx.au3>
#Include <WindowsConstants.au3>

$hForm = GUICreate('MyGUI', 800, 600)

$Label = GUICtrlCreateLabel('', 400, 500, 400 + 360, 500 + 60)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$hLabel = GUICtrlGetHandle($Label)

$hDll = DllCallbackRegister('_WinProc', 'ptr', 'hwnd;uint;wparam;lparam')
$pDll = DllCallbackGetPtr($hDll)
$hProc = _WinAPI_SetWindowLong($hLabel, $GWL_WNDPROC, $pDll)

GUISetState()

Do
Until GUIGetMsg() = -3

_WinAPI_SetWindowLong($hLabel, $GWL_WNDPROC, $hProc)
DllCallbackFree($hDll)

Func _WinProc($hWnd, $iMsg, $wParam, $lParam)
    Switch $iMsg
        Case $WM_PAINT

            Local $hDC, $hSv, $hFont, $tPAINTSTRUCT

            $hDC = _WinAPI_BeginPaint($hWnd, $tPAINTSTRUCT)
            $hFont = _WinAPI_CreateFont(65, 0, 0, 0, $FW_NORMAL , 0, 0, 0, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $ANTIALIASED_QUALITY, BitOR($DEFAULT_PITCH, $FF_DONTCARE), 'Arial')
            $hSv = _WinAPI_SelectObject($hDC, $hFont)
            _WinAPI_DrawShadowText($hDC, 'Shadow Text', 0xF06000, 0xFFFFFF, 3, 3, 0, 0)
            _WinAPI_SelectObject($hDC, $hSv)
            _WinAPI_EndPaint($hWnd, $tPAINTSTRUCT)
            Return 0
    EndSwitch
    Return _WinAPI_CallWindowProc($hProc, $hWnd, $iMsg, $wParam, $lParam)
EndFunc   ;==>_WinProc

WinAPIEx.au3

Edited by Yashied
Link to comment
Share on other sites

Oh whoops, forgot to say I meant that for the DrawThemeTextEx method...thanks anyway 'cause that will be useful for another project I'm working on!

Try Pacfox, my Firefox theme.Try Power Eject, my windows gadget that allows you to eject most drives.Using AutoIt 3.3.4.0, Windows 7 Premium, Intel Core 2 Quad CPU @ 2.66ghz, 4gb RAM, Nvidia GeForce 9500GT Graphics Card & Samsung 22" Monitor.
Link to comment
Share on other sites

Hey there,

Is there also a posibility to draw e.g. Inputs (GuiCtrlCreateInput) on Aero? So that black is not transparency? (I think we just have to set the Alpha Channel to 255 (0xFF000000).)

Any Ideas?

This wont work:

#include <Date.au3>
#include <FontConstants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
Opt("MustDeclareVars", 1)

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)

If Not IsDeclared("WM_DWMCOMPOSITIonchangeD") Then Global Const $WM_DWMCOMPOSITIonchangeD = 0x031E
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 $hGUI = GUICreate("Test", 300, 300)
Global $hTheme = _WinAPI_OpenThemeData($hGUI, "globals")

GUICtrlCreateInput("Hello World",0,0,200,20);Wont work

GUIRegisterMsg($WM_ERASEBKGND, "_WM_ERASEBKGND")
GUIRegisterMsg($WM_DWMCOMPOSITIonchangeD, "_WM_DWMCOMPOSITIonchangeD")
GUISetState()
_DrawTime()
_SendMessage($hGUI, $WM_DWMCOMPOSITIonchangeD)
AdlibEnable("_DrawTime", 1000)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

_WinAPI_CloseThemeData($hTheme)
GUIDelete()
Exit


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.

    _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)
    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 _DrawGlowingText($hDC, $sText, $tRc, $iGlowSize = 10, $hFont = 0, $iTextClr = -1)
    Local $hCDC
    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_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_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)
    Local $aResult = DllCall("uxtheme.dll", "hwnd", "OpenThemeData", "hwnd", $hWnd, "wstr", $sClassList)

    If @error Then Return SetError(@error, @extended, 0)
    If $aResult[0] = 0 Then Return SetError(1, 0, 0)
    Return SetError(0, 0, $aResult[0])
EndFunc

Func _WinAPI_CloseThemeData($hTheme)
    Local $aResult = DllCall("uxtheme.dll", "int", "CloseThemeData", "hwnd", $hTheme)

    If @error Then Return SetError(@error, @extended, 0)
    Return SetError(0, 0, $aResult[0] = 0)
EndFunc

Greetings,

Spider

www.AutoIt.de - Moderator of the German AutoIt Forum

 

Link to comment
Share on other sites

This code is from this 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. ::

Link to comment
Share on other sites

Hey Authenticity, would you be able to make the _DrawGlowingText function of the DrawThemeTextEx method able to take the text position in the function like this?

_DrawGlowingText($hDC, 'Test', $tClientRect, 10, $top, $left, $hFont, 0x000000)

Where $top represents the pixels the text is positioned from the top, and $left represents the pixels the text is positioned from the left.

Try Pacfox, my Firefox theme.Try Power Eject, my windows gadget that allows you to eject most drives.Using AutoIt 3.3.4.0, Windows 7 Premium, Intel Core 2 Quad CPU @ 2.66ghz, 4gb RAM, Nvidia GeForce 9500GT Graphics Card & Samsung 22" Monitor.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...