Sign in to follow this  
Followers 0
Lucid

Semi-transparent PNG via GDI+?

5 posts in this topic

I'm trying to rethink how I do my GUIs, and I'm struggling with a new issue - and I can't find what I'm looking for elsewhere in the forum. So I'm hoping someone here can point me in the right direction.

I'm tinkering with GUICtrlOnHover, but what I'm really wanting to do is use just 1 PNG file (as opposed to 3 separate files), and just have it become "solid" on hover, but semi-transparent when not active. Does that make sense? Can anyone shed any light on how I can adjust the transparency of an image "button" using GDI+?

#include-once
#include <GDIPlus.au3>
#include <GUICtrlOnHover.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

AutoItSetOption("MustDeclareVars", 1)

_GDIPlus_Startup()

Local $hGUI = GUICreate("test", 200, 100, -1, -1, $WS_POPUP, $WS_EX_LAYERED)
GUISetBkColor(0x000000, $hGUI)

Local $hButtonImagePNG = _GDIPlus_ImageLoadFromFile("button.png")
Local $iButtonWidth = _GDIPlus_ImageGetWidth($hButtonImagePNG)
Local $iButtonHeight = _GDIPlus_ImageGetHeight($hButtonImagePNG)
Local $hButtonImageBMP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hButtonImagePNG)

Local $hButton = GUICtrlCreatePic("", 0, 0, $iButtonWidth, $iButtonHeight)
_SendMessage(GUICtrlGetHandle($hButton), 0x0172, 0, $hButtonImageBMP)
_GUICtrl_OnHoverRegister($hButton, "_ImageButtonHover", "_ImageButtonHover", "_ImageButtonPressed", "_ImageButtonPressed", 0)

GUISetState(@SW_SHOW, $hGUI)

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

I should mention that I can get the 3-phase buttons to work just fine (I left out the code for my _ImageButtonHover and _ImageButtonPressed functions since I don't have anything in them that works for the single image file issue I'm currently running into). I'm just having problems wrapping my brain around how I can get the solid/faded look for a single image.

Thanks!

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Try this:

#AutoIt3Wrapper_Version=b
#include <Array.au3>
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#Include <WindowsConstants.au3>

_GDIPlus_Startup()
Global $aBtn[3] = [_GDIPlus_BitmapCreateFromMemory(_b0png(), True), _GDIPlus_BitmapCreateFromMemory(_b1png(), True), _GDIPlus_BitmapCreateFromMemory(_b2png(), True)]
Global Const $hGUI = GUICreate("Button Test", 256, 64, -1, @DesktopHeight / 2 - 200)
Global $aPic_Btn[2][2] = [[GUICtrlCreatePic("", 30, 7, 82, 49), 0], [GUICtrlCreatePic("", 150, 7, 82, 49), 0]]
_WinAPI_DeleteObject(GUICtrlSendMsg($aPic_Btn[0][0], $STM_SETIMAGE, $IMAGE_BITMAP, $aBtn[0]))
_WinAPI_DeleteObject(GUICtrlSendMsg($aPic_Btn[1][0], $STM_SETIMAGE, $IMAGE_BITMAP, $aBtn[0]))
GUISetState()

Global $aHover, $i, $bNoHover = False, $bMBPressed = False

