Jump to content

[SOLVED ]Embed PNG in exe file


Recommended Posts

Hi community

I'd like to embed .PNG files in order to use them in a GUI. My GUI is based on the excellent Metro UDF and more likely in the case I need on Metro with image button UDF written by DevMode 

_Metro_CreateButtonImage($Text,$ImageMap,$Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF") is the function that uses the PNG image

Both Resources UDF from Zedna and ResourcesEx from guiness seem out of date. And to be honnest, I never was able to use it correctly

At the moment I got around the image file embedding by converting them to ICO, using their index and the function GUICtrlSetImage

So … I need to embed a PNG and use it in a function

Code from UEZ looks very cool but the example delivered call a <memory.au3> that I am unable to find
Moreover, I Don't really understand how to code with his method
 

 

Edited by Ebola57
Link to comment
Share on other sites

29 minutes ago, UEZ said:

Do you have a short example script and files?

Sure !

Here's a short part of my script. I will make it shorter if it's confusing, because, this part is in the ùain code that became "fat"
A loop creates n buttons with both on hover picture and normal one (special treatment for Configuration button that have to be at the Bottom of the gui)

Embeded pictures are robot_on.png, robot_off.png, Excel_on.png, Excel_off.png ... aso

Global $aMenu_Name [5] [2] = [["","robot"], _ 
                            ["","Excel"], _ 
                            ["","Spice"], _ 
                            ["","Statistiques"], _
                            ["","Configuration"]]
    
    
; Définitition des boutons 'Off' grisés
For $i = 0 To $Nb_of_Menu - 1
    If $aMenu_Button [$i + 1] [1] == "Configuration" Then
        $sFont_Size = 10
        $aMenu_Button [$i + 1] [3] = _Metro_CreateButtonImage2 ( $aMenu_Button [$i + 1] [0], $aMenu_Button [$i + 1] [1], _Metro_ButtonImageRect ( @ScriptDir & "/" & $aMenu_Button [$i + 1] [1] & "_Off.png" ) _
        , _Metro_ButtonImageRect(@ScriptDir & "/" & $aMenu_Button [$i + 1] [1] & "_On.png"), $Left + $Menu_But_Step * ($i - 1), $Top + $Height - 102, $Menu_But_Width, $Menu_But_Height, $BG_Deep, "0xFFFFFF", $sFont_Name, $sFont_Size )
        $sFont_Size = 12                
    Else
        $aMenu_Button [$i + 1] [3] = _Metro_CreateButtonImage2 ( $aMenu_Button [$i + 1] [0], $aMenu_Button [$i + 1] [1], _Metro_ButtonImageRect ( @ScriptDir & "/" & $aMenu_Button [$i + 1] [1] & "_Off.png" ) _
        , _Metro_ButtonImageRect(@ScriptDir & "/" & $aMenu_Button [$i + 1] [1] & "_On.png"), $Left + $Menu_But_Step * $i, $Top, $Menu_But_Width, $Menu_But_Height, $BG_Deep, "0xFFFFFF", $sFont_Name, $sFont_Size )
    EndIf
Next

This below function mae a map structure of a given image

  _Metro_ButtonImageRect ( @ScriptDir & "/" & $aMenu_Button [$i + 1] [1] & "_Off.png" ) create a map structure of an input image file

This function add the image to the button (I slightly modified teh original in order to get an on hover picture of different color )

$aMenu_Button [$i + 1] [3] = _Metro_CreateButtonImage2 ( $aMenu_Button [$i + 1] [0], $aMenu_Button [$i + 1] [1], _Metro_ButtonImageRect ( @ScriptDir & "/" & $aMenu_Button [$i + 1] [1] & "_Off.png" )

Visual of what it does

image.png.57a65da013eaab399d90d6415c5761c8.png

"robot" is selected button. Excel has on hover

Excel_Off.png

Excel_On.png

robot_Off.png

robot_On.png

Edited by Ebola57
Link to comment
Share on other sites

I used the Example.au3 file and added two functions.

1) _Metro_CreateButtonFromImage() -> should create the button using an image

2) _Metro_CreateButtonWithIcon() -> should add an icon to the button to the left side

 

I added the images using File to Base64 String' Code Generator.

Here the code:

; ===============================================================================================================================
; Name ..........: MetroGUI UDF Example
; Version .......: v5.1
; Author ........: BB_19
; ===============================================================================================================================

;!Highly recommended for improved overall performance and responsiveness of the GUI effects etc.! (after compiling):
#AutoIt3Wrapper_Run_Au3Stripper=y
#Au3Stripper_Parameters=/so /rm /pe

