Jump to content

Problem with flashing Label (Solved)


Belini
 Share

Recommended Posts

I need to show a label on a PC but the label flashes when it is updated, I can upgrade without blinking using $WS_EX_COMPOSITED without pic below but put the PIC the label does not appear, does anyone know how to solve?

EXAMPLE:

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

gui_1(); ;If I do not use the $ WS_EX_COMPOSITED flashes the label.
gui_2(); If I use the $ WS_EX_COMPOSITED without PIC under the label does not blink.
gui_3(); If I use the $ WS_EX_COMPOSITED and put pic below does not show the label.

Func gui_1()
    Local $Form1 = GUICreate("Form1", 194, 137, 414, 452)
    Local $pic = GUICtrlCreatePic(_background(True), 0, 0, 194, 137)
    Local $Label1 = GUICtrlCreateLabel("100", 0, 0, 194, 137, $SS_CENTER + $SS_CENTERIMAGE)
    GUICtrlSetColor(-1, 0xffffff)
    GUICtrlSetBkColor(-1, 0x000000)
    GUICtrlSetFont(-1, 70, 800, 0, "Arial Black")
    GUISetState(@SW_SHOW)
    For $i = 100 To 200
        Sleep(20)
        GUICtrlSetData($Label1, $i)
    Next
EndFunc   ;==>gui_1

Func gui_2()
    Local $Form1 = GUICreate("Form1", 194, 137, 414, 452, Default, $WS_EX_COMPOSITED)
    Local $Label1 = GUICtrlCreateLabel("100", 0, 0, 194, 137, $SS_CENTER + $SS_CENTERIMAGE)
    GUICtrlSetColor(-1, 0xffffff)
    GUICtrlSetBkColor(-1, 0x000000)
    GUICtrlSetFont(-1, 70, 800, 0, "Arial Black")
    GUISetState(@SW_SHOW)
    For $i = 200 To 300
        Sleep(20)
        GUICtrlSetData($Label1, $i)
    Next
    GUIDelete()
EndFunc   ;==>gui_2

Func gui_3()
    Local $Form1 = GUICreate("Form1", 194, 137, 414, 452, Default, $WS_EX_COMPOSITED)
    Local $pic = GUICtrlCreatePic(_background(True), 0, 0, 194, 137)
    Local $Label1 = GUICtrlCreateLabel("100", 0, 0, 194, 137, $SS_CENTER + $SS_CENTERIMAGE)
    GUICtrlSetColor(-1, 0xffffff)
    GUICtrlSetBkColor(-1, 0x000000)
    GUICtrlSetFont(-1, 70, 800, 0, "Arial Black")
    GUISetState(@SW_SHOW)
    For $i = 300 To 400
        Sleep(20)
        GUICtrlSetData($Label1, $i)
    Next
    Exit
EndFunc   ;==>gui_3

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

; #INDEX# =======================================================================================================================
; Title .........: _background()
; AutoIt Version.: 3.3.8.1
; Language.......: Português (Brasil) - 0416(PTB)
; Description ...: Compressed file embedded
; Author ........: BELINI
; ===============================================================================================================================

; #CURRENT# =====================================================================================================================
; _background()
; ===============================================================================================================================

; #INTERNAL_USE_ONLY# ===========================================================================================================
; __background() ; _LZNTDecompress renamed!
; __backgroundB64() ; _Base64 renamed!
; ===============================================================================================================================

; #VARIABLES# ===================================================================================================================
; ===============================================================================================================================