Do
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            GUIDelete()
            _GDIPlus_Shutdown()
            _WinAPI_DeleteObject($aBtn[0])
            _WinAPI_DeleteObject($aBtn[1])
            _WinAPI_DeleteObject($aBtn[2])
            Exit
    EndSwitch
    $aHover = GUIGetCursorInfo($hGUI)
    $iPos = _ArraySearch($aPic_Btn, $aHover[4], 0, 0, 0, 0, 1, 0)
    Switch $iPos
        Case 0 To UBound($aPic_Btn) - 1
            $bNoHover = False
            $aHover = GUIGetCursorInfo($hGUI)
            Switch $aHover[2]
                Case 0
                    If Not $aPic_Btn[$iPos][1] Then
                        _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_ERASENOW)
                        _WinAPI_DeleteObject(GUICtrlSendMsg($aPic_Btn[$iPos][0], $STM_SETIMAGE, $IMAGE_BITMAP, 0))
                        _WinAPI_DeleteObject(GUICtrlSendMsg($aPic_Btn[$iPos][0], $STM_SETIMAGE, $IMAGE_BITMAP, $aBtn[1]))
                        For $i = 0 To UBound($aPic_Btn) - 1
                            If $i <> $iPos Then
                                $aPic_Btn[$i][1] = 0
                                _WinAPI_DeleteObject(GUICtrlSendMsg($aPic_Btn[$i][0], $STM_SETIMAGE, $IMAGE_BITMAP, 0))
                                _WinAPI_DeleteObject(GUICtrlSendMsg($aPic_Btn[$i][0], $STM_SETIMAGE, $IMAGE_BITMAP, $aBtn[0]))
                            EndIf
                        Next
                        _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_UPDATENOW)
                        $aPic_Btn[$iPos][1] = 1
                        $bMBPressed = False
                    EndIf
                Case 1
                    If Not $bMBPressed Then
                        $bMBPressed = True
                        _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_ERASENOW)
                        For $i = 0 To UBound($aPic_Btn) - 1
                            $aPic_Btn[$i][1] = 0
                            _WinAPI_DeleteObject(GUICtrlSendMsg($aPic_Btn[$i][0], $STM_SETIMAGE, $IMAGE_BITMAP, 0))
                            If $i = $iPos Then
                                _WinAPI_DeleteObject(GUICtrlSendMsg($aPic_Btn[$i][0], $STM_SETIMAGE, $IMAGE_BITMAP, $aBtn[2]))
                                ConsoleWrite("Button with id was pressed: " & $aPic_Btn[$iPos][0] & @CRLF)
                            Else
                                _WinAPI_DeleteObject(GUICtrlSendMsg($aPic_Btn[$i][0], $STM_SETIMAGE, $IMAGE_BITMAP, $aBtn[0]))
                            EndIf
                        Next
                        _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_UPDATENOW)
                    EndIf
            EndSwitch
        Case Else
            If Not $bNoHover Then
                _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_ERASENOW)
                For $i = 0 To UBound($aPic_Btn) - 1
                    $aPic_Btn[$i][1] = 0
                    _WinAPI_DeleteObject(GUICtrlSendMsg($aPic_Btn[$i][0], $STM_SETIMAGE, $IMAGE_BITMAP, 0))
                    _WinAPI_DeleteObject(GUICtrlSendMsg($aPic_Btn[$i][0], $STM_SETIMAGE, $IMAGE_BITMAP, $aBtn[0]))
                Next
                _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_UPDATENOW)
                $bNoHover = True
            EndIf
    EndSwitch
Until False


;Code below was generated by: 'File to Base64 String' Code Generator v1.20 Build 2015-03-02

Func _b0png($bSaveBinary = False, $sSavePath = @ScriptDir)
    Local $b0png
    $b0png &= 'iVBORw0KGgoAAAANSUhEUgAAAFIAAAAxCAYAAABJTP5vAAAIdklEQVR4Xu1bbUyU2RU+8wEM39+OWlZ+qCkFDKui/eHKbqvZsMYPEs2mRpsm3V1jsgmL+sNWUX/YJtuQoCYra5P9obtRNxujsaWpdEMVEfkyYCMUAxq3CaCbAIowM8zwMtPnnHJ/jMPw8s4YU5h5kuO9nJm5932f+5x7zjt3NPl8PgofUZgpGKKIEhklMkpkFNaZnO+990uaDe3trckmk+lDs9m8FbYafTvMBiMF7v8/A0l2As2PsE70a2HfFRWtHiMd3Lr1zzkTKWhouBngi4+PjwVxBywWy+9gaegTWkIrxCmbJ7DBckEgWxn6p3t6uj/XNK1qZGTEE6Ii9QESc0HYFRBXbLVahUBuY2JipGWYaH7Bi9JvamqK1UlAktfr/UNsbOxvbDbbB4ODg49fO5Eg8Wcg8XsQ9hMYxcXFUXJSkrRmKHDK6yUvLmheAtcPFZJrYkIiC1gJkXQuX7689PHjx3dfG5EgcQkm+IciMSUlhZJAIq+iw+kkj8dDWEmazwCBHFlyH5OTk/x3Mu6rrqCgcGN3d9f9sImExCE40zdYoRwmMT0tjRISEmgCq+cEiQvkqUiiyQ3jBGkBqR6QCWKTXC7nXzdseKeoqenOSFjlD5T4W5C4CUapqalMohDocDiExIUG3/SeCfVIpMFykHi+evfdX5hCViRCOgFq/CPLPiE+nhJhTKDL5aJIwJSmSTs+PrYlNTWtFN2/h6RIkPgRSFzEIZ2KfXFS04TESAHuW/ZLJKK40dEXlVBlbEiKBJH7WI2JCGf0aXxsTKQfKZCamEhC3OEYL9S0zE2sSkNEtrW15CHBFDKRNoT0BAbTsHdEGixQpdvtZjJTkBc+NEwkFPi+KgksaB3j40Q6ajx1+jRlZWXRr/fupQUCSTqA1Jl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YP/nUZVWS3LyCD6gNhJOqora2lc+fOSWmyc+dOvhExRlVVlTyTt7e3y/sePHjAScHvphoaGujatWu0a9cuamlpofr6+ln9OKiiI0eOSL+5uZnu3r0rCj1+/LjMg0fdcI5tWY0sBIfZbHpBQTDjj6hwJlOOM4wzuABWhJzLzAXq+AFHFNyXz2IcvqmAxKNe54XCPDIH+n7vxfMtH2uo0OLzotn8Mp7UqJqmKgi+FokGBU4oOCkUvwLGkjExDo8XcK3/OyFI60P1ca61taXaCJF5UFAPJuTnbSElEiFPNDAWg92+uDEtLf1Pzc1Nc3/WLi5e//D+/Y6HUEwelpVMUAr6FGnwToc1ROVCpAzHxFg7DdeRkPSXCLUzUCwPJNKPRIADwvFVf0xM7JPGxtuDBpONyPor2CgIZWnLykQSVJLBvWsI6V6I6ftQCnI+MXTiCPb3ILIGg0hpAx9FEkAe8kVyX2JiwiD69SGfayP7/RlK7ERLisxIATI1Z/YX2dnZ/7ZYrN/iR2WekImEAr0gcSuHOFopG5DRF/rpoRKNZ9Eie3NcnK0DpN4M+7c/o6Ojg0uXLn0fRNYjzJN4EoS8lETqy4AFAFV0i6GudWdn228nJ6c8gq8GavSFS6R6cmhbsWLFJij0LyDUjsFFmSiJJJuDYPVoNq+IUy2Ms7MicRQkNuKrwB/g+xwkvnitv4989OhRW3HxujU4eLrgdDpK4IrFRBwCAc+m80yJyiaRWB7ii+guRF0vXvkCJA697h+aCu7dax/ETzc+gArL8DOOT93uieVQaAYuwgYCLWgJ7XwhcApCcFutMSNIKv14BPwBBLL6amF1IFEzlOHJIKYnuAJCecKfw4pgubA0GW9+QYMxef+B/QvWCgInKARE2P/8iv73kCiRUSKjiBIZJTJKZBT/BVW4TPqo03KPAAAAAElFTkSuQmCC'
    Local $bString = _WinAPI_Base64Decode($b0png)
    If @error Then Return SetError(1, 0, 0)
    $bString = Binary($bString)
    If $bSaveBinary Then
        Local Const $hFile = FileOpen($sSavePath & "\b0.png", 18)
        If @error Then Return SetError(2, 0, $bString)
        FileWrite($hFile, $bString)
        FileClose($hFile)
    EndIf
    Return $bString
