Jump to content

_GDIPlus_GraphicsDrawImageRectRect Dispose ?


 Share

Recommended Posts

I am creating a very simple server ping and service monitor for a few of our servers in house to display on a monitor in our offices.

I created a simple display with icons next to each line which will show the status of a server or service, Right now I am having trouble getting the icon to change more than once, I think it is because I am not deleting the old graphic before drawing the new one.

I created a button for testing which should swap out the icon with several others each time you click the button but after the first one it stops.

Can someone help me with this?

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
 _GDIPlus_Startup ()
Global $color = 1

$SSMGUI = GUICreate("Form1", 1201, 701, -1385, 78)
GUISetBkColor(0x3c3c3c)
$GO = GUICtrlCreateButton("GO", 37, 28, 75, 25, $WS_GROUP)
$Label0 = GUICtrlCreateLabel("Test Server", 213, 71, 775, 72, $SS_CENTER)
GUICtrlSetFont(-1, 36, 400, 0, "Arial Black")
GUICtrlSetColor(-1, 0xfcfcfc)
$Label1 = GUICtrlCreateLabel("Service 1", 213, 170, 775, 45, $SS_CENTER)
GUICtrlSetFont(-1, 22, 400, 0, "Arial Black")
GUICtrlSetColor(-1, 0xfcfcfc)
$Label2 = GUICtrlCreateLabel("Service 2", 213, 225, 775, 45, $SS_CENTER)
GUICtrlSetFont(-1, 22, 400, 0, "Arial Black")
GUICtrlSetColor(-1, 0xfcfcfc)
$Label3 = GUICtrlCreateLabel("Service 3", 213, 280, 775, 45, $SS_CENTER)
GUICtrlSetFont(-1, 22, 400, 0, "Arial Black")
GUICtrlSetColor(-1, 0xfcfcfc)
$Label4 = GUICtrlCreateLabel("Service 4", 213, 335, 775, 45, $SS_CENTER)
GUICtrlSetFont(-1, 22, 400, 0, "Arial Black")
GUICtrlSetColor(-1, 0xfcfcfc)
$Label5 = GUICtrlCreateLabel("Service 5", 213, 445, 775, 45, $SS_CENTER)
GUICtrlSetFont(-1, 22, 400, 0, "Arial Black")
GUICtrlSetColor(-1, 0xfcfcfc)
$Label6 = GUICtrlCreateLabel("Service 6", 213, 500, 775, 45, $SS_CENTER)
GUICtrlSetFont(-1, 22, 400, 0, "Arial Black")
GUICtrlSetColor(-1, 0xfcfcfc)
$Label7 = GUICtrlCreateLabel("Service 7", 213, 390, 775, 45, $SS_CENTER)
GUICtrlSetFont(-1, 22, 400, 0, "Arial Black")
GUICtrlSetColor(-1, 0xfcfcfc)
$Label9 = GUICtrlCreateLabel("Service 8", 213, 555, 775, 45, $SS_CENTER)
GUICtrlSetFont(-1, 22, 400, 0, "Arial Black")
GUICtrlSetColor(-1, 0xfcfcfc)
$Label10 = GUICtrlCreateLabel("Service 9", 213, 610, 775, 45, $SS_CENTER)
GUICtrlSetFont(-1, 22, 400, 0, "Arial Black")
GUICtrlSetColor(-1, 0xfcfcfc)

GUISetState(@SW_SHOW)


$hIgreys= _GDIPlus_ImageLoadFromFile("include\img\sphere\dark-sphere-s.jpg")
$hIblues= _GDIPlus_ImageLoadFromFile("include\img\sphere\blue-sphere-s.jpg")
$hIgreens= _GDIPlus_ImageLoadFromFile("include\img\sphere\green-sphere-s.jpg")
$hIoranges= _GDIPlus_ImageLoadFromFile("include\img\sphere\orange-sphere-s.jpg")
$hIreds= _GDIPlus_ImageLoadFromFile("include\img\sphere\red-sphere-s.jpg")
$hIgreym= _GDIPlus_ImageLoadFromFile("include\img\sphere\dark-sphere-m.jpg")
$hIbluem= _GDIPlus_ImageLoadFromFile("include\img\sphere\blue-sphere-m.jpg")
$hIgreenm= _GDIPlus_ImageLoadFromFile("include\img\sphere\green-sphere-m.jpg")
$hIorangem= _GDIPlus_ImageLoadFromFile("include\img\sphere\orange-sphere-m.jpg")
$hIredm= _GDIPlus_ImageLoadFromFile("include\img\sphere\red-sphere-m.jpg")
$hGUI = _GDIPlus_GraphicsCreateFromHWND($SSMGUI)