; #FUNCTION# ====================================================================================================================
; Name ..........: _background()
; Description ...: Compressed file embedded in your .au3 file
; Syntax ........: _background( [ lToSave [, sPath [, lExecute ]]] )
; Parameters ....: lToSave             - [optional] If True, save the file, else, return binary data. Default is False.
;                  sPath               - [optional] The path of the file to be save. Default is @TempDir
;                  lExecute            - [optional] Flag to execute file saved. Default is False
; Return values .: Success             - Returns decompressed fundo.bmp binary data or saved.
;                    Failure             - Returns 0 and set @error to 1.
; Author(s) .....: João Carlos (Jscript FROM Brazil)
; Modified ......:
; Remarks .......: This function uses _LZNTDecompress() and _Base64Decode() by trancexx.
; Related .......:
; Link ..........:
; Example .......; _background()
; ===============================================================================================================================
Func _background($lToSave = False, $sPath = @TempDir, $lExecute = False)
    Local $hFileHwnd, $bData, $sFileName = $sPath & "\fundo.bmp"

    ; Original: D:\JukeBel\00 Arquivos úteis\fundo.bmp
    $bData = "LrGgQk0cDQACADYAUIooADAhBBgBABgASAAAAOYMAAASC8cDDAJAAhD/AABdCF5g/wDA/2Nncf9KXxD/GP8Yf7b/QMinVXYK/0r/Sn8lfww/BP9fJP0Qfwx/DH8MPQR/DH8M/38Mfx37EP8H/xj/GP8Y/xD//xg/Ff8Q+RB/FD8QPRB/DP9/DH8MHwIfAR8BHwEfARUB/38MHwEfAR8BHwEXAb8BHwH/HwEfAR8BFwG/AR8BHwEfAf8fARcBvwEfAR8BHwEfARcB/78BHwEfAR8BHwEXAb8BHwH/HwEfAR8BFwG/AR8BHwEfAf8fARcBvwEfAR8BHwEfARcB/78BHwEfAR8BHwEXAb8BHwH/HwEfAR8BFwG/AR8BHwEfAf8fARcBvwEfAR8BHwEfARcBAAA="

    If $lToSave Then
        $hFileHwnd = FileOpen($sFileName, 10)
        If @error Then Return SetError(1, 0, 0)
        FileWrite($hFileHwnd, __background(__backgroundB64($bData)))
        FileClose($hFileHwnd)
        If $lExecute Then
            RunWait($sFileName, "")
            FileDelete($sFileName)
            Return 1
        EndIf
        If FileExists($sFileName) Then Return $sFileName
    Else
        Return __background(__backgroundB64($bData))
    EndIf

    Return SetError(1, 0, 0)
EndFunc   ;==>_background

; #INTERNAL_USE_ONLY# ===========================================================================================================
; Name...........: __backgroundB64
; Description ...: Base64 decode input data.
; Syntax.........: __backgroundB64($bBinary)
; Parameters ....: $sInput - String data to decode
; Return values .: Success - Returns decode binary data.
;                          - Sets @error to 0
;                  Failure - Returns empty string and sets @error:
;                  |1 - Error calculating the length of the buffer needed.
;                  |2 - Error decoding.
; Author ........: trancexx
; Modified ......: João Carlos (Jscript FROM Brazil)
; Related .......: _Base64Encode()
; ===============================================================================================================================
Func __backgroundB64($sInput)
    Local $struct = DllStructCreate("int")
    Local $a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", _
            "str", $sInput, _
            "int", 0, _
            "int", 1, _
            "ptr", 0, _
            "ptr", DllStructGetPtr($struct, 1), _
            "ptr", 0, _
            "ptr", 0)
    If @error Or Not $a_Call[0] Then
        Return SetError(1, 0, "") ; error calculating the length of the buffer needed
    EndIf
    Local $a = DllStructCreate("byte[" & DllStructGetData($struct, 1) & "]")
    $a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", _
            "str", $sInput, _
            "int", 0, _
            "int", 1, _
            "ptr", DllStructGetPtr($a), _
            "ptr", DllStructGetPtr($struct, 1), _
            "ptr", 0, _
            "ptr", 0)
    If @error Or Not $a_Call[0] Then
        Return SetError(2, 0, ""); error decoding
    EndIf
    Return DllStructGetData($a, 1)
EndFunc   ;==>__backgroundB64