EndFunc   ;==>_b0png

Func _b2png($bSaveBinary = False, $sSavePath = @ScriptDir)
    Local $b2png
    $b2png &= 'iVBORw0KGgoAAAANSUhEUgAAAFIAAAAxCAMAAAB+kg5dAAACalBMVEX///8AAAA/P0EFBQU/P0EpKCg5OTsoJiY9PT85OTs5OTsODg4GBgYGBgY7Oz08PD4/P0ERERE/P0E/P0E/P0E/P0EzMzU/P0E/P0E+PkA/P0EDAwMFBQUQEBAVFRU5OTsEBAQuLjAXFxgXFxgEBAQSEhIEBAQMDA0ODg4hISITExMiIiMEBAQDAwMDAwMhISIFBQUmJCQEBAQGBgYEBAQFBQUEBAQFBQUDAwMEBAQFBQU2NjghISIFBQUKCgoPDxAFBQUGBgYDAwMPDw8GBgYEBAQEBAQSEhIGBgYNDQ0DAwMWFhc6OjwFBQUfHyAFBQUtLS4ICAgSEhIGBgYfHyA8PD4FBQUJCQkPDw82NjgDAwMEBAQhISI8PD4HBQUFBQUNDQ4UFBU6Ojs+PkAGBgYICAgODg4REREDAwM+PkAUFBUPDw8REREwMDE+PkA/P0EgICASEhMVFRU+PkA/P0EyMjQeHh8QEBAREREhISI8PD4/P0E/P0E3NzglJSYZGRoTExMFBQUUFBQbGxsnJyg7Oz0/P0E/P0EGBgYKCgoODg86OjwHBwcJCQkMDAwNDQ0ODg4qKioPDw8QEBALCwsoKCgGBgYJCQkVFRUPDg4HBwcNDAwAAAASEhIICAgiIiIjIyMRERETEhIZGRkdHR0cHBwKCgoFBQUYGBgEBAQWFhYTExMBAQECAgIDAwMKCQkWFRUXFxcpKSkgICAMCwsSEREkJCQfHx8ZGBgUFBQVFBQaGhoQDw8eHh4aGRkREBAcGxslJSUpKCgnJycUExMmJiYXFhYODQ0mJSUbGxshISEIBwciISEYFxeZK10PAAAAjnRSTlMAAKEAAACnAEeZovz3+GxIBvyNbgGdrwg/GgQZpPfiEmOa4Tpt8OMj8q3vMMsoDc3gAGTg5G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PzIRTXzgweVB8pdfQbBI5COPHhQkH3v8CSYxgvjkU0/HgmRf37PPCcl6Fp/f8OK6DrLvpZeFFNATiK+8+trrsXaSeuNNIaVACBuytza8/U6sk6Tefe99IYVgIfvgw48+/iTWQcaabfn0s8+/WC1DtPqrr7/59rvvt8S6kH4bN61ds37fEK1fs3bTRtICZMQWW+xfvzSO9/+fiBMAAAAASUVORK5CYII='
    Local $bString = _WinAPI_Base64Decode($b2png)
    If @error Then Return SetError(1, 0, 0)
    $bString = Binary($bString)
    If $bSaveBinary Then
        Local Const $hFile = FileOpen($sSavePath & "\b2.png", 18)
        If @error Then Return SetError(2, 0, $bString)
        FileWrite($hFile, $bString)
        FileClose($hFile)
    EndIf
    Return $bString