;YOU NEED TO EXCLUDE FOLLOWING FUNCTIONS FROM AU3STRIPPER, OTHERWISE IT WON'T WORK:
#Au3Stripper_Ignore_Funcs=_iHoverOn,_iHoverOff,_iFullscreenToggleBtn,_cHvr_CSCP_X64,_cHvr_CSCP_X86,_iControlDelete
;Please not that Au3Stripper will show errors. You can ignore them as long as you use the above Au3Stripper_Ignore_Funcs parameters.

;Required if you want High DPI scaling enabled. (Also requries _Metro_EnableHighDPIScaling())
#AutoIt3Wrapper_Res_HiDpi=y
; ===============================================================================================================================

#NoTrayIcon
#include "MetroGUI-UDF\MetroGUI_UDF.au3"
#include "MetroGUI-UDF\_GUIDisable.au3" ; For dim effects when msgbox is displayed
#include <GUIConstants.au3>

;=======================================================================Creating the GUI===============================================================================
;Enable high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp.
_Metro_EnableHighDPIScaling() ; Note: Requries "#AutoIt3Wrapper_Res_HiDpi=y" for compiling. To see visible changes without compiling, you have to disable dpi scaling in compatibility settings of Autoit3.exe

;Set Theme
_SetTheme("DarkTeal") ;See MetroThemes.au3 for selectable themes or to add more

;Create resizable Metro GUI
$Form1 = _Metro_CreateGUI("Example", 500, 300, -1, -1, True)

;Add/create control buttons to the GUI
$Control_Buttons = _Metro_AddControlButtons(True, True, True, True, True) ;CloseBtn = True, MaximizeBtn = True, MinimizeBtn = True, FullscreenBtn = True, MenuBtn = True

;Set variables for the handles of the GUI-Control buttons. (Above function always returns an array this size and in this order, no matter which buttons are selected.)
$GUI_CLOSE_BUTTON = $Control_Buttons[0]
$GUI_MAXIMIZE_BUTTON = $Control_Buttons[1]
$GUI_RESTORE_BUTTON = $Control_Buttons[2]
$GUI_MINIMIZE_BUTTON = $Control_Buttons[3]
$GUI_FULLSCREEN_BUTTON = $Control_Buttons[4]
$GUI_FSRestore_BUTTON = $Control_Buttons[5]
$GUI_MENU_BUTTON = $Control_Buttons[6]
;======================================================================================================================================================================

;Create  Buttons
Global $hImage_Btn1 = _GDIPlus_BitmapCreateFromMemory(_Button1())
$Button1 = _Metro_CreateButtonFromImage($hImage_Btn1, 37, 235)
Global $hImage_Icon1 = _GDIPlus_BitmapCreateFromMemory(_Icon1())
$Button2 = _Metro_CreateButtonWithIcon("Excel", $hImage_Icon1, 190, 245, 130, 35)

$Button3 = _Metro_CreateButtonEx2("Button Style 3", 340, 245, 115, 35)

;Create Checkboxes
$Checkbox1 = _Metro_CreateCheckbox("Checkbox 1", 30, 70, 125, 30)
$Checkbox2 = _Metro_CreateCheckboxEx("Checkbox 2", 30, 107, 125, 30)
$Checkbox3 = _Metro_CreateCheckboxEx2("Checkbox 3", 29, 142, 125, 30)
;Set status to checked
_Metro_CheckboxCheck($Checkbox1, True)
_Metro_CheckboxCheck($Checkbox2, True)
_Metro_CheckboxCheck($Checkbox3, True)

;Create 3 Radios that are assigned to Radio Group 1
$Radio1 = _Metro_CreateRadio("1", "Radio 1", 180, 70, 100, 30)
$Radio2 = _Metro_CreateRadio("1", "Radio 2", 180, 110, 100, 30)
$Radio3 = _Metro_CreateRadioEx("1", "Radio 3", 180, 150, 100, 30) ;Style with colored checkmark
_Metro_RadioCheck("1", $Radio1) ;check $Radio1 which is assigned to radio group "1" and uncheck any other radio in group "1"

;Create Toggles
$Toggle1 = _Metro_CreateToggle("Toggle 1", 320, 70, 130, 30)
$Toggle2 = _Metro_CreateToggleEx("Toggle 2", 322, 107, 128, 30)
$Toggle3 = _Metro_CreateOnOffToggle("Enabled", "Disabled", 320, 144, 130, 30) ; Creates a toggle with different texts for on/off. Alternatively you can use _Metro_CreateOnOffToggleEx for the secondary toggle style.

;Create Progressbar
$Progress1 = _Metro_CreateProgress(100, 195, 300, 26)