; #INTERNAL_USE_ONLY# ===========================================================================================================
; Name...........: __background
; Original Name..: _LZNTDecompress
; Description ...: Decompresses input data.
; Syntax.........: __background($bBinary)
; Parameters ....: $vInput - Binary data to decompress.
; Return values .: Success - Returns decompressed binary data.
;                          - Sets @error to 0
;                  Failure - Returns empty string and sets @error:
;                  |1 - Error decompressing.
; Author ........: trancexx
; Related .......: _LZNTCompress
; Link ..........; http://msdn.microsoft.com/en-us/library/bb981784.aspx
; ===============================================================================================================================
Func __background($bBinary)
    $bBinary = Binary($bBinary)
    Local $tInput = DllStructCreate("byte[" & BinaryLen($bBinary) & "]")
    DllStructSetData($tInput, 1, $bBinary)
    Local $tBuffer = DllStructCreate("byte[" & 16 * DllStructGetSize($tInput) & "]") ; initially oversizing buffer
    Local $a_Call = DllCall("ntdll.dll", "int", "RtlDecompressBuffer", _
            "ushort", 2, _
            "ptr", DllStructGetPtr($tBuffer), _
            "dword", DllStructGetSize($tBuffer), _
            "ptr", DllStructGetPtr($tInput), _
            "dword", DllStructGetSize($tInput), _
            "dword*", 0)

    If @error Or $a_Call[0] Then
        Return SetError(1, 0, "") ; error decompressing
    EndIf

    Local $tOutput = DllStructCreate("byte[" & $a_Call[6] & "]", DllStructGetPtr($tBuffer))

    Return SetError(0, 0, DllStructGetData($tOutput, 1))
EndFunc   ;==>__background

 

Edited by Belini
Link to comment
Share on other sites

Use GDI+ to draw the string and copy the bitmap to the pic control. There are several examples flying around.

 

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

I did as you said and it worked but as I have little knowledge about GDI can not tell if it was the best solution, please see if what I did is correct.

#include <GUIConstantsEx.au3>
#include <GDIPlus.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

gui()

Func gui()
    Local $hGUI, $hGraphic

    Local $hGUI = GUICreate("Form", 194, 137, -1, -1, Default, $WS_EX_COMPOSITED)

    _GDIPlus_Startup()

    $hBitmap = _GDIPlus_BitmapCreateFromFile(_background(True))
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsDrawImage($hGraphic, $hBitmap, 0, 0)

    Local $Label1 = GUICtrlCreateLabel("100", 0, 0, 194, 137, $SS_CENTER + $SS_CENTERIMAGE)
    GUICtrlSetColor(-1, 0xffffff)
    GUICtrlSetBkColor(-1, 0x000000)
    GUICtrlSetFont(-1, 70, 800, 0, "Arial Black")
    GUISetState(@SW_SHOW)
    For $i = 100 To 200
        Sleep(20)
        GUICtrlSetData($Label1, $i)
    Next
    ; Clean up resources
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_BitmapDispose($hBitmap)

    ; Shut down GDI+ library
    _GDIPlus_Shutdown()
    Exit
EndFunc   ;==>gui_3

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

; #INDEX# =======================================================================================================================
; Title .........: _background()
; AutoIt Version.: 3.3.8.1
; Language.......: Português (Brasil) - 0416(PTB)
; Description ...: Compressed file embedded
; Author ........: BELINI
; ===============================================================================================================================

; #CURRENT# =====================================================================================================================
; _background()
; ===============================================================================================================================

; #INTERNAL_USE_ONLY# ===========================================================================================================
; __background() ; _LZNTDecompress renamed!
; __backgroundB64() ; _Base64 renamed!
; ===============================================================================================================================

; #VARIABLES# ===================================================================================================================
; ===============================================================================================================================