EndFunc   ;==>_b2png

Func _b1png($bSaveBinary = False, $sSavePath = @ScriptDir)
    Local $b1png
    $b1png &= 'iVBORw0KGgoAAAANSUhEUgAAAFIAAAAxCAYAAABJTP5vAAAMfklEQVR4Xu2bC4xVxf3HvzPn3IUFYWFdXJ7iUlcqWhUNFbVoTUQipVZibesjsZWqVYylFusf/zZtKdVQIQ22VC01JbZSUBsftCKoNNX4QDQUGl9IKU8VXWWXZe/u3ntmpjN35uSXO3P21DUhYWsn+WbOmeTMuecz39+Zx53Dxr0ikJFYkGeL+2V+HYeZFCgpT5KOA8HPfcW5ELOhcZJfTuAPO5jZQKSfk6jcg8iyYMa5EEN4UVbuO7MPgCQROJGRMw9qCDMESQCyADrFNg/ESX0GpPQg+krSYw+izKgTceAcghFlACyYY5KFS7At/MMdJLnMQSJoCQncB+rECSY5M/bckwWxkCMCahWG+GGQckJaeADLJEQ2D8xAMEFhTo4kkQsJWI1TPzomoASyzyVh5AEsOXV7xih7MC1gz5HB+9AD2N9A9DRI62ytSVrHag2x5X0jOVCtWtu0Nmo9q9Vuyr0oYz40yiGz3pEsCGeCWGtyp4FaM7UuMTCZKCNqeRes1El9Wd9I/VRNbaNoGNGoosJZAGZpPaT1iFaH48D9V4N3zPIcGQcQSUdr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RXB6F/vNJwPXLQRGjWuhLSsoWhHEwJkOJO0HJ1cSzHAT1a1Q8liz8i3XrQBefxkQyaECdejhRjEw4fOAnk7CrK4zvs1totpF8HyIRgQxDW3u7UTznBls6ztC66J0Wx+SMrBv'
    $b1png &= 'V2Xdr48luwbZeHT6Z1u729b3qAvlrooIYJfnRCPqbLwVDZGzdZk6JNuT/VnrbMSFSRj1GRP2Qy38vpEclP200RTPuelfyUHr7gGgcFLeZvxg96kAJQ8y9ezuJqu1nuzDW58lPQ8N+4y8MC57IINFC3Ik5SJnc6Wg4dF/+Wb8UCJ0Y+hIRrDAA1dmO5Ig9v3PQwgmqUzlAUTp1Yc4nDMQTG+dMqJQ+FR+sCRzP1gKCgkmy7rxp+sTuvzvEnO+RaQw94AqP/Q/fR91hhADkDkw6Zxy+b/PjMMU594whAsPmuhDEPNhhuch+Jz0b7lT2F9wYXECAAAAAElFTkSuQmCC'
    Local $bString = _WinAPI_Base64Decode($b1png)
    If @error Then Return SetError(1, 0, 0)
    $bString = Binary($bString)
    If $bSaveBinary Then
        Local Const $hFile = FileOpen($sSavePath & "\b1.png", 18)
        If @error Then Return SetError(2, 0, $bString)
        FileWrite($hFile, $bString)
        FileClose($hFile)
    EndIf
    Return $bString
EndFunc   ;==>_b1png

Func _WinAPI_Base64Decode($sB64String)
    Local $aCrypt = DllCall("Crypt32.dll", "bool", "CryptStringToBinaryA", "str", $sB64String, "dword", 0, "dword", 1, "ptr", 0, "dword*", 0, "ptr", 0, "ptr", 0)
    If @error Or Not $aCrypt[0] Then Return SetError(1, 0, "")
    Local $bBuffer = DllStructCreate("byte[" & $aCrypt[5] & "]")
    $aCrypt = DllCall("Crypt32.dll", "bool", "CryptStringToBinaryA", "str", $sB64String, "dword", 0, "dword", 1, "struct*", $bBuffer, "dword*", $aCrypt[5], "ptr", 0, "ptr", 0)
    If @error Or Not $aCrypt[0] Then Return SetError(2, 0, "")
    Return DllStructGetData($bBuffer, 1)