;Set resizing options for the controls so they don't change in size or position. This can be customized to match your gui perfectly for resizing. See AutoIt Help file.
GUICtrlSetResizing($Button1, 768 + 8)
GUICtrlSetResizing($Button2, 768 + 8)
GUICtrlSetResizing($Button3, 768 + 8)
GUICtrlSetResizing($Checkbox1, 768 + 2 + 32)
GUICtrlSetResizing($Checkbox2, 768 + 2 + 32)
GUICtrlSetResizing($Checkbox3, 768 + 2 + 32)
GUICtrlSetResizing($Radio1, 768 + 2 + 32)
GUICtrlSetResizing($Radio2, 768 + 2 + 32)
GUICtrlSetResizing($Radio3, 768 + 2 + 32)
GUICtrlSetResizing($Toggle1, 768 + 2 + 32)
GUICtrlSetResizing($Toggle2, 768 + 2 + 32)
GUICtrlSetResizing($Toggle3, 768 + 2 + 32)
GUICtrlSetResizing($Progress1[0], 768 + 2 + 32)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE, $GUI_CLOSE_BUTTON
            _GDIPlus_ImageDispose($hImage_Btn1)
            _GDIPlus_ImageDispose($hImage_Icon1)
            _Metro_GUIDelete($Form1) ;Delete GUI/release resources, make sure you use this when working with multiple GUIs!
            Exit
        Case $GUI_MAXIMIZE_BUTTON
            GUISetState(@SW_MAXIMIZE, $Form1)
        Case $GUI_MINIMIZE_BUTTON
            GUISetState(@SW_MINIMIZE, $Form1)
        Case $GUI_RESTORE_BUTTON
            GUISetState(@SW_RESTORE, $Form1)
        Case $GUI_FULLSCREEN_BUTTON, $GUI_FSRestore_BUTTON
            ConsoleWrite("Fullscreen toggled" & @CRLF) ;Fullscreen toggle is processed automatically when $ControlBtnsAutoMode is set to true, otherwise you need to use here _Metro_FullscreenToggle($Form1)
        Case $GUI_MENU_BUTTON
            ;Create an Array containing menu button names
            Local $MenuButtonsArray[5] = ["Themes Demo", "Settings", "About", "Contact", "Exit"]
            ; Open the metro Menu. See decleration of $MenuButtonsArray above.
            Local $MenuSelect = _Metro_MenuStart($Form1, 150, $MenuButtonsArray)
            Switch $MenuSelect ;Above function returns the index number of the selected button from the provided buttons array.
                Case "0"
                    ConsoleWrite("Returned 0 = Starting themes demo. Please note that the window border colors are not updated during this demo." & @CRLF)
                    _ThemesDemo()
                Case "1"
                    ConsoleWrite("Returned 1 = Settings button clicked." & @CRLF)
                Case "2"
                    ConsoleWrite("Returned 2 = About button clicked." & @CRLF)
                Case "3"
                    ConsoleWrite("Returned 3 = Contact button clicked." & @CRLF)
                Case "4"
                    ConsoleWrite("Returned 4 = Exit button clicked." & @CRLF)
                    _Metro_GUIDelete($Form1)
                    Exit
            EndSwitch
        Case $Button3
            _GUIDisable($Form1, 0, 30) ;For better visibility of the MsgBox on top of the first GUI.
            _Metro_MsgBox(0, "Metro MsgBox Example", "Try a rightclick on this button for rightclick menu demo.", 400, 11, $Form1) ; with 3 secs timeout
            _GUIDisable($Form1)
        Case $GUI_EVENT_SECONDARYDOWN ;Demo for starting rightclick menu
            Local $aCInfo = GUIGetCursorInfo($Form1)
            If $aCInfo[4] = $Button3 Then
                ;Create an Array containing menu button names
                Local $MenuButtonsArray[4] = ["Button 1", "Button 2", "Button 3", "Button 4"]
                ; Open the rightclick Menu. See decleration of $MenuButtonsArray above.
                Local $MenuSelect = _Metro_RightClickMenu($Form1, 300, $MenuButtonsArray)
                Switch $MenuSelect ;Above function returns the index number of the selected button from the provided buttons array.
                    Case "0"
                        ConsoleWrite("Returned 0 = Button 1 clicked." & @CRLF)
                    Case "1"
                        ConsoleWrite("Returned 1 = Button 2 clicked." & @CRLF)
                    Case "2"
                        ConsoleWrite("Returned 2 = Button 3 clicked." & @CRLF)
                    Case "3"
                        ConsoleWrite("Returned 3 = Button 4 clicked." & @CRLF)
                EndSwitch
            EndIf
        Case $Button2
            _GUIDisable($Form1, 0, 30) ;For better visibility of the MsgBox on top of the first GUI.
            _Metro_MsgBox(0, "Metro MsgBox Example", "Button 2 clicked. (Button with 3 secs timeout)", 400, 11, $Form1, 3) ; with 3 secs timeout
            _GUIDisable($Form1)
        Case $Button1
            _GUIDisable($Form1, 0, 30)
            Local $mInput = _Metro_InputBox("Please enter your name.", 11, "", False, True)
            If Not @error Then _Metro_MsgBox(0, "Metro MsgBox Example", "Hello " & $mInput & ", Press ok to set the progressbar.", 350, 11, $Form1)
            _GUIDisable($Form1)
            For $i = 0 To 85 Step +2
                Sleep(1)
                _Metro_SetProgress($Progress1, $i)
            Next
            _GUIDisable($Form1, 0, 30)
            Local $Select_YesNo = _Metro_MsgBox(4, "Metro MsgBox Example", "Select yes to create a second GUI.", 350, 11, $Form1)
            If $Select_YesNo = "Yes" Then _SecondGUI()
            _GUIDisable($Form1)
        Case $Toggle1
            If _Metro_ToggleIsChecked($Toggle1) Then
                _Metro_ToggleUnCheck($Toggle1)
                ConsoleWrite("Toggle unchecked!" & @CRLF)
            Else
                _Metro_ToggleCheck($Toggle1)
                ConsoleWrite("Toggle checked!" & @CRLF)
            EndIf
        Case $Toggle2
            If _Metro_ToggleIsChecked($Toggle2) Then
                _Metro_ToggleUnCheck($Toggle2)
                ConsoleWrite("Toggle unchecked!" & @CRLF)
            Else
                _Metro_ToggleCheck($Toggle2)
                ConsoleWrite("Toggle checked!" & @CRLF)
            EndIf
        Case $Toggle3
            If _Metro_ToggleIsChecked($Toggle3) Then
                _Metro_ToggleUnCheck($Toggle3)
                ConsoleWrite("Disabled!" & @CRLF)
            Else
                _Metro_ToggleCheck($Toggle3)
                ConsoleWrite("Enabled!" & @CRLF)
            EndIf
        Case $Checkbox1
            If _Metro_CheckboxIsChecked($Checkbox1) Then
                _Metro_CheckboxUnCheck($Checkbox1)
                ConsoleWrite("Checkbox unchecked!" & @CRLF)
            Else
                _Metro_CheckboxCheck($Checkbox1)
                ConsoleWrite("Checkbox checked!" & @CRLF)
            EndIf
        Case $Checkbox2
            If _Metro_CheckboxIsChecked($Checkbox2) Then
                _Metro_CheckboxUnCheck($Checkbox2)
                ConsoleWrite("Checkbox unchecked!" & @CRLF)
            Else
                _Metro_CheckboxCheck($Checkbox2)
                ConsoleWrite("Checkbox checked!" & @CRLF)
            EndIf
        Case $Checkbox3
            If _Metro_CheckboxIsChecked($Checkbox3) Then
                _Metro_CheckboxUnCheck($Checkbox3)
                ConsoleWrite("Checkbox unchecked!" & @CRLF)
            Else
                _Metro_CheckboxCheck($Checkbox3)
                ConsoleWrite("Checkbox checked!" & @CRLF)
            EndIf
        Case $Radio1
            _Metro_RadioCheck(1, $Radio1)
            ConsoleWrite("Radio 1 selected!" & @CRLF)
        Case $Radio2
            _Metro_RadioCheck(1, $Radio2)
            ConsoleWrite("Radio 2 selected = " & _Metro_RadioIsChecked(1, $Radio2) & @CRLF)
        Case $Radio3
            _Metro_RadioCheck(1, $Radio3)
            ConsoleWrite("Radio 3 (ExStyle) selected!" & @CRLF)
    EndSwitch