; #FUNCTION# ====================================================================================================================
; Name ..........: _background()
; Description ...: Compressed file embedded in your .au3 file
; Syntax ........: _background( [ lToSave [, sPath [, lExecute ]]] )
; Parameters ....: lToSave             - [optional] If True, save the file, else, return binary data. Default is False.
;                  sPath               - [optional] The path of the file to be save. Default is @TempDir
;                  lExecute            - [optional] Flag to execute file saved. Default is False
; Return values .: Success             - Returns decompressed fundo.bmp binary data or saved.
;                    Failure             - Returns 0 and set @error to 1.
; Author(s) .....: João Carlos (Jscript FROM Brazil)
; Modified ......:
; Remarks .......: This function uses _LZNTDecompress() and _Base64Decode() by trancexx.
; Related .......:
; Link ..........:
; Example .......; _background()
; ===============================================================================================================================
Func _background($lToSave = False, $sPath = @TempDir, $lExecute = False)
    Local $hFileHwnd, $bData, $sFileName = $sPath & "\fundo.bmp"

    ; Original: D:\JukeBel\00 Arquivos úteis\fundo.bmp
    $bData = "LrGgQk0cDQACADYAUIooADAhBBgBABgASAAAAOYMAAASC8cDDAJAAhD/AABdCF5g/wDA/2Nncf9KXxD/GP8Yf7b/QMinVXYK/0r/Sn8lfww/BP9fJP0Qfwx/DH8MPQR/DH8M/38Mfx37EP8H/xj/GP8Y/xD//xg/Ff8Q+RB/FD8QPRB/DP9/DH8MHwIfAR8BHwEfARUB/38MHwEfAR8BHwEXAb8BHwH/HwEfAR8BFwG/AR8BHwEfAf8fARcBvwEfAR8BHwEfARcB/78BHwEfAR8BHwEXAb8BHwH/HwEfAR8BFwG/AR8BHwEfAf8fARcBvwEfAR8BHwEfARcB/78BHwEfAR8BHwEXAb8BHwH/HwEfAR8BFwG/AR8BHwEfAf8fARcBvwEfAR8BHwEfARcBAAA="

    If $lToSave Then
        $hFileHwnd = FileOpen($sFileName, 10)
        If @error Then Return SetError(1, 0, 0)
        FileWrite($hFileHwnd, __background(__backgroundB64($bData)))
        FileClose($hFileHwnd)
        If $lExecute Then
            RunWait($sFileName, "")
            FileDelete($sFileName)
            Return 1
        EndIf
        If FileExists($sFileName) Then Return $sFileName
    Else
        Return __background(__backgroundB64($bData))
    EndIf

    Return SetError(1, 0, 0)
EndFunc   ;==>_background

; #INTERNAL_USE_ONLY# ===========================================================================================================
; Name...........: __backgroundB64
; Description ...: Base64 decode input data.
; Syntax.........: __backgroundB64($bBinary)
; Parameters ....: $sInput - String data to decode
; Return values .: Success - Returns decode binary data.
;                          - Sets @error to 0
;                  Failure - Returns empty string and sets @error:
;                  |1 - Error calculating the length of the buffer needed.
;                  |2 - Error decoding.
; Author ........: trancexx
; Modified ......: João Carlos (Jscript FROM Brazil)
; Related .......: _Base64Encode()
; ===============================================================================================================================
Func __backgroundB64($sInput)
    Local $struct = DllStructCreate("int")
    Local $a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", _
            "str", $sInput, _
            "int", 0, _
            "int", 1, _
            "ptr", 0, _
            "ptr", DllStructGetPtr($struct, 1), _
            "ptr", 0, _
            "ptr", 0)
    If @error Or Not $a_Call[0] Then
        Return SetError(1, 0, "") ; error calculating the length of the buffer needed
    EndIf
    Local $a = DllStructCreate("byte[" & DllStructGetData($struct, 1) & "]")
    $a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", _
            "str", $sInput, _
            "int", 0, _
            "int", 1, _
            "ptr", DllStructGetPtr($a), _
            "ptr", DllStructGetPtr($struct, 1), _
            "ptr", 0, _
            "ptr", 0)
    If @error Or Not $a_Call[0] Then
        Return SetError(2, 0, ""); error decoding
    EndIf
    Return DllStructGetData($a, 1)
EndFunc   ;==>__backgroundB64

