jimg 0 Report post Posted July 25, 2008 I'd like to create a GUI that includes several scrolling (horizontal) line charts (sort of like Performance Monitor or Task Manager's performance windows. I don't see any way to do this without redrawing everything. Is there a better way? Share this post Link to post Share on other sites
martin 68 Report post Posted July 25, 2008 I'd like to create a GUI that includes several scrolling (horizontal) line charts (sort of like Performance Monitor or Task Manager's performance windows. I don't see any way to do this without redrawing everything. Is there a better way?I think it's fairly simple if you have an image. as shown below. Otherwise have a look at the radar example by monoceres and weaponex.here expandcollapse popup#include <windowsconstants.au3> Global Const $WS_EX_COMPOSITED = 0x2000000 $gui = GUICreate("Scrolling") GUISetState() $child1 = GUICreate("screen", 198, 50, 20, 80, $WS_POPUP, BitOR($WS_EX_MDICHILD, $WS_EX_COMPOSITED), $gui) $n = GUICtrlCreatePic(@SystemDir & "\oobe\images\mslogo.jpg", 0, 0, 200, 50) $n2 = GUICtrlCreatePic(@SystemDir & "\oobe\images\mslogo.jpg", 199, 0, 200, 50) GUISetState() GUIRegisterMsg($WM_MOVE, "redraw") AdlibEnable("slide", 40) While GUIGetMsg() <> -3 Sleep(90) WEnd Func slide() Local $p1 = ControlGetPos($child1, "", $n) Local $p2 = ControlGetPos($child1, "", $n2) Local $newx If IsArray($p1) Then $newx = $p1[0] - 1 If $newx <= -200 Then $newx = 199 ControlMove($child1, "", $n, $newx, $p1[1]) EndIf If IsArray($p2) Then $newx = $p2[0] - 1 If $newx <= -200 Then $newx = 199 ControlMove($child1, "", $n2, $newx, $p2[1]) EndIf EndFunc ;==>slide Func redraw() DllCall("user32.dll", "int", "InvalidateRect", "hwnd", $gui, "int", 0, "int", 1);force a redraw DllCall("user32.dll", "int", "InvalidateRect", "hwnd", $child1, "int", 0, "int", 1);force a redraw EndFunc ;==>redraw Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Share this post Link to post Share on other sites
jimg 0 Report post Posted July 25, 2008 I think it's fairly simple if you have an image. as shown below. Otherwise have a look at the radar example by monoceres and weaponex.here expandcollapse popup#include <windowsconstants.au3> Global Const $WS_EX_COMPOSITED = 0x2000000 $gui = GUICreate("Scrolling") GUISetState() $child1 = GUICreate("screen", 198, 50, 20, 80, $WS_POPUP, BitOR($WS_EX_MDICHILD, $WS_EX_COMPOSITED), $gui) $n = GUICtrlCreatePic(@SystemDir & "\oobe\images\mslogo.jpg", 0, 0, 200, 50) $n2 = GUICtrlCreatePic(@SystemDir & "\oobe\images\mslogo.jpg", 199, 0, 200, 50) GUISetState() GUIRegisterMsg($WM_MOVE, "redraw") AdlibEnable("slide", 40) While GUIGetMsg() <> -3 Sleep(90) WEnd Func slide() Local $p1 = ControlGetPos($child1, "", $n) Local $p2 = ControlGetPos($child1, "", $n2) Local $newx If IsArray($p1) Then $newx = $p1[0] - 1 If $newx <= -200 Then $newx = 199 ControlMove($child1, "", $n, $newx, $p1[1]) EndIf If IsArray($p2) Then $newx = $p2[0] - 1 If $newx <= -200 Then $newx = 199 ControlMove($child1, "", $n2, $newx, $p2[1]) EndIf EndFunc ;==>slide Func redraw() DllCall("user32.dll", "int", "InvalidateRect", "hwnd", $gui, "int", 0, "int", 1);force a redraw DllCall("user32.dll", "int", "InvalidateRect", "hwnd", $child1, "int", 0, "int", 1);force a redraw EndFunc ;==>redraw I need to add live data at the right edge as it scrolls, so it seems a little different, but I'll play with your approach. Share this post Link to post Share on other sites
martin 68 Report post Posted July 25, 2008 (edited) I need to add live data at the right edge as it scrolls, so it seems a little different, but I'll play with your approach.You need to do something like this maybe expandcollapse popup;run as beta Global $lastY = 0,$DrawX = 0, $stepx = 4 #include <GDIPlus.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> Global Const $width = 600 Global Const $height = 200 Opt("GUIOnEventMode", 1) $hwnd = GUICreate("graph", $width, $height,-1,-1) GUISetOnEvent(-3, "close") GUISetState() GUIRegisterMsg($WM_PAINT, "_Paint") GUIRegisterMsg($WM_MOVE, "_Move") _GDIPlus_Startup() $graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd) $bitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $graphics) $background = _GDIPlus_BitmapCreateFromGraphics($width, $height, $graphics) $backgroundgraphics = _GDIPlus_ImageGetGraphicsContext($background) $backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap) $brush = _GDIPlus_BrushCreateSolid(0xFF005200) $pen = _GDIPlus_PenCreate(0xFF888800, 3) _GDIPlus_GraphicsClear($backgroundgraphics, 0xFF000000) _GDIPlus_GraphicsFillRect($backgroundgraphics, 0, 0, $width, $height, $brush) Do _Draw() Sleep(80) Until False Func _Draw() _GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, -$drawx-$stepx, 0, $width, $height) _GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, $width -$drawx-$stepx, 0, $width, $height) $drawX += $stepx if $drawX > $width then $drawX = $stepx ;_GDIPlus_GraphicsClear($backbuffer, 0xFF000000) Local $newY = Random(Int($height/4),Int(3*$height/4),1) _GDIPlus_GraphicsFillRect($backbuffer, $drawx-$stepx, 0,$stepx+1, $height,$brush) _GDIPlus_GraphicsDrawLine($backbuffer, $drawx - $stepx, $lastY , $drawx , $newY, $pen) $lastY = $newY EndFunc ;==>_Draw Func close() _GDIPlus_PenDispose($pen) _GDIPlus_BrushDispose($brush) _WinAPI_DeleteObject($bitmap) _WinAPI_DeleteObject($background) _GDIPlus_GraphicsDispose($backgroundgraphics) _GDIPlus_GraphicsDispose($graphics) _GDIPlus_GraphicsDispose($backbuffer) _GDIPlus_Shutdown() Exit EndFunc ;==>close Func _Paint() _GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, $width, $height) Return "GUI_RUNDEFMSG" EndFunc ;==>_Paint Func _Move() _Draw() Return "GUI_RUNDEFMSG" EndFunc ;==>_Move Edited July 25, 2008 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Share this post Link to post Share on other sites
jimg 0 Report post Posted July 25, 2008 That's close enough to what I need to get me going. Thanks! You need to do something like this maybe expandcollapse popup;run as beta Global $lastY = 0,$DrawX = 0, $stepx = 4 #include <GDIPlus.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> Global Const $width = 600 Global Const $height = 200 Opt("GUIOnEventMode", 1) $hwnd = GUICreate("graph", $width, $height,-1,-1) GUISetOnEvent(-3, "close") GUISetState() GUIRegisterMsg($WM_PAINT, "_Paint") GUIRegisterMsg($WM_MOVE, "_Move") _GDIPlus_Startup() $graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd) $bitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $graphics) $background = _GDIPlus_BitmapCreateFromGraphics($width, $height, $graphics) $backgroundgraphics = _GDIPlus_ImageGetGraphicsContext($background) $backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap) $brush = _GDIPlus_BrushCreateSolid(0xFF005200) $pen = _GDIPlus_PenCreate(0xFF888800, 3) _GDIPlus_GraphicsClear($backgroundgraphics, 0xFF000000) _GDIPlus_GraphicsFillRect($backgroundgraphics, 0, 0, $width, $height, $brush) Do _Draw() Sleep(80) Until False Func _Draw() _GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, -$drawx-$stepx, 0, $width, $height) _GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, $width -$drawx-$stepx, 0, $width, $height) $drawX += $stepx if $drawX > $width then $drawX = $stepx ;_GDIPlus_GraphicsClear($backbuffer, 0xFF000000) Local $newY = Random(Int($height/4),Int(3*$height/4),1) _GDIPlus_GraphicsFillRect($backbuffer, $drawx-$stepx, 0,$stepx+1, $height,$brush) _GDIPlus_GraphicsDrawLine($backbuffer, $drawx - $stepx, $lastY , $drawx , $newY, $pen) $lastY = $newY EndFunc ;==>_Draw Func close() _GDIPlus_PenDispose($pen) _GDIPlus_BrushDispose($brush) _WinAPI_DeleteObject($bitmap) _WinAPI_DeleteObject($background) _GDIPlus_GraphicsDispose($backgroundgraphics) _GDIPlus_GraphicsDispose($graphics) _GDIPlus_GraphicsDispose($backbuffer) _GDIPlus_Shutdown() Exit EndFunc ;==>close Func _Paint() _GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, $width, $height) Return "GUI_RUNDEFMSG" EndFunc ;==>_Paint Func _Move() _Draw() Return "GUI_RUNDEFMSG" EndFunc ;==>_Move Share this post Link to post Share on other sites
laffo16 1 Report post Posted September 29, 2008 (edited) has anyone improved upon this code? when i rattle with the window the graphs speed increases. window size reshape would be nice. its pretty CPU intensive i find or is this standard? i get crash while launching if my CPU is to high. very nice though. decreasing line thickness makes the lines disapear at points which is a shame. Edited September 29, 2008 by laffo16 Share this post Link to post Share on other sites
martin 68 Report post Posted September 29, 2008 has anyone improved upon this code?Have you seen monoceres Earth and Moon? Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Share this post Link to post Share on other sites