WEnd


Func _SecondGUI()
    Local $Form2 = _Metro_CreateGUI("Example2", 600, 400, -1, -1, True)

    ;Add control buttons
    Local $Control_Buttons_2 = _Metro_AddControlButtons(True, True, True, True)
    Local $GUI_CLOSE_BUTTON = $Control_Buttons_2[0]
    Local $GUI_MAXIMIZE_BUTTON = $Control_Buttons_2[1]
    Local $GUI_RESTORE_BUTTON = $Control_Buttons_2[2]
    Local $GUI_MINIMIZE_BUTTON = $Control_Buttons_2[3]

    Local $Button1 = _Metro_CreateButton("Close", 250, 340, 100, 40)
    GUICtrlSetResizing($Button1, 768 + 8)
    GUISetState(@SW_SHOW)

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE, $Button1, $GUI_CLOSE_BUTTON
                _Metro_GUIDelete($Form2) ;Delete GUI/release resources, make sure you use this when working with multiple GUIs!
                Return 0
            Case $GUI_MAXIMIZE_BUTTON
                GUISetState(@SW_MAXIMIZE, $Form2)
            Case $GUI_MINIMIZE_BUTTON
                GUISetState(@SW_MINIMIZE, $Form2)
            Case $GUI_RESTORE_BUTTON
                GUISetState(@SW_RESTORE, $Form2)
        EndSwitch
    WEnd