EndFunc   ;==>_WinAPI_Base64Decode
Only tested on Win 8.1 x64 running AutoIt v3.3.13.20 (beta). Edited by UEZ

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

UEZ,

Thanks for the code! I ended up adding: Global Const $STM_SETIMAGE = 0x0172 but after that, it looks like it worked just fine on my x64 Win8.1 box.

Unfortunately, it doesn't look like it does what I'm currently after. When it's visible, with no mouse hovering over it, I'm wanting the image button to be semi-transparent (say, 50%). Then, when the mouse moves over it, the button should change to 100% visibility/opaque. Does that make sense? Did I overlook something in the example code?

Thanks again!

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I don't know why you want to have the button semi transparent but here we go:

 

#AutoIt3Wrapper_Version=b
#include <Array.au3>
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#Include <WindowsConstants.au3>

_GDIPlus_Startup()
#Region convert bitmap to semi transparent bitmap
Global Const $hBitmap_empty = _GDIPlus_BitmapCreateFromScan0(82, 49)
Global Const $hGfx = _GDIPlus_ImageGetGraphicsContext($hBitmap_empty)
Global Const $hBitmap = _GDIPlus_BitmapCreateFromMemory(_b0png())
Global Const $hAttribute_Alpha = _GDIPlus_ImageAttributesCreate()
Global Const $tColorMatrix = _GDIPlus_ColorMatrixCreateTranslate(0, 0, 0, -0.5)
_GDIPlus_ImageAttributesSetColorMatrix($hAttribute_Alpha, 0, True, DllStructGetPtr($tColorMatrix))
_GDIPlus_GraphicsDrawImageRectRect($hGfx, $hBitmap, 0, 0, 82, 49, 0, 0, 82, 49, $hAttribute_Alpha)
_GDIPlus_GraphicsDispose($hGfx)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_ImageAttributesDispose($hAttribute_Alpha)
#EndRegion
Global $aBtn[3] = [_GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_empty), _GDIPlus_BitmapCreateFromMemory(_b1png(), True), _GDIPlus_BitmapCreateFromMemory(_b2png(), True)]
_GDIPlus_BitmapDispose($hBitmap_empty)

Global Const $hGUI = GUICreate("Button Test", 256, 64, -1, @DesktopHeight / 2 - 200)
GUISetBkColor(0xC8C8C8, $hGUI)
Global $aPic_Btn[2][2] = [[GUICtrlCreatePic("", 30, 7, 82, 49), 0], [GUICtrlCreatePic("", 150, 7, 82, 49), 0]]
_WinAPI_DeleteObject(GUICtrlSendMsg($aPic_Btn[0][0], $STM_SETIMAGE, $IMAGE_BITMAP, $aBtn[0]))
_WinAPI_DeleteObject(GUICtrlSendMsg($aPic_Btn[1][0], $STM_SETIMAGE, $IMAGE_BITMAP, $aBtn[0]))
GUISetState()

Global $aHover, $i, $bNoHover = False, $bMBPressed = False

Do
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            GUIDelete()
            _GDIPlus_Shutdown()
            _WinAPI_DeleteObject($aBtn[0])
            _WinAPI_DeleteObject($aBtn[1])
            _WinAPI_DeleteObject($aBtn[2])
            Exit
    EndSwitch
    $aHover = GUIGetCursorInfo($hGUI)
    $iPos = _ArraySearch($aPic_Btn, $aHover[4], 0, 0, 0, 0, 1, 0)
    Switch $iPos
        Case 0 To UBound($aPic_Btn) - 1
            $bNoHover = False
            $aHover = GUIGetCursorInfo($hGUI)
            Switch $aHover[2]
                Case 0
                    If Not $aPic_Btn[$iPos][1] Then
                        _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_ERASENOW)
                        _WinAPI_DeleteObject(GUICtrlSendMsg($aPic_Btn[$iPos][0], $STM_SETIMAGE, $IMAGE_BITMAP, 0))
                        _WinAPI_DeleteObject(GUICtrlSendMsg($aPic_Btn[$iPos][0], $STM_SETIMAGE, $IMAGE_BITMAP, $aBtn[1]))
                        For $i = 0 To UBound($aPic_Btn) - 1
                            If $i <> $iPos Then
                                $aPic_Btn[$i][1] = 0
                                _WinAPI_DeleteObject(GUICtrlSendMsg($aPic_Btn[$i][0], $STM_SETIMAGE, $IMAGE_BITMAP, 0))
                                _WinAPI_DeleteObject(GUICtrlSendMsg($aPic_Btn[$i][0], $STM_SETIMAGE, $IMAGE_BITMAP, $aBtn[0]))
                            EndIf
                        Next
                        _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_UPDATENOW)
                        $aPic_Btn[$iPos][1] = 1
                        $bMBPressed = False
                    EndIf
                Case 1
                    If Not $bMBPressed Then
                        $bMBPressed = True
                        _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_ERASENOW)
                        For $i = 0 To UBound($aPic_Btn) - 1
                            $aPic_Btn[$i][1] = 0
                            _WinAPI_DeleteObject(GUICtrlSendMsg($aPic_Btn[$i][0], $STM_SETIMAGE, $IMAGE_BITMAP, 0))
                            If $i = $iPos Then
                                _WinAPI_DeleteObject(GUICtrlSendMsg($aPic_Btn[$i][0], $STM_SETIMAGE, $IMAGE_BITMAP, $aBtn[2]))
                                ConsoleWrite("Button with id was pressed: " & $aPic_Btn[$iPos][0] & @CRLF)
                            Else
                                _WinAPI_DeleteObject(GUICtrlSendMsg($aPic_Btn[$i][0], $STM_SETIMAGE, $IMAGE_BITMAP, $aBtn[0]))
                            EndIf
                        Next
                        _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_UPDATENOW)
                    EndIf
            EndSwitch
        Case Else
            If Not $bNoHover Then
                _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_ERASENOW)
                For $i = 0 To UBound($aPic_Btn) - 1
                    $aPic_Btn[$i][1] = 0
                    _WinAPI_DeleteObject(GUICtrlSendMsg($aPic_Btn[$i][0], $STM_SETIMAGE, $IMAGE_BITMAP, 0))
                    _WinAPI_DeleteObject(GUICtrlSendMsg($aPic_Btn[$i][0], $STM_SETIMAGE, $IMAGE_BITMAP, $aBtn[0]))
                Next
                _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_UPDATENOW)
                $bNoHover = True
            EndIf
    EndSwitch