$bigstatus = _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIbluem, 0, 0, 125, 125, 1038, 30, 125, 125)

$service1a= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIgreens, 0, 0, 55, 55, 150, 160, 55, 55)
$service2a= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIgreens, 0, 0, 55, 55, 150, 215, 55, 55)
$service3a= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIgreens, 0, 0, 55, 55, 150, 270, 55, 55)
$service4a= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIgreens, 0, 0, 55, 55, 150, 325, 55, 55)
$service5a= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIgreens, 0, 0, 55, 55, 150, 380, 55, 55)
$service6a= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIgreens, 0, 0, 55, 55, 150, 435, 55, 55)
$service7a= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIgreens, 0, 0, 55, 55, 150, 490, 55, 55)
$service8a= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIoranges, 0, 0, 55, 55, 150, 545, 55, 55)
$service9a= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIreds, 0, 0, 55, 55, 150, 600, 55, 55)

$service1b= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIgreens, 0, 0, 55, 55, 995, 160, 55, 55)
$service2b= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIgreens, 0, 0, 55, 55, 995, 215, 55, 55)
$service3b= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIgreens, 0, 0, 55, 55, 995, 270, 55, 55)
$service4b= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIgreens, 0, 0, 55, 55, 995, 325, 55, 55)
$service5b= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIgreens, 0, 0, 55, 55, 995, 380, 55, 55)
$service6b= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIgreens, 0, 0, 55, 55, 995, 435, 55, 55)
$service7b= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIgreens, 0, 0, 55, 55, 995, 490, 55, 55)
$service8b= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIoranges, 0, 0, 55, 55, 995, 545, 55, 55)
$service9b= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIreds, 0, 0, 55, 55, 995, 600, 55, 55)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
    Exit
Case $GO
        If $color = 1 Then
            $hi = $hIblues
        ElseIf $color = 2 Then
            $hi = $hIgreys
        ElseIf $color = 3 Then
            $hi = $hIreds
        ElseIf $color = 4 Then
            $hi = $hIoranges
        ElseIf $color = 5 Then
            $hi = $hIgreens
        Else
            $hi = $hIgreens
        EndIf
    $service9b= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hi, 0, 0, 55, 55, 995, 600, 55, 55)
    If $color > 6 Then
        Global $color = 1
    Else
        Global $color = $color +1
               ;I tried all of these to delete the graphic but none worked
        _GDIPlus_GraphicsDispose ($service9b)
        _GDIPlus_ImageDispose ($service9b)
        _WinAPI_DeleteObject  ($service9b)
        _GDIPlus_BitmapDispose($service9b)
        _WinAPI_RedrawWindow($SSMGUI, 0, 0, $RDW_ERASENOW)
        _WinAPI_RedrawWindow($SSMGUI, 0, 0, $RDW_UPDATENOW)
        _WinAPI_RedrawWindow($SSMGUI, 0, 0, $RDW_VALIDATE)
    EndIf
EndSwitch
WEnd

I attached the file with the icons

SS Monitor.rar

Edited by burners

~~--Feel Free to Steal my Sigs --~~FLAT LOOK____________________________________ROUNDED LOOK

Link to comment
Share on other sites

Why the main Gui start outside the screen area?.... anyway about the graphics, you don`t need to dispose every drawing in a graphic, but you need to clear the graphic before put another drawing above another.

Maybe this before re drawing another icon _GDIPlus_GraphicsClear().

PD I can`t test the script because i dont`have the images to test it.

Edited by monoscout999
Link to comment
Share on other sites

Why the main Gui start outside the screen area?.... anyway about the graphics, you don`t need to dispose every drawing in a graphic, but you need to clear the graphic before put another drawing above another.