; #INTERNAL_USE_ONLY# ===========================================================================================================
; Name...........: __background
; Original Name..: _LZNTDecompress
; Description ...: Decompresses input data.
; Syntax.........: __background($bBinary)
; Parameters ....: $vInput - Binary data to decompress.
; Return values .: Success - Returns decompressed binary data.
;                          - Sets @error to 0
;                  Failure - Returns empty string and sets @error:
;                  |1 - Error decompressing.
; Author ........: trancexx
; Related .......: _LZNTCompress
; Link ..........; http://msdn.microsoft.com/en-us/library/bb981784.aspx
; ===============================================================================================================================
Func __background($bBinary)
    $bBinary = Binary($bBinary)
    Local $tInput = DllStructCreate("byte[" & BinaryLen($bBinary) & "]")
    DllStructSetData($tInput, 1, $bBinary)
    Local $tBuffer = DllStructCreate("byte[" & 16 * DllStructGetSize($tInput) & "]") ; initially oversizing buffer
    Local $a_Call = DllCall("ntdll.dll", "int", "RtlDecompressBuffer", _
            "ushort", 2, _
            "ptr", DllStructGetPtr($tBuffer), _
            "dword", DllStructGetSize($tBuffer), _
            "ptr", DllStructGetPtr($tInput), _
            "dword", DllStructGetSize($tInput), _
            "dword*", 0)

    If @error Or $a_Call[0] Then
        Return SetError(1, 0, "") ; error decompressing
    EndIf

    Local $tOutput = DllStructCreate("byte[" & $a_Call[6] & "]", DllStructGetPtr($tBuffer))

    Return SetError(0, 0, DllStructGetData($tOutput, 1))
EndFunc   ;==>__background

EDITED: There were other problems, the image is huge in the script that I want to use and do not know how to resize and also can not delete the image after it is created!

Edited by Belini
Link to comment
Share on other sites

This is not exactly what I meant. I found an old script which I wrote:

#include <ScreenCapture.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <GUIConstantsEx.au3>

_GDIPlus_Startup()
Global $iCtrlX = 10, $iCtrlY = 70, $iCtrlW = 250, $iCtrlH = 20
$hGUI = GUICreate("Test", 450, 100);, -1, -1, Default, BitOR($WS_EX_COMPOSITED, $WS_EX_TOPMOST, $WS_EX_LAYERED))
$iPic_bg = GUICtrlCreatePic("", 0, 0, 450, 100)
GUICtrlSetState(-1, $GUI_DISABLE)
$iLabel = GUICtrlCreateLabel("Standard Control: 0000000000", 10, 10, $iCtrlW, $iCtrlH)
GUICtrlSetFont(-1, 11, 400, 0, "Arial")
$iPic = GUICtrlCreatePic("", $iCtrlX, $iCtrlY, $iCtrlW, $iCtrlH)
GUICtrlSetState(-1, $GUI_DISABLE)
$hBG_Image = _ScreenCapture_Capture("", 0, @DesktopHeight - 100, 450, @DesktopHeight)
$hB = GUICtrlSendMsg($iPic_bg, 0x0172, 0, $hBG_Image)
If $hB Then _WinAPI_DeleteObject($hB)
GUISetState()

$hImage = _GDIPlus_BitmapCreateFromHBITMAP ($hBG_Image)
_WinAPI_DeleteObject($hBG_Image)
$hImgBg_Rect = _GDIPlus_CropImage($hImage, $iCtrlX, $iCtrlY, $iCtrlW, $iCtrlH)

Do
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            GUIDelete()
            _GDIPlus_BitmapDispose($hImgBg_Rect)
            _GDIPlus_Shutdown()
            Exit
    EndSwitch
    GUICtrlSetData($iLabel, "Standard Control: " & Random(1111111111, 99999999999, 1)) ;standard control is flickering
    _GDIPlus_DrwTxt2Ctrl($hGUI, $iPic, "Graphic Control: " & Random(1111111111, 99999999999, 1), $hImgBg_Rect, 11, "Arial", 0xFFF0F080, 0xFFF0F0F0, 1) ;workaround using GDI+