Until False


;Code below was generated by: 'File to Base64 String' Code Generator v1.20 Build 2015-03-02

Func _b0png($bSaveBinary = False, $sSavePath = @ScriptDir)
    Local $b0png
    $b0png &= 'iVBORw0KGgoAAAANSUhEUgAAAFIAAAAxCAYAAABJTP5vAAAIdklEQVR4Xu1bbUyU2RU+8wEM39+OWlZ+qCkFDKui/eHKbqvZsMYPEs2mRpsm3V1jsgmL+sNWUX/YJtuQoCYra5P9obtRNxujsaWpdEMVEfkyYCMUAxq3CaCbAIowM8zwMtPnnHJ/jMPw8s4YU5h5kuO9nJm5932f+5x7zjt3NPl8PgofUZgpGKKIEhklMkpkFNaZnO+990uaDe3trckmk+lDs9m8FbYafTvMBiMF7v8/A0l2As2PsE70a2HfFRWtHiMd3Lr1zzkTKWhouBngi4+PjwVxBywWy+9gaegTWkIrxCmbJ7DBckEgWxn6p3t6uj/XNK1qZGTEE6Ii9QESc0HYFRBXbLVahUBuY2JipGWYaH7Bi9JvamqK1UlAktfr/UNsbOxvbDbbB4ODg49fO5Eg8Wcg8XsQ9hMYxcXFUXJSkrRmKHDK6yUvLmheAtcPFZJrYkIiC1gJkXQuX7689PHjx3dfG5EgcQkm+IciMSUlhZJAIq+iw+kkj8dDWEmazwCBHFlyH5OTk/x3Mu6rrqCgcGN3d9f9sImExCE40zdYoRwmMT0tjRISEmgCq+cEiQvkqUiiyQ3jBGkBqR6QCWKTXC7nXzdseKeoqenOSFjlD5T4W5C4CUapqalMohDocDiExIUG3/SeCfVIpMFykHi+evfdX5hCViRCOgFq/CPLPiE+nhJhTKDL5aJIwJSmSTs+PrYlNTWtFN2/h6RIkPgRSFzEIZ2KfXFS04TESAHuW/ZLJKK40dEXlVBlbEiKBJH7WI2JCGf0aXxsTKQfKZCamEhC3OEYL9S0zE2sSkNEtrW15CHBFDKRNoT0BAbTsHdEGixQpdvtZjJTkBc+NEwkFPi+KgksaB3j40Q6ajx1+jRlZWXRr/fupQUCSTqA1JlO5/iajRtLlsIxaITI9TApuKFEtjlnveGREcrIyKBwU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hExRlVVlTyTt7e3y/sePHjAScHvphoaGujatWu0a9cuamlpofr6+ln9OKiiI0eOSL+5uZnu3r0rCj1+/LjMg0fdcI5tWY0sBIfZbHpBQTDjj6hwJlOOM4wzuABWhJzLzAXq+AFHFNyXz2IcvqmAxKNe54XCPDIH+n7vxfMtH2uo0OLzotn8Mp7UqJqmKgi+FokGBU4oOCkUvwLGkjExDo8XcK3/OyFI60P1ca61taXaCJF5UFAPJuTnbSElEiFPNDAWg92+uDEtLf1Pzc1Nc3/WLi5e//D+/Y6HUEwelpVMUAr6FGnwToc1ROVCpAzHxFg7DdeRkPSXCLUzUCwPJNKPRIADwvFVf0xM7JPGxtuDBpONyPor2CgIZWnLykQSVJLBvWsI6V6I6ftQCnI+MXTiCPb3ILIGg0hpAx9FEkAe8kVyX2JiwiD69SGfayP7/RlK7ERLisxIATI1Z/YX2dnZ/7ZYrN/iR2WekImEAr0gcSuHOFopG5DRF/rpoRKNZ9Eie3NcnK0DpN4M+7c/o6Ojg0uXLn0fRNYjzJN4EoS8lETqy4AFAFV0i6GudWdn228nJ6c8gq8GavSFS6R6cmhbsWLFJij0LyDUjsFFmSiJJJuDYPVoNq+IUy2Ms7MicRQkNuKrwB/g+xwkvnitv4989OhRW3HxujU4eLrgdDpK4IrFRBwCAc+m80yJyiaRWB7ii+guRF0vXvkCJA697h+aCu7dax/ETzc+gArL8DOOT93uieVQaAYuwgYCLWgJ7XwhcApCcFutMSNIKv14BPwBBLL6amF1IFEzlOHJIKYnuAJCecKfw4pgubA0GW9+QYMxef+B/QvWCgInKARE2P/8iv73kCiRUSKjiBIZJTJKZBT/BVW4TPqo03KPAAAAAElFTkSuQmCC'
    Local $bString = _WinAPI_Base64Decode($b0png)
    If @error Then Return SetError(1, 0, 0)
    $bString = Binary($bString)
    If $bSaveBinary Then
        Local Const $hFile = FileOpen($sSavePath & "\b0.png", 18)
        If @error Then Return SetError(2, 0, $bString)
        FileWrite($hFile, $bString)
        FileClose($hFile)
    EndIf
    Return $bString
