Jump to content

[RESOLVED]_GDIPlus not drawing icons in GUI


JonBMN
 Share

Go to solution Solved by FireFox,

Recommended Posts

I'm trying to put an icon in the top of the GUI window using _GDIPlus.au3. I've tried using the Sleep(20) that has been suggested to no avail. Thank you for any and all help.

Func GUI()
Local $hImageGreen, $hImageRed, $hGraphic, $CheckRunning, $Parent, $ButtonInstall, $buttonUninstall, $ButtonStart, $ButtonStop, $ButtonConfigure
    _GDIPlus_Startup()
    $hImageRed = _GDIPlus_ImageLoadFromFile(@UserProfileDir & "\Desktop\SRRS\console\Red.png")
    $hImageGreen = _GDIPlus_ImageLoadFromFile(@UserProfileDir & "\Desktop\SRRS\console\Green.png")
    $Parent = GUICreate("Console", 345, 225)
    ConsoleWrite($hImageRed & "<-red       green->" & $hImageGreen)
    $CheckRunning = ProcessExists("test.exe")
    If $CheckRunning <> 0 Then
        GUICtrlCreateLabel("its running!", 110, 40)
        $hGraphic = _GDIPlus_GraphicsCreateFromHWND($Parent)
        Sleep(20)
        _GDIPlus_GraphicsDrawImage($hGraphic, $hImageGreen, 110, 40)
    Else
        GUICtrlCreateLabel("not running!", 108, 40)
        $hGraphic = _GDIPlus_GraphicsCreateFromHWND($Parent)
        Sleep(20)
        _GDIPlus_GraphicsDrawImage($hGraphic, $hImageRed, 110, 40)
    EndIf
    $ButtonInstall = GUICtrlCreateButton("Install", 55, 85, 70)
    $ButtonUninstall = GUICtrlCreateButton("Uninstall", 55, 125, 70)
    $ButtonStart = GUICtrlCreateButton("Start", 210, 85)
    $ButtonStop = GUICtrlCreateButton("Stop", 210, 125)
    $ButtonConfigure = GUICtrlCreateButton("Configure", 131, 165, 70)
    GUICtrlCreateLabel("Is it Running?", 110, 10)
    GUISetState(@SW_SHOW) ;shows the GUI window
Edited by JonBMN
Link to comment
Share on other sites

  • Solution

Hi,

Try this :

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

GUI()

Func GUI()
    Local $hImageGreen, $hImageRed, $hGraphic, $CheckRunning, $Parent, $ButtonInstall, $buttonUninstall, $ButtonStart, $ButtonStop, $ButtonConfigure
    Local $hTimer = 0

    _GDIPlus_Startup()
    $hImageRed = _GDIPlus_ImageLoadFromFile(@UserProfileDir & "\Desktop\SRRS\console\Red.png")
    $hImageGreen = _GDIPlus_ImageLoadFromFile(@UserProfileDir & "\Desktop\SRRS\console\Green.png")

    $Parent = GUICreate("Console", 345, 225)
    $ButtonInstall = GUICtrlCreateButton("Install", 55, 85, 70)
    $buttonUninstall = GUICtrlCreateButton("Uninstall", 55, 125, 70)
    $ButtonStart = GUICtrlCreateButton("Start", 210, 85)
    $ButtonStop = GUICtrlCreateButton("Stop", 210, 125)
    $ButtonConfigure = GUICtrlCreateButton("Configure", 131, 165, 70)
    GUICtrlCreateLabel("Is it Running?", 110, 10)
    GUISetState(@SW_SHOW, $Parent)

    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($Parent)

    While GUIGetMsg() <> $GUI_EVENT_CLOSE
        If TimerDiff($hTimer) >= 1000 Then
            $CheckRunning = ProcessExists("test.exe")
            If $CheckRunning > 0 Then
                GUICtrlCreateLabel("its running!", 110, 40)
                _GDIPlus_GraphicsDrawImage($hGraphic, $hImageGreen, 110, 40)
            Else
                GUICtrlCreateLabel("not running!", 108, 40)
                _GDIPlus_GraphicsDrawImage($hGraphic, $hImageRed, 110, 40)
            EndIf

            $hTimer = TimerInit()
        EndIf
        Sleep(10)
    WEnd

    GUIDelete($Parent)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_ImageDispose($hImageRed)
    _GDIPlus_ImageDispose($hImageGreen)
    _GDIPlus_Shutdown()
EndFunc
Edit: Added indents.

Br, FireFox.

Edited by FireFox
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

×
×
  • Create New...