Erik. 1 Posted May 30, 2011 Hi, I think the solution is easy but i can't find it. I want to make an graphic that displays data in my array. That's not the problem at all, the problem now is, i am pushing the array with an new random number. I would like to update the graphic after the new random integer has been generated. I can't find out how to do that. Hope you can help me. My code: expandcollapse popup#include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Array.au3> Dim $aArray[500] #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 615, 438, 247, 136) $Graphic1 = GUICtrlCreateGraphic(0,0, 500, 500) GUICtrlSetGraphic(-1,$GUI_GR_LINE,0,250) GUICtrlSetGraphic(-1,$GUI_GR_LINE,500,250) GUICtrlSetGraphic(-1,$GUI_GR_MOVE,0,0) #EndRegion ### END Koda GUI section ### $i = 0 While $i < 500 $aArray[$i] = random(-250,250,1) $i = $i + 1 WEnd While 1 $nMsg = GUIGetMsg() _ArrayPush($aArray,random(-250,250,1),1) Drawgraphic() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func Drawgraphic() $y = 0 While $y < 500 GUICtrlSetGraphic($Graphic1,$GUI_GR_LINE,($y),($aArray[$y]+250)) $y = $y + 1 Wend GUISetState() EndFunc I little problem, hard to find and fix Share this post Link to post Share on other sites
Erik. 1 Posted May 30, 2011 Simple $GUI_GR_REFRESH After adding this my graphic will be updated every loop. Problem now is, it does not delete the old lines to it will be an black block. How can i do that? I little problem, hard to find and fix Share this post Link to post Share on other sites
UEZ 1,273 Posted May 30, 2011 It will flicker a lot when using this method! I would do it in GDI+ with backbuffer method to minimize flickering. Example: expandcollapse popup#include <Array.au3> #include <GDIPlus.au3> Opt("GUIOnEventMode", 1) _GDIPlus_Startup() $iW = 615 $iH = 438 $Form1 = GUICreate("Form1", $iW, $iH, 247, 136) GUISetBkColor(0xFFFFFF, $Form1) GUISetState() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($Form1) $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hGraphic) $hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hBackbuffer, 2) _GDIPlus_GraphicsClear($hBackbuffer, 0xFFFFFFFF) $hPen = _GDIPlus_PenCreate(0xFF000000, 1) Dim $aArray[500] $i = 0 While $i < 500 $aArray[$i] = random(-250, 250, 1) $i = $i + 1 WEnd GUISetOnEvent(-3, "_Exit") AdlibRegister("Draw", 100) While Sleep(10000) WEnd Func Draw() _GDIPlus_GraphicsClear($hBackbuffer, 0xFFFFFFFF) $y = 0 While $y < 500 _GDIPlus_GraphicsDrawLine($hBackbuffer, $y, 250, $y, $aArray[$y]+250,$hPen) $y = $y + 1 Wend _GDIPlus_GraphicsDrawImage($hGraphic, $hBitmap, 0, 0) _ArrayPush($aArray,random(-250,250,1),1) EndFunc Func _Exit() AdlibUnRegister("Draw") _GDIPlus_PenDispose($hPen) _GDIPlus_GraphicsDispose($hBackbuffer) _GDIPlus_BitmapDispose ($hBitmap) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() GUIDelete($Form1) Exit EndFunc Br, 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!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Share this post Link to post Share on other sites
Erik. 1 Posted May 30, 2011 Wow, that is very nice!! I was looking for that. I little problem, hard to find and fix Share this post Link to post Share on other sites