JonBMN Posted July 15, 2013 Posted July 15, 2013 (edited) 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 July 17, 2013 by JonBMN
Solution FireFox Posted July 16, 2013 Solution Posted July 16, 2013 (edited) Hi,Try this :expandcollapse popup#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() EndFuncEdit: Added indents.Br, FireFox. Edited July 16, 2013 by FireFox
JonBMN Posted July 17, 2013 Author Posted July 17, 2013 Thank you for the reply, I see what you did with the while loop and the timer. Great thinking, as I would only have thought to use sleep(). Thank you for the knowledge @FireFox.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now