Until False

Func _GDIPlus_DrwTxt2Ctrl($hWnd, $iCtrl, $sText, $hBgImage = 0, $iFontSize = 11, $sFont = "Arial", $iFontColor = 0xFF000000, $iBgColor = 0xFFF0F0F0, $iAlign = 0, $bAntiAlias = False) ;coded by UEZ build 2013-01-17
    Local $hCtrl = GUICtrlGetHandle($iCtrl)
    Local $aSize = ControlGetPos($hWnd, "", $iCtrl)
    Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($aSize[2], $aSize[3])
    Local $hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    If $hBgImage Then
        _GDIPlus_GraphicsDrawImage($hCtxt, $hBgImage, 0, 0)
    Else
        _GDIPlus_GraphicsClear($hCtxt, $iBgColor)
    EndIf
    If $bAntiAlias Then
        _GDIPlus_GraphicsSetSmoothingMode($hCtxt, 2)
        _GDIPlus_GraphicsSetTextRenderingHint($hCtxt, 4)
    EndIf
    Local $hBrush = _GDIPlus_BrushCreateSolid($iFontColor)
    Local $hFormat = _GDIPlus_StringFormatCreate()
    _GDIPlus_StringFormatSetAlign($hFormat, $iAlign)
    Local $hFamily = _GDIPlus_FontFamilyCreate($sFont)
    Local $hFont = _GDIPlus_FontCreate($hFamily, $iFontSize)
    Local $tLayout = _GDIPlus_RectFCreate(0, 0, $aSize[2], $aSize[3])
    _GDIPlus_GraphicsDrawStringEx($hCtxt, $sText, $hFont, $tLayout, $hFormat, $hBrush)
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hCtxt)
    Local $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
    Local $hB = GUICtrlSendMsg($iCtrl, 0x0172, 0, $hHBitmap)
    If $hB Then _WinAPI_DeleteObject($hB)
    _WinAPI_DeleteObject($hHBitmap)
    Return 1
EndFunc

Func _GDIPlus_CropImage($hImage, $iX, $iY, $iW, $iH, $bHBitmap = False)
    Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH)
    Local $hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsDrawImageRectRect($hCtxt, $hImage, $iX, $iY, $iW, $iH, 0, 0, $iW, $iH)
    _GDIPlus_GraphicsDispose($hCtxt)
    If $bHBitmap Then
        Local $hHBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
        _GDIPlus_BitmapDispose($hBitmap)
        Return $hHBmp
    EndIf
    Return $hBitmap
EndFunc

 

Something like this here.