EndFunc   ;==>_SecondGUI


Func _ThemesDemo() ;Loop through all themes by recreating all controls
    Local $ThemesArray[25] = ["DarkMidnightTeal", "DarkMidnightBlue", "DarkMidnightCyan", "DarkMidnight", "DarkTeal", "DarkBlueV2", "DarkBlue", "DarkCyan", "DarkRuby", "DarkGray", "DarkGreen", "DarkGreenV2", "DarkPurple", "DarkAmber", "DarkOrange", "LightTeal", "LightGray", "LightBlue", "LightCyan", "LightGreen", "LightRed", "LightOrange", "LightPurple", "LightPink", "DarkTealV2"]
    For $i = 0 To 24
        GUISetState($Form1, @SW_LOCK)
        ConsoleWrite($ThemesArray[$i] & @CRLF)
        _SetTheme($ThemesArray[$i]) ;See MetroThemes.au3 for selectable themes or to add more
        GUICtrlDelete($Button1)
        GUICtrlDelete($Button2)
        GUICtrlDelete($Button3)
        GUICtrlDelete($Checkbox1)
        GUICtrlDelete($Checkbox2)
        GUICtrlDelete($Checkbox3)
        GUICtrlDelete($Radio1)
        GUICtrlDelete($Radio2)
        GUICtrlDelete($Radio3)
        GUICtrlDelete($Toggle1)
        GUICtrlDelete($Toggle2)
        GUICtrlDelete($Toggle3)
        GUICtrlDelete($Progress1[0])
        GUICtrlDelete($GUI_CLOSE_BUTTON)
        GUICtrlDelete($GUI_MAXIMIZE_BUTTON)
        GUICtrlDelete($GUI_RESTORE_BUTTON)
        GUICtrlDelete($GUI_MINIMIZE_BUTTON)
        GUICtrlDelete($GUI_FULLSCREEN_BUTTON)
        GUICtrlDelete($GUI_FSRestore_BUTTON)
        GUICtrlDelete($GUI_MENU_BUTTON)
        GUISetBkColor($GUIThemeColor, $Form1)
        $Control_Buttons = _Metro_AddControlButtons(True, True, True, True, True)
        $GUI_CLOSE_BUTTON = $Control_Buttons[0]
        $GUI_MAXIMIZE_BUTTON = $Control_Buttons[1]
        $GUI_RESTORE_BUTTON = $Control_Buttons[2]
        $GUI_MINIMIZE_BUTTON = $Control_Buttons[3]
        $GUI_FULLSCREEN_BUTTON = $Control_Buttons[4]
        $GUI_FSRestore_BUTTON = $Control_Buttons[5]
        $GUI_MENU_BUTTON = $Control_Buttons[6]
        $Button1 = _Metro_CreateButton("Button Style 1", 50, 245, 115, 40)
        $Button2 = _Metro_CreateButtonEx("Button Style 2", 195, 245, 115, 40)
        $Button3 = _Metro_CreateButtonEx2("Button Style 3", 340, 245, 115, 40)
        $Checkbox1 = _Metro_CreateCheckbox("Checkbox 1", 30, 70, 125, 30)
        $Checkbox2 = _Metro_CreateCheckboxEx("Checkbox 2", 30, 107, 125, 30)
        $Checkbox3 = _Metro_CreateCheckboxEx2("Checkbox 3", 29, 142, 125, 30)
        _Metro_CheckboxCheck($Checkbox1, True)
        _Metro_CheckboxCheck($Checkbox2, True)
        _Metro_CheckboxCheck($Checkbox3, True)
        $Radio1 = _Metro_CreateRadio("1", "Radio 1", 180, 70, 100, 30)
        $Radio2 = _Metro_CreateRadio("1", "Radio 2", 180, 110, 100, 30)
        $Radio3 = _Metro_CreateRadioEx("1", "Radio 3", 180, 150, 100, 30)
        _Metro_RadioCheck("1", $Radio1)
        $Toggle1 = _Metro_CreateToggle("Toggle 1", 320, 70, 130, 30)
        $Toggle2 = _Metro_CreateToggleEx("Toggle 2", 322, 107, 128, 30)
        $Toggle3 = _Metro_CreateOnOffToggle("Enabled", "Disabled", 320, 144, 130, 30)
        $Progress1 = _Metro_CreateProgress(100, 195, 300, 26)
        GUICtrlSetResizing($Button1, 768 + 8)
        GUICtrlSetResizing($Button2, 768 + 8)
        GUICtrlSetResizing($Button3, 768 + 8)
        GUICtrlSetResizing($Checkbox1, 768 + 2 + 32)
        GUICtrlSetResizing($Checkbox2, 768 + 2 + 32)
        GUICtrlSetResizing($Checkbox3, 768 + 2 + 32)
        GUICtrlSetResizing($Radio1, 768 + 2 + 32)
        GUICtrlSetResizing($Radio2, 768 + 2 + 32)
        GUICtrlSetResizing($Radio3, 768 + 2 + 32)
        GUICtrlSetResizing($Toggle1, 768 + 2 + 32)
        GUICtrlSetResizing($Toggle2, 768 + 2 + 32)
        GUICtrlSetResizing($Toggle3, 768 + 2 + 32)
        GUICtrlSetResizing($Progress1[0], 768 + 2 + 32)
        GUISetState($Form1, @SW_UNLOCK)
        Sleep(1500)
    Next