EndFunc   ;==>_b0png

Func _b2png($bSaveBinary = False, $sSavePath = @ScriptDir)
    Local $b2png
    $b2png &= 'iVBORw0KGgoAAAANSUhEUgAAAFIAAAAxCAMAAAB+kg5dAAACalBMVEX///8AAAA/P0EFBQU/P0EpKCg5OTsoJiY9PT85OTs5OTsODg4GBgYGBgY7Oz08PD4/P0ERERE/P0E/P0E/P0E/P0EzMzU/P0E/P0E+PkA/P0EDAwMFBQUQEBAVFRU5OTsEBAQuLjAXFxgXFxgEBAQSEhIEBAQMDA0ODg4hISITExMiIiMEBAQDAwMDAwMhISIFBQUmJCQEBAQGBgYEBAQFBQUEBAQFBQUDAwMEBAQFBQU2NjghISIFBQUKCgoPDxAFBQUGBgYDAwMPDw8GBgYEBAQEBAQSEhIGBgYNDQ0DAwMWFhc6OjwFBQUfHyAFBQUtLS4ICAgSEhIGBgYfHyA8PD4FBQUJCQkPDw82NjgDAwMEBAQhISI8PD4HBQUFBQUNDQ4UFBU6Ojs+PkAGBgYICAgODg4REREDAwM+PkAUFBUPDw8REREwMDE+PkA/P0EgICASEhMVFRU+PkA/P0EyMjQeHh8QEBAREREhISI8PD4/P0E/P0E3NzglJSYZGRoTExMFBQUUFBQbGxsnJyg7Oz0/P0E/P0EGBgYKCgoODg86OjwHBwcJCQkMDAwNDQ0ODg4qKioPDw8QEBALCwsoKCgGBgYJCQkVFRUPDg4HBwcNDAwAAAASEhIICAgiIiIjIyMRERETEhIZGRkdHR0cHBwKCgoFBQUYGBgEBAQWFhYTExMBAQECAgIDAwMKCQkWFRUXFxcpKSkgICAMCwsSEREkJCQfHx8ZGBgUFBQVFBQaGhoQDw8eHh4aGRkREBAcGxslJSUpKCgnJycUExMmJiYXFhYODQ0mJSUbGxshISEIBwciISEYFxeZK10PAAAAjnRSTlMAAKEAAACnAEeZovz3+GxIBvyNbgGdrwg/GgQZpPfiEmOa4Tpt8OMj8q3vMMsoDc3gAGTg5GMN6QZ370jD0/PzBusf+dBur/Gl2injim7RzrjX8m7Q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kU0/HgmRf37PPCcl6Fp/f8OK6DrLvpZeFFNATiK+8+trrsXaSeuNNIaVACBuytza8/U6sk6Tefe99IYVgIfvgw48+/iTWQcaabfn0s8+/WC1DtPqrr7/59rvvt8S6kH4bN61ds37fEK1fs3bTRtICZMQWW+xfvzSO9/+fiBMAAAAASUVORK5CYII='
    Local $bString = _WinAPI_Base64Decode($b2png)
    If @error Then Return SetError(1, 0, 0)
    $bString = Binary($bString)
    If $bSaveBinary Then
        Local Const $hFile = FileOpen($sSavePath & "\b2.png", 18)
        If @error Then Return SetError(2, 0, $bString)
        FileWrite($hFile, $bString)
        FileClose($hFile)
    EndIf
    Return $bString