Maybe this before re drawing another icon _GDIPlus_GraphicsClear().

PD I can`t test the script because i dont`have the images to test it.

I tried this and it did not work, I attached the graphics in my 1st post

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ScreenCapture.au3>
#include <GDIPlus.au3>
 _GDIPlus_Startup ()
Global $color = 1

$SSMGUI = GUICreate("Form1", 1201, 701, -1385, 78)
GUISetBkColor(0x3c3c3c)
$GO = GUICtrlCreateButton("GO", 37, 28, 75, 25, $WS_GROUP)
$Label0 = GUICtrlCreateLabel("Test Server", 213, 71, 775, 72, $SS_CENTER)
GUICtrlSetFont(-1, 36, 400, 0, "Arial Black")
GUICtrlSetColor(-1, 0xfcfcfc)
$Label1 = GUICtrlCreateLabel("Service 1", 213, 170, 775, 45, $SS_CENTER)
GUICtrlSetFont(-1, 22, 400, 0, "Arial Black")
GUICtrlSetColor(-1, 0xfcfcfc)
$Label2 = GUICtrlCreateLabel("Service 2", 213, 225, 775, 45, $SS_CENTER)
GUICtrlSetFont(-1, 22, 400, 0, "Arial Black")
GUICtrlSetColor(-1, 0xfcfcfc)
$Label3 = GUICtrlCreateLabel("Service 3", 213, 280, 775, 45, $SS_CENTER)
GUICtrlSetFont(-1, 22, 400, 0, "Arial Black")
GUICtrlSetColor(-1, 0xfcfcfc)
$Label4 = GUICtrlCreateLabel("Service 4", 213, 335, 775, 45, $SS_CENTER)
GUICtrlSetFont(-1, 22, 400, 0, "Arial Black")
GUICtrlSetColor(-1, 0xfcfcfc)
$Label5 = GUICtrlCreateLabel("Service 5", 213, 445, 775, 45, $SS_CENTER)
GUICtrlSetFont(-1, 22, 400, 0, "Arial Black")
GUICtrlSetColor(-1, 0xfcfcfc)
$Label6 = GUICtrlCreateLabel("Service 6", 213, 500, 775, 45, $SS_CENTER)
GUICtrlSetFont(-1, 22, 400, 0, "Arial Black")
GUICtrlSetColor(-1, 0xfcfcfc)
$Label7 = GUICtrlCreateLabel("Service 7", 213, 390, 775, 45, $SS_CENTER)
GUICtrlSetFont(-1, 22, 400, 0, "Arial Black")
GUICtrlSetColor(-1, 0xfcfcfc)
$Label9 = GUICtrlCreateLabel("Service 8", 213, 555, 775, 45, $SS_CENTER)
GUICtrlSetFont(-1, 22, 400, 0, "Arial Black")
GUICtrlSetColor(-1, 0xfcfcfc)
$Label10 = GUICtrlCreateLabel("Service 9", 213, 610, 775, 45, $SS_CENTER)
GUICtrlSetFont(-1, 22, 400, 0, "Arial Black")
GUICtrlSetColor(-1, 0xfcfcfc)

;GUIRegisterMsg($WM_PAINT, "MY_WM_PAINT")
GUISetState(@SW_SHOW)


$hIgreys= _GDIPlus_ImageLoadFromFile("include\img\sphere\dark-sphere-s.jpg")
$hIblues= _GDIPlus_ImageLoadFromFile("include\img\sphere\blue-sphere-s.jpg")
$hIgreens= _GDIPlus_ImageLoadFromFile("include\img\sphere\green-sphere-s.jpg")
$hIoranges= _GDIPlus_ImageLoadFromFile("include\img\sphere\orange-sphere-s.jpg")
$hIreds= _GDIPlus_ImageLoadFromFile("include\img\sphere\red-sphere-s.jpg")
$hIgreym= _GDIPlus_ImageLoadFromFile("include\img\sphere\dark-sphere-m.jpg")
$hIbluem= _GDIPlus_ImageLoadFromFile("include\img\sphere\blue-sphere-m.jpg")
$hIgreenm= _GDIPlus_ImageLoadFromFile("include\img\sphere\green-sphere-m.jpg")
$hIorangem= _GDIPlus_ImageLoadFromFile("include\img\sphere\orange-sphere-m.jpg")
$hIredm= _GDIPlus_ImageLoadFromFile("include\img\sphere\red-sphere-m.jpg")
$hGUI = _GDIPlus_GraphicsCreateFromHWND($SSMGUI)

 $bigstatus = _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIbluem, 0, 0, 125, 125, 1038, 30, 125, 125)

