burners Posted August 4, 2011 Posted August 4, 2011 I want to create a resizable GUI but the problem is when you resize the GUI the GDI+ Graphic gets drawn twice and I cant figure out how to remove the old graphic. I worked up this quick example to show what I mean. The program is meant to be a simple full screen server monitor app. The GO button was just to make sure I could change the color of the icons, I haven't made everything resizable yet so I already know there is still a ton of work to do but this one thing is really tripping me up. expandcollapse popup#include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <ScreenCapture.au3> #include <GDIPlus.au3> Global $resx = @DesktopWidth Global $resy = @DesktopHeight Global $lastwinadded = 0 Global $color = 1 _GDIPlus_Startup () $DEGUI = GUICreate("Dashboard Essentials", 1024, 768, -1, -1,BitOr($GUI_SS_DEFAULT_GUI,$WS_MAXIMIZEBOX,$WS_MAXIMIZE)) 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") $bstatcurrent = $hIbluem $s1astatcurrent = $hIgreens $s2astatcurrent = $hIgreens $s3astatcurrent = $hIgreens $s4astatcurrent = $hIgreens $s5astatcurrent = $hIgreens $s6astatcurrent = $hIgreens $s7astatcurrent = $hIgreens $s8astatcurrent = $hIgreens $s9astatcurrent = $hIgreens $s1bstatcurrent = $hIgreens $s2bstatcurrent = $hIgreens $s3bstatcurrent = $hIgreens $s4bstatcurrent = $hIgreens $s5bstatcurrent = $hIgreens $s6bstatcurrent = $hIgreens $s7bstatcurrent = $hIgreens $s8bstatcurrent = $hIgreens $s9bstatcurrent = $hIgreens $hGUI = _GDIPlus_GraphicsCreateFromHWND($DEGUI) While 1 updatestatus() $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $GO If $color = 1 Then $s9bstatcurrent = $hIreds ElseIf $color = 2 Then $s9bstatcurrent = $hIblues ElseIf $color = 3 Then $s9bstatcurrent = $hIoranges ElseIf $color = 4 Then $s9bstatcurrent = $hIgreys ElseIf $color = 5 Then $s9bstatcurrent = $hIreds Else $s9bstatcurrent = $hIgreens EndIf If $color > 6 Then $color = 1 Else $color = $color +1 EndIf EndSwitch WEnd Func updatestatus() $desize = WinGetPos("Dashboard Essentials") $winx = $desize[2] $winy = $desize[3] $winadded = $winx + $winy Global $bigstatus = _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $bstatcurrent, 0, 0, 125, 125, $winx - 150, 30, 125, 125) Global $service1a= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $s1astatcurrent, 0, 0, 55, 55, 150, 160, 55, 55) Global $service2a= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $s2astatcurrent, 0, 0, 55, 55, 150, 215, 55, 55) Global $service3a= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $s3astatcurrent, 0, 0, 55, 55, 150, 270, 55, 55) Global $service4a= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $s4astatcurrent, 0, 0, 55, 55, 150, 325, 55, 55) Global $service5a= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $s5astatcurrent, 0, 0, 55, 55, 150, 380, 55, 55) Global $service6a= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $s6astatcurrent, 0, 0, 55, 55, 150, 435, 55, 55) Global $service7a= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $s7astatcurrent, 0, 0, 55, 55, 150, 490, 55, 55) Global $service8a= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $s8astatcurrent, 0, 0, 55, 55, 150, 545, 55, 55) Global $service9a= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $s9astatcurrent, 0, 0, 55, 55, 150, 600, 55, 55) Global $service1b= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $s1bstatcurrent, 0, 0, 55, 55, $winx - 150, 160, 55, 55) Global $service2b= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $s2bstatcurrent, 0, 0, 55, 55, $winx - 150, 215, 55, 55) Global $service3b= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $s3bstatcurrent, 0, 0, 55, 55, $winx - 150, 270, 55, 55) Global $service4b= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $s4bstatcurrent, 0, 0, 55, 55, $winx - 150, 325, 55, 55) Global $service5b= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $s5bstatcurrent, 0, 0, 55, 55, $winx - 150, 380, 55, 55) Global $service6b= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $s6bstatcurrent, 0, 0, 55, 55, $winx - 150, 435, 55, 55) Global $service7b= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $s7bstatcurrent, 0, 0, 55, 55, $winx - 150, 490, 55, 55) Global $service8b= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $s8bstatcurrent, 0, 0, 55, 55, $winx - 150, 545, 55, 55) Global $service9b= _GDIPlus_GraphicsDrawImageRectRect ($hGUI, $s9bstatcurrent, 0, 0, 55, 55, $winx - 150, 600, 55, 55) If $winadded <> $lastwinadded Then ; I have no clue what I am doing here so I tried everything ;_GDIPlus_BitmapDispose($s9bstatcurrent) _GDIPlus_GraphicsClear ($service9b) _GDIPlus_ImageDispose ($service9b) _WinAPI_DeleteObject ($service9b) _GDIPlus_GraphicsDispose($service9b) _GDIPlus_Shutdown () _GDIPlus_Startup () EndIf $lastwinadded = $winadded EndFunc You can see this when you click the Maximize button a few times. I created an If statement that checked if the GUI size has changed and then I threw in everything including the kitchen sink to try to delete just one of the graphics. As you can see in the "If $winadded <> $lastwinadded Then" Statement I tried everything to delete one of the objects just to see if I could get it to work but I could not. Thanks ~~--Feel Free to Steal my Sigs --~~FLAT LOOK____________________________________ROUNDED LOOK
monoscout999 Posted August 4, 2011 Posted August 4, 2011 But without the images i can`t do anything. You can wait until some more experinced user take a look at this, or upload the images and let me do some test.
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