Sign in to follow this  
Followers 0
nend

Does anybody know what's changed

4 posts in this topic

 
Hello,
 
I've got a very large program and when I update from Autoit 3.3.8.1 to the latest public one function doesn't work corectly.
In autoit 3.3.8.1 it produce a glowing text whitout any background, in the latest version of autoit it only shows a white bar
This piece of code that doesn't work anymore and shows a white bar.
 
This Piece of code I found a long time a go and don't know whom it's from.
I don't have a clue how this code work.
Is there anybody how knows what is changed and how I can solve this?
 
#include <WinAPI.au3>
#include <WindowsConstants.au3>


$Gui = GUICreate("ROtext", 200, 20, 400, @DesktopHeight - 30, $WS_POPUP, $WS_EX_TOOLWINDOW)
$hTheme = DllCall("uxtheme.dll", "hwnd", "OpenThemeData", "hwnd", $Gui, "wstr", "globals")
GUISetState(@SW_SHOWNA, $Gui)

_DrawGlowingText("This is a test", $Gui, 15)
WinSetOnTop($GUI, "", 1)


While 1
    Sleep(2000)
WEnd

Func _DrawGlowingText($sText, $Gui, $iGlowSize)
    Local $hCDC, $tBI, $tDTO, $hOldBmp, $hCDC, $tMargs

    $tRc = _WinAPI_GetClientRect($Gui)
    $hDC = _WinAPI_GetDC($Gui)
    $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)

    $aResult = DllCall("gdi32.dll", "hwnd", "CreateDIBSection", "hwnd", $hDC, "ptr", DllStructGetPtr($tBI), "uint", 0, "ptr", 0, "hwnd", 0, "uint", 0)
    $hOldBmp = _WinAPI_SelectObject($hCDC, $aResult[0])

    $tDTO = DllStructCreate("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;")
    DllStructSetData($tDTO, "Size", DllStructGetSize($tDTO))
    DllStructSetData($tDTO, "Flags", BitOR(0x00000800, 0x00002000))
    DllStructSetData($tDTO, "GlowSize", $iGlowSize)

    DllCall("uxtheme.dll", "int", "DrawThemeTextEx", "ptr", $hTheme[0], "hwnd", $hCDC, "int", 0, "int", 0, "wstr", $sText, "int", -1, "uint", BitOR($DT_SINGLELINE, 1, $DT_VCENTER, $DT_NOPREFIX), "ptr", DllStructGetPtr($tRc), "ptr", DllStructGetPtr($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)

    $tMargs = DllStructCreate($tagMARGINS)
    DllStructSetData($tMargs, 1, -1)
    DllStructSetData($tMargs, 2, -1)
    DllStructSetData($tMargs, 3, -1)
    DllStructSetData($tMargs, 4, -1)
    DllCall("dwmapi.dll", "int", "DwmExtendFrameIntoClientArea", "hwnd", $Gui, "ptr", DllStructGetPtr($tMargs))

    _WinAPI_DeleteObject($aResult[0])
    _WinAPI_DeleteDC($hCDC)
    _WinAPI_ReleaseDC($Gui, $hDC)
EndFunc   ;==>_DrawGlowingText

 

Share this post


Link to post
Share on other sites



See if this works:

#AutoIt3Wrapper_AU3Check_Parameters=-w 1 -w 2 -w 3 -w 4 -w 6 -w 7 -d

#include <WinAPI.au3>

#include <WindowsConstants.au3>

#include <WinAPITheme.au3>

#include <WinAPIGdi.au3>

Global Const $Gui = GUICreate("ROtext", 200, 20, 400, @DesktopHeight - 30, $WS_POPUP, $WS_EX_TOOLWINDOW)

Global Const $hTheme = _WinAPI_OpenThemeData($Gui, "globals")

GUISetState(@SW_SHOWNA, $Gui)

_DrawGlowingText("This is a test", $Gui, 15)

WinSetOnTop($GUI, "", 1)

While 1
    Sleep(2000)
WEnd

Func _DrawGlowingText(Const $sText, Const $Gui, Const $iGlowSize)
    Local Const $tRc = _WinAPI_GetClientRect($Gui)
    Local Const $hDC = _WinAPI_GetDC($Gui)
    Local Const $hCDC = _WinAPI_CreateCompatibleDC($hDC)

    Local Const $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)
    
    Local Const $aResult = DllCall("gdi32.dll", "hwnd", "CreateDIBSection", "hwnd", $hDC, "ptr", DllStructGetPtr($tBI), "uint", 0, "ptr", 0, "hwnd", 0, "uint", 0)
    
    Local Const $hOldBmp = _WinAPI_SelectObject($hCDC, $aResult[0])

    Local Const $tDTO = DllStructCreate($tagDTTOPTS)
    DllStructSetData($tDTO, "Size", DllStructGetSize($tDTO))
    DllStructSetData($tDTO, "Flags", BitOR(0x00000800, 0x00002000))
    DllStructSetData($tDTO, "GlowSize", $iGlowSize)
    
    _WinAPI_DrawThemeTextEx($hTheme, 0, 0, $hDC, $sText, DllStructGetPtr($tRc), BitOR($DT_SINGLELINE, 1, $DT_VCENTER, $DT_NOPREFIX), DllStructGetPtr($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)

    Local Const $tMargs = DllStructCreate($tagMARGINS)
    DllStructSetData($tMargs, 1, -1)
    DllStructSetData($tMargs, 2, -1)
    DllStructSetData($tMargs, 3, -1)
    DllStructSetData($tMargs, 4, -1)
    
    _WinAPI_DwmExtendFrameIntoClientArea($Gui, DllStructGetPtr($tMargs))

    _WinAPI_DeleteObject($aResult[0])
    _WinAPI_DeleteDC($hCDC)
    _WinAPI_ReleaseDC($Gui, $hDC)
EndFunc   ;==>_DrawGlowingText

Share this post


Link to post
Share on other sites

Hoi jaberwacky,

Thanks for looking at it.

It still produce a white bar but now with the text on it.

In windows 7 it looks like this Knipsel2.jpg in autoit 3.3.8.1.

In windows 8 it looks like black text with a transparant background.

This is wat your code produce Knipsel1.jpg

Share this post


Link to post
Share on other sites

I'v found this in the help file "_WinAPI_DrawThemeTextEx" with this example.

I change a few things so it wil be text with a 100% transparent background(I set these option Guictrlcreate , $WS_POPUP, $WS_EX_TOOLWINDOW) I can use this for my program but.... how can I change the text realtime?

I can set the text in the code but when I start the code I can changed it anymore.

Anyone a idea?

#include <FontConstants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPIGdi.au3>
#include <WinAPITheme.au3>
#include <WindowsConstants.au3>

If Not _WinAPI_DwmIsCompositionEnabled() Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later with enabled Aero theme.')
    Exit
EndIf

OnAutoItExitRegister('OnAutoItExit')

; Create GUI
Local $hForm = GUICreate('Test', 240, 240, 900, 884, $WS_POPUP, $WS_EX_TOOLWINDOW)

GUICtrlCreateLabel('', 20, 130, 190, 30)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetState(-1, $GUI_DISABLE)
Global $g_hLabel = GUICtrlGetHandle(-1)
GUISetBkColor(0)

; Register label window proc
Global $g_hDll = DllCallbackRegister('_WinProc', 'ptr', 'hwnd;uint;wparam;lparam')
Local $pDll = DllCallbackGetPtr($g_hDll)
Global $g_hProc = _WinAPI_SetWindowLong($g_hLabel, $GWL_WNDPROC, $pDll)

_WinAPI_DwmExtendFrameIntoClientArea($hForm)

GUISetState(@SW_SHOW)

Do
    WinSetOnTop($hForm, "", 1)
    Sleep(1000)
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func _DrawText($hDC, $sText, $tRECT)
    ; Original idea by Authenticity
    Local $iWidth = DllStructGetData($tRECT, 3) - DllStructGetData($tRECT, 1)
    Local $iHeight = DllStructGetData($tRECT, 4) - DllStructGetData($tRECT, 2)

    Local $tDTTOPTS = DllStructCreate($tagDTTOPTS)
    DllStructSetData($tDTTOPTS, 'Size', DllStructGetSize($tDTTOPTS))
    DllStructSetData($tDTTOPTS, 'Flags', BitOR($DTT_TEXTCOLOR, $DTT_GLOWSIZE, $DTT_COMPOSITED))
    DllStructSetData($tDTTOPTS, 'clrText', 0x00C0)
    DllStructSetData($tDTTOPTS, 'GlowSize', 12)

    Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC)
    Local $hBitmap = _WinAPI_CreateDIB($iWidth, -$iHeight)
    Local $hSv1 = _WinAPI_SelectObject($hMemDC, $hBitmap)
    Local $hFont = _WinAPI_CreateFont(26, 0, 0, 0, 700, 0, 0, 0, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, $DEFAULT_PITCH, 'Segoe Script')
    Local $hSv2 = _WinAPI_SelectObject($hMemDC, $hFont)
    $tRECT = _WinAPI_CreateRect(0, 0, $iWidth, $iHeight)
    Local $hTheme = _WinAPI_OpenThemeData($hForm, 'Globals')

    _WinAPI_DrawThemeTextEx($hTheme, 0, 0, $hMemDC, $sText, $tRECT, BitOR($DT_CENTER, $DT_SINGLELINE, $DT_VCENTER), $tDTTOPTS)
    _WinAPI_BitBlt($hDC, 0, 0, $iWidth, $iHeight, $hMemDC, 0, 0, $SRCCOPY)

    _WinAPI_CloseThemeData($hTheme)
    _WinAPI_SelectObject($hMemDC, $hSv1)
    _WinAPI_DeleteObject($hBitmap)
    _WinAPI_SelectObject($hMemDC, $hSv2)
    _WinAPI_DeleteObject($hFont)
    _WinAPI_DeleteDC($hMemDC)
EndFunc   ;==>_DrawText

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

            Local $hDC = _WinAPI_BeginPaint($hWnd, $tPAINTSTRUCT)
            _DrawText($hDC, "this is a test", _WinAPI_GetClientRect($hWnd))
            _WinAPI_EndPaint($hWnd, $tPAINTSTRUCT)
            Return 0
    EndSwitch
    Return _WinAPI_CallWindowProc($g_hProc, $hWnd, $iMsg, $wParam, $lParam)
EndFunc   ;==>_WinProc

Func OnAutoItExit()
    _WinAPI_SetWindowLong($g_hLabel, $GWL_WNDPROC, $g_hProc)
    DllCallbackFree($g_hDll)
EndFunc   ;==>OnAutoItExit

Share this post


Link to post
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
Sign in to follow this  
Followers 0