$service1a= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIgreens, 0, 0, 55, 55, 150, 160, 55, 55)
$service2a= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIgreens, 0, 0, 55, 55, 150, 215, 55, 55)
$service3a= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIgreens, 0, 0, 55, 55, 150, 270, 55, 55)
$service4a= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIgreens, 0, 0, 55, 55, 150, 325, 55, 55)
$service5a= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIgreens, 0, 0, 55, 55, 150, 380, 55, 55)
$service6a= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIgreens, 0, 0, 55, 55, 150, 435, 55, 55)
$service7a= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIgreens, 0, 0, 55, 55, 150, 490, 55, 55)
$service8a= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIoranges, 0, 0, 55, 55, 150, 545, 55, 55)
$service9a= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIreds, 0, 0, 55, 55, 150, 600, 55, 55)

 $service1b= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIgreens, 0, 0, 55, 55, 995, 160, 55, 55)
 $service2b= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIgreens, 0, 0, 55, 55, 995, 215, 55, 55)
 $service3b= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIgreens, 0, 0, 55, 55, 995, 270, 55, 55)
 $service4b= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIgreens, 0, 0, 55, 55, 995, 325, 55, 55)
 $service5b= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIgreens, 0, 0, 55, 55, 995, 380, 55, 55)
 $service6b= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIgreens, 0, 0, 55, 55, 995, 435, 55, 55)
 $service7b= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIgreens, 0, 0, 55, 55, 995, 490, 55, 55)
 $service8b= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIoranges, 0, 0, 55, 55, 995, 545, 55, 55)
 $service9b= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIreds, 0, 0, 55, 55, 995, 600, 55, 55)




While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
    Exit
Case $GO
        If $color = 1 Then
            $hi = $hIblues
        ElseIf $color = 2 Then
            $hi = $hIgreys
        ElseIf $color = 3 Then
            $hi = $hIreds
        ElseIf $color = 4 Then
            $hi = $hIoranges
        ElseIf $color = 5 Then
            $hi = $hIgreens
        Else
            $hi = $hIgreens
        EndIf
    _GDIPlus_GraphicsClear ($service9b)
    $service9b= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hi, 0, 0, 55, 55, 995, 600, 55, 55)
    If $color > 6 Then
        Global $color = 1
    Else
        Global $color = $color +1
    EndIf
EndSwitch
WEnd


Func MY_WM_PAINT($hWnd, $Msg, $wParam, $lParam)
    _WinAPI_RedrawWindow($SSMGUI, 0, 0, $RDW_UPDATENOW)
    _WinAPI_RedrawWindow($SSMGUI, 0, 0, $RDW_VALIDATE)
    Return $GUI_RUNDEFMSG
EndFunc

~~--Feel Free to Steal my Sigs --~~FLAT LOOK____________________________________ROUNDED LOOK

Link to comment
Share on other sites

I got it! you are Re Declaring $color as Global every time, so every time you create a new variable called $color and add 1 and deleting the old variable $color...

You only need to declare once at the top of the script after that you don`t need to put "global" anymore use the variable name only.

Also you don`t need to dispose every drawing in a graphic object, only the graphic object when you finish with it.

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ScreenCapture.au3>
#include <GDIPlus.au3>
 _GDIPlus_Startup ()
Global $color = 1