EndFunc   ;==>_b2png

Func _b1png($bSaveBinary = False, $sSavePath = @ScriptDir)
    Local $b1png
    $b1png &= 'iVBORw0KGgoAAAANSUhEUgAAAFIAAAAxCAYAAABJTP5vAAAMfklEQVR4Xu2bC4xVxf3HvzPn3IUFYWFdXJ7iUlcqWhUNFbVoTUQipVZibesjsZWqVYylFusf/zZtKdVQIQ22VC01JbZSUBsftCKoNNX4QDQUGl9IKU8VXWWXZe/u3ntmpjN35uSXO3P21DUhYWsn+WbOmeTMuecz39+Zx53Dxr0ikJFYkGeL+2V+HYeZFCgpT5KOA8HPfcW5ELOhcZJfTuAPO5jZQKSfk6jcg8iyYMa5EEN4UVbuO7MPgCQROJGRMw9qCDMESQCyADrFNg/ESX0GpPQg+krSYw+izKgTceAcghFlACyYY5KFS7At/MMdJLnMQSJoCQncB+rECSY5M/bckwWxkCMCahWG+GGQckJaeADLJEQ2D8xAMEFhTo4kkQsJWI1TPzomoASyzyVh5AEsOXV7xih7MC1gz5HB+9AD2N9A9DRI62ytSVrHag2x5X0jOVCtWtu0Nmo9q9Vuyr0oYz40yiGz3pEsCGeCWGtyp4FaM7UuMTCZKCNqeRes1El9Wd9I/VRNbaNoGNGoosJZAGZpPaT1iFaH48D9V4N3zPIcGQcQSUdrzYOSzf23PIsBL6xGzbbNQFKGkAJKqQBkVYHKoM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1cSzHAT1a1Q8liz8i3XrQBefxkQyaECdejhRjEw4fOAnk7CrK4zvs1totpF8HyIRgQxDW3u7UTznBls6ztC66J0Wx+SMrBv'
    $b1png &= 'V2Xdr48luwbZeHT6Z1u729b3qAvlrooIYJfnRCPqbLwVDZGzdZk6JNuT/VnrbMSFSRj1GRP2Qy38vpEclP200RTPuelfyUHr7gGgcFLeZvxg96kAJQ8y9ezuJqu1nuzDW58lPQ8N+4y8MC57IINFC3Ik5SJnc6Wg4dF/+Wb8UCJ0Y+hIRrDAA1dmO5Ig9v3PQwgmqUzlAUTp1Yc4nDMQTG+dMqJQ+FR+sCRzP1gKCgkmy7rxp+sTuvzvEnO+RaQw94AqP/Q/fR91hhADkDkw6Zxy+b/PjMMU594whAsPmuhDEPNhhuch+Jz0b7lT2F9wYXECAAAAAElFTkSuQmCC'
    Local $bString = _WinAPI_Base64Decode($b1png)
    If @error Then Return SetError(1, 0, 0)
    $bString = Binary($bString)
    If $bSaveBinary Then
        Local Const $hFile = FileOpen($sSavePath & "\b1.png", 18)
        If @error Then Return SetError(2, 0, $bString)
        FileWrite($hFile, $bString)
        FileClose($hFile)
    EndIf
    Return $bString
EndFunc   ;==>_b1png

Func _WinAPI_Base64Decode($sB64String)
    Local $aCrypt = DllCall("Crypt32.dll", "bool", "CryptStringToBinaryA", "str", $sB64String, "dword", 0, "dword", 1, "ptr", 0, "dword*", 0, "ptr", 0, "ptr", 0)
    If @error Or Not $aCrypt[0] Then Return SetError(1, 0, "")
    Local $bBuffer = DllStructCreate("byte[" & $aCrypt[5] & "]")
    $aCrypt = DllCall("Crypt32.dll", "bool", "CryptStringToBinaryA", "str", $sB64String, "dword", 0, "dword", 1, "struct*", $bBuffer, "dword*", $aCrypt[5], "ptr", 0, "ptr", 0)
    If @error Or Not $aCrypt[0] Then Return SetError(2, 0, "")
    Return DllStructGetData($bBuffer, 1)
EndFunc   ;==>_WinAPI_Base64Decode
0 is opaque, -1 is fully transparent! Edited by UEZ

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Thanks for the code adjustment! It looks to give me the code I need to wrangle with.

As for why I want it... I'm adding some buttons that won't normally be used, but that I still want available. So think 1 image instead of 2 in the example you posted. Default = 50%, Hover = 100%, and Pressed = 0%.

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