Edited by UEZ
Modified code to run with built-in functions

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Or try something like this (you'll have to adjust positioning, there seems to be an kind of border/offset in the control, was too lazy for that :) )...

 

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>


gui_1(); ;If I do not use the $ WS_EX_COMPOSITED flashes the label.

Func gui_1()
    Local $Form1 = GUICreate("Form1", 194, 137, 414, 452)
    Local $pic = GUICtrlCreatePic(_background(True), 0, 0, 194, 137)
    Local $Label1 = GUICtrlCreateInput("100", 0, 0, 194, 137, $ES_READONLY, $WS_EX_TRANSPARENT)
    GUICtrlSetColor(-1, 0xffffff)
    GUICtrlSetBkColor(-1, 0x000000)
    GUICtrlSetFont(-1, 70, 800, 0, "Arial Black")
    GUISetState(@SW_SHOW)
    For $i = 100 To 200
        Sleep(20)
        GUICtrlSetData($Label1, $i)
    Next
EndFunc   ;==>gui_1


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

; #INDEX# =======================================================================================================================
; Title .........: _background()
; AutoIt Version.: 3.3.8.1
; Language.......: Português (Brasil) - 0416(PTB)
; Description ...: Compressed file embedded
; Author ........: BELINI
; ===============================================================================================================================

; #CURRENT# =====================================================================================================================
; _background()
; ===============================================================================================================================

; #INTERNAL_USE_ONLY# ===========================================================================================================
; __background() ; _LZNTDecompress renamed!
; __backgroundB64() ; _Base64 renamed!
; ===============================================================================================================================

; #VARIABLES# ===================================================================================================================
; ===============================================================================================================================

; #FUNCTION# ====================================================================================================================
; Name ..........: _background()
; Description ...: Compressed file embedded in your .au3 file
; Syntax ........: _background( [ lToSave [, sPath [, lExecute ]]] )
; Parameters ....: lToSave             - [optional] If True, save the file, else, return binary data. Default is False.
;                  sPath               - [optional] The path of the file to be save. Default is @TempDir
;                  lExecute            - [optional] Flag to execute file saved. Default is False
; Return values .: Success             - Returns decompressed fundo.bmp binary data or saved.
;                    Failure             - Returns 0 and set @error to 1.
; Author(s) .....: João Carlos (Jscript FROM Brazil)
; Modified ......:
; Remarks .......: This function uses _LZNTDecompress() and _Base64Decode() by trancexx.
; Related .......:
; Link ..........:
; Example .......; _background()
; ===============================================================================================================================
Func _background($lToSave = False, $sPath = @TempDir, $lExecute = False)
    Local $hFileHwnd, $bData, $sFileName = $sPath & "\fundo.bmp"

    ; Original: D:\JukeBel\00 Arquivos úteis\fundo.bmp
    $bData = "LrGgQk0cDQACADYAUIooADAhBBgBABgASAAAAOYMAAASC8cDDAJAAhD/AABdCF5g/wDA/2Nncf9KXxD/GP8Yf7b/QMinVXYK/0r/Sn8lfww/BP9fJP0Qfwx/DH8MPQR/DH8M/38Mfx37EP8H/xj/GP8Y/xD//xg/Ff8Q+RB/FD8QPRB/DP9/DH8MHwIfAR8BHwEfARUB/38MHwEfAR8BHwEXAb8BHwH/HwEfAR8BFwG/AR8BHwEfAf8fARcBvwEfAR8BHwEfARcB/78BHwEfAR8BHwEXAb8BHwH/HwEfAR8BFwG/AR8BHwEfAf8fARcBvwEfAR8BHwEfARcB/78BHwEfAR8BHwEXAb8BHwH/HwEfAR8BFwG/AR8BHwEfAf8fARcBvwEfAR8BHwEfARcBAAA="

    If $lToSave Then
        $hFileHwnd = FileOpen($sFileName, 10)
        If @error Then Return SetError(1, 0, 0)
        FileWrite($hFileHwnd, __background(__backgroundB64($bData)))
        FileClose($hFileHwnd)
        If $lExecute Then
            RunWait($sFileName, "")
            FileDelete($sFileName)
            Return 1
        EndIf
        If FileExists($sFileName) Then Return $sFileName
    Else
        Return __background(__backgroundB64($bData))
    EndIf

    Return SetError(1, 0, 0)
EndFunc   ;==>_background

; #INTERNAL_USE_ONLY# ===========================================================================================================
; Name...........: __backgroundB64
; Description ...: Base64 decode input data.
; Syntax.........: __backgroundB64($bBinary)
; Parameters ....: $sInput - String data to decode
; Return values .: Success - Returns decode binary data.
;                          - Sets @error to 0
;                  Failure - Returns empty string and sets @error:
;                  |1 - Error calculating the length of the buffer needed.
;                  |2 - Error decoding.
; Author ........: trancexx
; Modified ......: João Carlos (Jscript FROM Brazil)
; Related .......: _Base64Encode()
; ===============================================================================================================================
Func __backgroundB64($sInput)
    Local $struct = DllStructCreate("int")
    Local $a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", _
            "str", $sInput, _
            "int", 0, _
            "int", 1, _
            "ptr", 0, _
            "ptr", DllStructGetPtr($struct, 1), _
            "ptr", 0, _
            "ptr", 0)
    If @error Or Not $a_Call[0] Then
        Return SetError(1, 0, "") ; error calculating the length of the buffer needed
    EndIf
    Local $a = DllStructCreate("byte[" & DllStructGetData($struct, 1) & "]")
    $a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", _
            "str", $sInput, _
            "int", 0, _
            "int", 1, _
            "ptr", DllStructGetPtr($a), _
            "ptr", DllStructGetPtr($struct, 1), _
            "ptr", 0, _
            "ptr", 0)
    If @error Or Not $a_Call[0] Then
        Return SetError(2, 0, ""); error decoding
    EndIf
    Return DllStructGetData($a, 1)