$SSMGUI = GUICreate("Form1", 1201, 701, -1, -1)
GUISetBkColor(0x3c3c3c)
$GO = GUICtrlCreateButton("GO", 37, 28, 75, 25, $WS_GROUP)
$Label0 = GUICtrlCreateLabel("Test Server", 213, 71, 775, 72, $SS_CENTER)
GUICtrlSetFont(-1, 36, 400, 0, "Arial Black")
GUICtrlSetColor(-1, 0xfcfcfc)
$Label1 = GUICtrlCreateLabel("Service 1", 213, 170, 775, 45, $SS_CENTER)
GUICtrlSetFont(-1, 22, 400, 0, "Arial Black")
GUICtrlSetColor(-1, 0xfcfcfc)
$Label2 = GUICtrlCreateLabel("Service 2", 213, 225, 775, 45, $SS_CENTER)
GUICtrlSetFont(-1, 22, 400, 0, "Arial Black")
GUICtrlSetColor(-1, 0xfcfcfc)
$Label3 = GUICtrlCreateLabel("Service 3", 213, 280, 775, 45, $SS_CENTER)
GUICtrlSetFont(-1, 22, 400, 0, "Arial Black")
GUICtrlSetColor(-1, 0xfcfcfc)
$Label4 = GUICtrlCreateLabel("Service 4", 213, 335, 775, 45, $SS_CENTER)
GUICtrlSetFont(-1, 22, 400, 0, "Arial Black")
GUICtrlSetColor(-1, 0xfcfcfc)
$Label5 = GUICtrlCreateLabel("Service 5", 213, 445, 775, 45, $SS_CENTER)
GUICtrlSetFont(-1, 22, 400, 0, "Arial Black")
GUICtrlSetColor(-1, 0xfcfcfc)
$Label6 = GUICtrlCreateLabel("Service 6", 213, 500, 775, 45, $SS_CENTER)
GUICtrlSetFont(-1, 22, 400, 0, "Arial Black")
GUICtrlSetColor(-1, 0xfcfcfc)
$Label7 = GUICtrlCreateLabel("Service 7", 213, 390, 775, 45, $SS_CENTER)
GUICtrlSetFont(-1, 22, 400, 0, "Arial Black")
GUICtrlSetColor(-1, 0xfcfcfc)
$Label9 = GUICtrlCreateLabel("Service 8", 213, 555, 775, 45, $SS_CENTER)
GUICtrlSetFont(-1, 22, 400, 0, "Arial Black")
GUICtrlSetColor(-1, 0xfcfcfc)
$Label10 = GUICtrlCreateLabel("Service 9", 213, 610, 775, 45, $SS_CENTER)
GUICtrlSetFont(-1, 22, 400, 0, "Arial Black")
GUICtrlSetColor(-1, 0xfcfcfc)

;GUIRegisterMsg($WM_PAINT, "MY_WM_PAINT")
GUISetState(@SW_SHOW)


$hIgreys= _GDIPlus_ImageLoadFromFile("include\img\sphere\dark-sphere-s.jpg")
$hIblues= _GDIPlus_ImageLoadFromFile("include\img\sphere\blue-sphere-s.jpg")
$hIgreens= _GDIPlus_ImageLoadFromFile("include\img\sphere\green-sphere-s.jpg")
$hIoranges= _GDIPlus_ImageLoadFromFile("include\img\sphere\orange-sphere-s.jpg")
$hIreds= _GDIPlus_ImageLoadFromFile("include\img\sphere\red-sphere-s.jpg")
$hIgreym= _GDIPlus_ImageLoadFromFile("include\img\sphere\dark-sphere-m.jpg")
$hIbluem= _GDIPlus_ImageLoadFromFile("include\img\sphere\blue-sphere-m.jpg")
$hIgreenm= _GDIPlus_ImageLoadFromFile("include\img\sphere\green-sphere-m.jpg")
$hIorangem= _GDIPlus_ImageLoadFromFile("include\img\sphere\orange-sphere-m.jpg")
$hIredm= _GDIPlus_ImageLoadFromFile("include\img\sphere\red-sphere-m.jpg")
$hGUI = _GDIPlus_GraphicsCreateFromHWND($SSMGUI)

 $bigstatus = _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIbluem, 0, 0, 125, 125, 1038, 30, 125, 125)

