Results 1 to 9 of 9

Thread: Picturebox flickers??

  1. #1

    Thread Starter
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863
    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
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  2. #2
    Guest
    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.

  3. #3
    Guest

    The faster thing

    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

  4. #4
    Guest
    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

  5. #5

    Thread Starter
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863
    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?
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  6. #6
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    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
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  7. #7
    Guest
    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
    =)

  8. #8
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    In this case, what is the variable? Are you using a with statement or something? What am I missing????
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  9. #9
    Guest
    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:
    Code:
    If X > Y Then
         Z = True
    Else
         Z = False
    End If
    But, a MUCH better way to do it is this:
    Code:
    Z = X > Y
    So, any comparison that you do returns a boolean
    variable. This goes for While loops as well. Example:
    Code:
    Do While X > Y
         'Do Some Stuff
    Loop
    WHen our program hits this block of code, it checks our
    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 =).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width