EndFunc   ;==>__backgroundB64

; #INTERNAL_USE_ONLY# ===========================================================================================================
; Name...........: __background
; Original Name..: _LZNTDecompress
; Description ...: Decompresses input data.
; Syntax.........: __background($bBinary)
; Parameters ....: $vInput - Binary data to decompress.
; Return values .: Success - Returns decompressed binary data.
;                          - Sets @error to 0
;                  Failure - Returns empty string and sets @error:
;                  |1 - Error decompressing.
; Author ........: trancexx
; Related .......: _LZNTCompress
; Link ..........; http://msdn.microsoft.com/en-us/library/bb981784.aspx
; ===============================================================================================================================
Func __background($bBinary)
    $bBinary = Binary($bBinary)
    Local $tInput = DllStructCreate("byte[" & BinaryLen($bBinary) & "]")
    DllStructSetData($tInput, 1, $bBinary)
    Local $tBuffer = DllStructCreate("byte[" & 16 * DllStructGetSize($tInput) & "]") ; initially oversizing buffer
    Local $a_Call = DllCall("ntdll.dll", "int", "RtlDecompressBuffer", _
            "ushort", 2, _
            "ptr", DllStructGetPtr($tBuffer), _
            "dword", DllStructGetSize($tBuffer), _
            "ptr", DllStructGetPtr($tInput), _
            "dword", DllStructGetSize($tInput), _
            "dword*", 0)

    If @error Or $a_Call[0] Then
        Return SetError(1, 0, "") ; error decompressing
    EndIf

    Local $tOutput = DllStructCreate("byte[" & $a_Call[6] & "]", DllStructGetPtr($tBuffer))

    Return SetError(0, 0, DllStructGetData($tOutput, 1))
EndFunc   ;==>__background

 

Link to comment
Share on other sites

@UEZ could not test it gave error on line 72 (Subscript used with non-Array variable)

@KaFu Worked but I need to center the text and the control accepts not to use the style $ SS_CENTER

Edited by Belini
Link to comment
Share on other sites

I use the 3.3.9.4 version of Autoit and gave undefined function to _GDIPlus_BitmapCreateFromScan0 () and _GDIPlus_GraphicsSetTextRenderingHint () as I can exchange them for other functions from version 3.3.9.4?

Link to comment
Share on other sites

UEZ Used the 3.3.14.1 version and it showed unblinking text but what I need is even use a label upon a PIC unblinking, what I really need is to use the $ WS_EX_COMPOSITED not to blink and Label is above pic.

EDITED: $ WS_EX_COMPOSITED already solved the problem of flashing the label now we just need to upload the image keeping the label over it.

Edited by Belini
Link to comment
Share on other sites

You don't need to provide the background image.

Use this line instead

_GDIPlus_DrwTxt2Ctrl($hGUI, $iPic, "Graphic Control: " & Random(1111111111, 99999999999, 1), 0, 11, "Arial", 0xFF000040, 0xFFF0F0F0, 1) ;workaround using GDI+

 

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

But I need to have an image under the text, without the image works already using $WS_EX_COMPOSITED

Link to comment
Share on other sites

Apparently put a label on PIC and upgrade it without blinking is more difficult than I imagined!

Link to comment
Share on other sites

As I could not do it the way I wanted I used the tip of @Kafu but I had to move the input off the screen when I do not need the text on the PIC because the input does not accept GUICtrlSetBkColor (-1, $ GUI_BKCOLOR_TRANSPARENT) as the label.

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...