$service1a= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIgreens, 0, 0, 55, 55, 150, 160, 55, 55)
$service2a= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIgreens, 0, 0, 55, 55, 150, 215, 55, 55)
$service3a= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIgreens, 0, 0, 55, 55, 150, 270, 55, 55)
$service4a= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIgreens, 0, 0, 55, 55, 150, 325, 55, 55)
$service5a= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIgreens, 0, 0, 55, 55, 150, 380, 55, 55)
$service6a= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIgreens, 0, 0, 55, 55, 150, 435, 55, 55)
$service7a= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIgreens, 0, 0, 55, 55, 150, 490, 55, 55)
$service8a= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIoranges, 0, 0, 55, 55, 150, 545, 55, 55)
$service9a= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIreds, 0, 0, 55, 55, 150, 600, 55, 55)

_GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIgreens, 0, 0, 55, 55, 995, 160, 55, 55)
_GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIgreens, 0, 0, 55, 55, 995, 215, 55, 55)
_GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIgreens, 0, 0, 55, 55, 995, 270, 55, 55)
_GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIgreens, 0, 0, 55, 55, 995, 325, 55, 55)
_GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIgreens, 0, 0, 55, 55, 995, 380, 55, 55)
_GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIgreens, 0, 0, 55, 55, 995, 435, 55, 55)
_GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIgreens, 0, 0, 55, 55, 995, 490, 55, 55)
_GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIoranges, 0, 0, 55, 55, 995, 545, 55, 55)
_GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hIreds, 0, 0, 55, 55, 995, 600, 55, 55)




While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
    Exit
Case $GO
        If $color = 1 Then
            $hi = $hIblues
        ElseIf $color = 2 Then
            $hi = $hIgreys
        ElseIf $color = 3 Then
            $hi = $hIreds
        ElseIf $color = 4 Then
            $hi = $hIoranges
        ElseIf $color = 5 Then
            $hi = $hIgreens
        Else
            $hi = $hIgreens
        EndIf
    _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hi, 0, 0, 55, 55, 995, 600, 55, 55)
    If $color > 6 Then
        $color = 1
    Else
        $color += 1
        _WinAPI_RedrawWindow($SSMGUI, 0, 0, $RDW_ERASENOW)
        _WinAPI_RedrawWindow($SSMGUI, 0, 0, $RDW_UPDATENOW)
        _WinAPI_RedrawWindow($SSMGUI, 0, 0, $RDW_VALIDATE)
    EndIf
EndSwitch
WEnd


Func MY_WM_PAINT($hWnd, $Msg, $wParam, $lParam)
    _WinAPI_RedrawWindow($SSMGUI, 0, 0, $RDW_UPDATENOW)
    _WinAPI_RedrawWindow($SSMGUI, 0, 0, $RDW_VALIDATE)
    Return $GUI_RUNDEFMSG
EndFunc

EDIT: I forget to delete the variables thats contains the return from the drawing operations.. that are not handles they are only trues or falses... so is useless save them in a variable

Edited by monoscout999
Link to comment
Share on other sites

LMAO I cant believe that's what it was, I had Global because in the future I plan to make the Icon Changing into a seperate function and in order to pass variables in and out of functions they must be globally declared.

Here I thought the whole time it was because I wasn't disposing of the image, So do you think after a few hours of this running and thousands of images later will I have a memory leak?

~~--Feel Free to Steal my Sigs --~~FLAT LOOK____________________________________ROUNDED LOOK

Link to comment
Share on other sites

So do you think after a few hours of this running and thousands of images later will I have a memory leak?

no exactly i just see that you don`t dispose the images and the graphic before close the program.

you only need to dispose the images and the graphics objects(not the drawings on the graphic object).

_GDIPlus_GraphicsDispose($hGui) for the only graphic object $hGui

_GDIPlus_ImageDispose() For each image.

If you want to be sure about the memory leak do this test, change the line 103..

_GDIPlus_GraphicsDrawImageRectRect ($hGUI, $hi, 0, 0, 55, 55, 995, 600, 55, 55)

to this

_GDIPlus_GraphicsDrawImageRectRect ($hGUI, _GDIPlus_ImageLoadFromFile("include\img\sphere\dark-sphere-s.jpg"), 0, 0, 55, 55, 995, 600, 55, 55)

Open the Task Manager and check the ammount of memory that the process uses, for every click you do, the memory usage will be higher.

Undo the changes and try again.. this time you will see the memory will be constant.

Edited by monoscout999
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...