Hi,
I'm using a PictureBox with lots of Lines,Circles, Shapes and Label. Each of them is moved around, with an increased number and updaterate they start flickering. Is theier anything I can do against that? and whow?
Thanks
Printable View
Hi,
I'm using a PictureBox with lots of Lines,Circles, Shapes and Label. Each of them is moved around, with an increased number and updaterate they start flickering. Is theier anything I can do against that? and whow?
Thanks
if you set the picturebox's "AutoRedraw" property to "True" it will eliminate the flickering... it is VERY slow, however, but i can post faster code later, if anyone wants it.
Ok, heres some psudo code for drawing faster, without autoredraw....
youll need to add the LockWindowUpdate API function to your form (use the API viewer)... then use this formula...
Code:do while true
picture1.cls
lockwindowupdate 0
'do your drawing stuff
lockwindowupdate picture1.hwnd
doevents
loop
Another faster method is to double buffer the drawing - draw onto a device context in memory first, then 'flip' the entire image onto the picture box. Smooth as a babys bum.
- gaffa
Thanks,but:
Zaei: Your code does somethig, but their must be a mistake in it, 'cause the picture stays fixed?? Although the other parts of the forms have a new flickering if I use that function??
gaffa: I was thinking about something like that, the whow is my problem, I did something like that with old QBX, but I think it does not work for Shape- and Line-Objects. Do you some more specific help?
I think the 'do while true' line in Zaei's code is wrong. Correct me if im wrong, but by default everything is zero, zero=false so it will never happen?
Use do while Drawing=True and make drawing a boolean you can set to true to draw and false not to draw
its not wrong, its just a horrible programming style =)
the way it works is a do while loop will continue UNTIL
the condition is false. so, when you say "Do While
True" True can NEVER be False, so it will just loop
continuously. As a side effect, if you try to close the
window the regular way (the "X" button) the form will
actually re-load itself, and the only way to stop it is to
use that stop button in VB. Never do it the way i did it
=)
In this case, what is the variable? Are you using a with statement or something? What am I missing????
there is no variable, its a Value. Enter More Theory:
Whenever you do a comparison, it will return a boolean
value. This can save lines and lines of coding, if, for
example, you needed to assign "True" or "False" to a
variable. You could do it this way:
But, a MUCH better way to do it is this:Code:If X > Y Then
Z = True
Else
Z = False
End If
So, any comparison that you do returns a booleanCode:Z = X > Y
variable. This goes for While loops as well. Example:
WHen our program hits this block of code, it checks ourCode:Do While X > Y
'Do Some Stuff
Loop
statement. If X started off being less than Y, the code
would never execute, because X > Y returns "False".
Basically, all I did in the Do While True loop, is, instead
of passing a statement (X = X, for example) i saved
myself typing time by just passing the value "True".
I hope that sheds some light on this stuff =).