EndFunc   ;==>_ThemesDemo


Func _Metro_CreateButtonFromImage($hImage, $Left, $Top, $BG_Color = $ButtonBKColor, $FrameColor = "0xFFFFFF", $DisableColor = 0x40000000)
    Local $Button_Array[16]

    Local $aDim = _GDIPlus_ImageGetDimension($hImage)
    If @error Then Return 0

    Local $Width = $aDim[0]
    Local $Height = $aDim[1]

    ;HighDPI Support
    Local $btnDPI = _HighDPICheck()
    If $HIGHDPI_SUPPORT Then
        $Left = Round($Left * $gDPI)
        $Top = Round($Top * $gDPI)
        $Width = Round($aDim[0] * $gDPI)
        $Height = Round($aDim[1] * $gDPI)
    EndIf

    $Button_Array[1] = False ; Set hover OFF
    $Button_Array[3] = "2" ; Type
    $Button_Array[15] = GetCurrentGUI()

    ;Calculate Framesize
    Local $FrameSize = Round(4 * $btnDPI)
    If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1

    ;Set Colors
    $BG_Color = "0xFF" & Hex($BG_Color, 6)
    $FrameColor = "0xFF" & Hex($FrameColor, 6)
    Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize)
    Local $hBrush_Btn_Disable = _GDIPlus_BrushCreateSolid($DisableColor)
    ;Create Button graphics
    Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color) ;Default
    _GDIPlus_GraphicsDrawImageRect($Button_Graphic1[0], $hImage, 0, 0, $Width, $Height)
    Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover
    _GDIPlus_GraphicsDrawImageRect($Button_Graphic2[0], $hImage, 0, 0, $Width, $Height)
    Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled
    _GDIPlus_GraphicsDrawImageRect($Button_Graphic3[0], $hImage, 0, 0, $Width, $Height)
    _GDIPlus_GraphicsFillRect($Button_Graphic3, 0, 0, $Width, $Height, $hBrush_Btn_Disable)

    ;Add frame
    _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor)

    ;Release created objects
    _GDIPlus_PenDispose($Pen_BTN_FrameHoverColor)
    _GDIPlus_BrushDispose($hBrush_Btn_Disable)

    ;Set graphic and return Bitmap handle
    $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height)
    $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1)
    $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False)
    $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False)

    ;For GUI Resizing
    GUICtrlSetResizing($Button_Array[0], 768)
    _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array))

    Return $Button_Array[0]
EndFunc   ;==>_Metro_CreateButtonFromImage

