navajo Posted October 23, 2006 Share Posted October 23, 2006 (edited) Sorry if an anser to this problem has been posted before, I could not find an answer with the forum searchThe code below draws a few lines, 200 of them, if you watch close, some of the lines drop from view after they have been drawn. any suggestions why those lines are dropping? expandcollapse popup#include <GuiConstants.au3> $linecount = 0 $Form1 = GUICreate("Lines", 705, 805, 220, 116) $canvas = GUICtrlCreateGraphic(10, 10, 700, 700) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch if $linecount <= 200 Then sleep(150) rndline($canvas, rndcolor()) $linecount = $linecount + 1 EndIf WEnd Func rndcolor() $_c = random(0x000000, 0xffffff, 1) return $_c EndFunc Func rndline($_canvas, $color = 0x000000) $t_x = Random(10, 600, 1) $t_y = random(10, 600, 1) GUICtrlSetGraphic($_canvas, $GUI_GR_COLOR, $color, $color) GUICtrlSetGraphic($canvas, $GUI_GR_LINE, $t_x, $t_y) GUICtrlSetGraphic($_canvas, $GUI_GR_REFRESH) EndFunc Edited October 23, 2006 by navajo Link to comment Share on other sites More sharing options...
BitRot Posted October 23, 2006 Share Posted October 23, 2006 (edited) any suggestions why those lines are dropping? Probably because the $GUI_GR_LINE is a "draw-to command, which is probably terminated and re-started from a last-set (not by you) point by the $GUI_GR_REFRESH command. Suggestion : createa random starting-point, use $GUI_GR_MOVE to get there, than generate a random ending-point, and draw your line. Than refresh the display : Func rndline($_canvas, $color = 0x000000) GUICtrlSetGraphic($_canvas, $GUI_GR_COLOR, $color, $color) $t_x = Random(10, 600, 1) $t_y = random(10, 600, 1) GUICtrlSetGraphic($canvas, $GUI_GR_MOVE, $t_x, $t_y) $t_x = Random(10, 600, 1) $t_y = random(10, 600, 1) GUICtrlSetGraphic($canvas, $GUI_GR_LINE, $t_x, $t_y) GUICtrlSetGraphic($_canvas, $GUI_GR_REFRESH) EndFuncHope that helps. [edit] It looks like that placing a simple "GUICtrlSetGraphic($canvas, $GUI_GR_MOVE, 20,20)" just above the "while 1" will allso do the job ... No real idea why though. Edited October 23, 2006 by BitRot Link to comment Share on other sites More sharing options...
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