Func _Metro_CreateButtonWithIcon($Text, $hImage, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 10, $FontStyle = 1, $FrameColor = "0xFFFFFF", $DisableColor = 0x40000000)
    Local $Button_Array[16]

    Local $btnDPI = _HighDPICheck()
    ;HighDPI Support
    If $HIGHDPI_SUPPORT Then
        $Left = Round($Left * $gDPI)
        $Top = Round($Top * $gDPI)
        $Width = Round($Width * $gDPI)
        $Height = Round($Height * $gDPI)
    Else
        $Fontsize = ($Fontsize / $Font_DPI_Ratio)
    EndIf

    $Button_Array[1] = False ; Set hover OFF
    $Button_Array[3] = "2" ; Type
    $Button_Array[15] = GetCurrentGUI()

    ;Calculate Framesize
    Local $FrameSize = Round(4 * $btnDPI)
    If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1

    ;Set Colors
    $BG_Color = "0xFF" & Hex($BG_Color, 6)
    $Font_Color = "0xFF" & Hex($Font_Color, 6)
    $FrameColor = "0xFF" & Hex($FrameColor, 6)
    Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color)
    Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF"))
    Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize)
    Local $hBrush_Btn_Disable = _GDIPlus_BrushCreateSolid($DisableColor)

    Local $aDim = _GDIPlus_ImageGetDimension($hImage)
    Local $minBtn = $Width < $Height ? $Width : $Height
    Local $maxImg = $aDim[0] < $aDim ? $aDim[0] : $aDim[1]
    Local $fFactor = 1
    If $maxImg > $minBtn Then $fFactor = ($minBtn / $maxImg) * 0.8
    Local $hImage_Icon = _GDIPlus_ImageScale($hImage, $fFactor, $fFactor)
    Local $aDim2 = _GDIPlus_ImageGetDimension($hImage_Icon)
    Local $hGfx = _GDIPlus_ImageGetGraphicsContext($hImage_Icon)

    ;Create Button graphics
    Local $Button_Graphic1 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Default
    _GDIPlus_GraphicsDrawImageRect($Button_Graphic1[0], $hImage_Icon, $Width * 0.05, ($Height - $aDim2[1]) / 2, $aDim2[0], $aDim2[1])
    Local $Button_Graphic2 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Hover
    _GDIPlus_GraphicsDrawImageRect($Button_Graphic2[0], $hImage_Icon, $Width * 0.05, ($Height - $aDim2[1]) / 2, $aDim2[0], $aDim2[1])
    Local $Button_Graphic3 = _iGraphicCreate($Width, $Height, $BG_Color, 0, 5) ;Disabled
    _GDIPlus_GraphicsDrawImageRect($Button_Graphic3[0], $hImage_Icon, $Width * 0.05, ($Height - $aDim2[1]) / 2, $aDim2[0], $aDim2[1])
    _GDIPlus_GraphicsFillRect($Button_Graphic3, 0, 0, $Width, $Height, $hBrush_Btn_Disable)

    ;Create font, Set font options
    Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle)
    Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height)
    _GDIPlus_StringFormatSetAlign($hFormat, 1)
    _GDIPlus_StringFormatSetLineAlign($hFormat, 1)

    ;Draw button text
    _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor)
    _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor)
    _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis)

    ;Add frame
    _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor)

    ;Release created objects
    _GDIPlus_BrushDispose($hBrush_Btn_Disable)
    _GDIPlus_ImageDispose($hImage_Icon)
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($Brush_BTN_FontColor)
    _GDIPlus_BrushDispose($Brush_BTN_FontColorDis)
    _GDIPlus_PenDispose($Pen_BTN_FrameHoverColor)

    ;Set graphic and return Bitmap handle
    $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height)
    $Button_Array[5] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic1)
    $Button_Array[6] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic2, False)
    $Button_Array[7] = _iGraphicCreateBitmapHandle($Button_Array[0], $Button_Graphic3, False)

    ;For GUI Resizing
    GUICtrlSetResizing($Button_Array[0], 768)
    _cHvr_Register($Button_Array[0], "_iHoverOff", "_iHoverOn", "", "", _iAddHover($Button_Array))

    Return $Button_Array[0]
EndFunc   ;==>_Metro_CreateButtonWithIcon

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

Func _Button1($bSaveBinary = False, $sSavePath = @ScriptDir)
    Local $Button1
    $Button1 &= 'iVBORw0KGgoAAAANSUhEUgAAAIIAAAA0CAIAAADJ8nfCAAAe50lEQVR4Xu18B5RURf7uV3VTh+nJiSGPoEQFFVBRUXAVMAYU0dUnu2vAHHbNKLpiWBb+KooKIrorLqioKCBJRQQRRGCIwwyTA5On8+2bql5v9X/6DMJyWHff+s5ZPurcU0NV161bX/1i3W4CTMMvjeOQ8Qu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r8fubVq78bM2aLY4zEDgfyAf0Q103jp+LY07PkeSNjtrKDnv99PAcNf95dxEgR6chyYQkhHFf167bbrq578mDfuU4rlAonOrzFPYoyMpIKypv'
    $Button1 &= '+m7Dd9uKy5uDTszmRNUUZsky7dYl87yBvc8+7+wu6VppRU1tfQNAJFmtqSn9YuWyTRuLgKGEnMt5ppiA1XlCx78XfRSZqAVWjxubN27cyMzMk2ybR/UoY06X/Kze3booLg9zENJjDEyTZLeqSW5XsK21tLQsahiqolFJ0vXAli3rV6/5pq42BpwGDANyO+SAJ2k4TsPRmXALI7MtLbdo3IUnjRh2TmZ6F1VNi8XMmKlrmtvj1tyaAoA5jmlZkWjMcZiqagBvaqqLn0qsX7+xtDQMZAMDRfEl7cGx4DgN6LBFCueSEItil3vLGcP79D/lxK453TIyCzTNRaA5jsM5A5EZtyxTN4xw3cHa/fviJ2YHqqujwuAPB7qIYJgB+s+WgOPfi6aEaJzbQAjYBuxSVLWwl+525WTkutxuF7jEYAbags1NkUBAF2m4XFH6AD0IyeBcSzpqPxPHaUgqcUGGKvzlGFACtAiVxUQlC9CBrqJnoYjOfIC3wwbY4vpvw/GfLpEIAaByrhBiCX2ld4Q/docXL3FwcJ6UgP+H1vj4T5ckfGqQRIV1NPLk0v8Hfi7p+A/58H/TiyTHafilcRz/F2SpKN30Uej4AAAAAElFTkSuQmCC'
    Local $bString = _WinAPI_Base64Decode($Button1)
    If @error Then Return SetError(1, 0, 0)
    $bString = Binary($bString)
    If $bSaveBinary Then
        Local Const $hFile = FileOpen($sSavePath & "\AutoIt Logo4.png", 18)
        If @error Then Return SetError(2, 0, $bString)
        FileWrite($hFile, $bString)
        FileClose($hFile)
    EndIf
    Return $bString
EndFunc   ;==>_Button1

Func _Icon1($bSaveBinary = False, $sSavePath = @ScriptDir)
    Local $Icon1
    $Icon1 &= 'iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAACXBIWXMAAAsTAAALEwEAmpwYAAAFUUlEQVR42uWb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PXNdj+tLG6ysYK+FnYaT0c82EGJyzEZofF5o80sd9HZdb11FY2qONZw+PLA8+J13VAy/8cOOI4UzaanUhkOK4OOAbsMfKe0WbcxKYG+3VVWv2AnZa8x+XvcqIjLZ0d/iorYSTme7aJs1VFhejCRkWLOdznOGGbW6kDuo26G6gfhh704Ad86ljnbCv9gCe1GajiDUsUdqORd9AxgBnHDzjjWK/UKivwg6VeMUbZXmAmjZ6gqw4oCrcvyzI/CWyZp+yQmC1di08CrwIvOL5vXJLuXOl+wS7xM1y4gBc6XC/tE+U4IjqgX7aGa2Q4MTrs62BkxKL5SzHM7mza6XAjiHNV9lFqL0mYdPhuotB5PfwOvN2OLeCbDn/pWOc3n3Q4SZhmsORY74gvOpw0TDrsehk7nyYdEAdlY5YrhmIcx+HoG/i+XWaw2bQ9KTOY1i1wIakXpVUASzpdAKc9tj2xEJTgJvx9L1ATpFGiBHN0Jsqd/sFEsEichTJwJfGusfwfMKMfaXYLYSkQXWnz8hmcCxTqzZBwLIkVkDW8rV8k7dfyu4hC2zeIQNYQ3Q9Y5cuKKKWOKtThIPR/SOxiBaaAQ5JMelsUwawnOi7vi0l7rQjDsCejMiTxXXMzZrAk6QDwruZX9ItQCkTH50OyYmLpl5AQhZr7f6EERAKiWLx5JtcrAql+S9wnaRD7fZ8rtO0AIan8djgOJiUdIjooqaJHhFAVyB2ygk4bOsGbEP4BIM4eA8u3/o4AAAAASUVORK5CYII='
    Local $bString = _WinAPI_Base64Decode($Icon1)
    If @error Then Return SetError(1, 0, 0)
    $bString = Binary($bString)
    If $bSaveBinary Then
        Local Const $hFile = FileOpen($sSavePath & "\Excel_Off.png", 18)
        If @error Then Return SetError(2, 0, $bString)
        FileWrite($hFile, $bString)
        FileClose($hFile)
    EndIf
    Return $bString
EndFunc   ;==>_Icon1

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

 

@BBs19 feel free to add these two functions to your UDF if you want.

It should look like this:

MetroGUI.png

 

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

Link to comment
Share on other sites

  • 2 weeks later...
I was busy on another subject and I couldn't get over it until today

Also, I have to adapt your code to my needs and to understand it : that was not simple :D GDI+ isn't that simple

But I have to say, it works flawlessly ! 
 
Thank you :)
 
 
Edited by Ebola57
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...