Results 1 to 4 of 4

Thread: Can't create AutoRedraw Image

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2001
    Posts
    9

    Can't create AutoRedraw Image

    There is a problem i face when drawing lines on picture box.

    I have been using this line of code extensively in my forms to draw the lines.
    /*code*/
    frmname.Line (x1, y1)-(X2, Y2), rgbColor
    /*code*/

    It has been working fine for me for quite some time.

    But now the number of lines drawn and redrawn is so great that it has started throwing an error

    Can't create AutoRedraw Image.

    And it fails to draw the lines.

  2. #2
    Frenzied Member
    Join Date
    Aug 2001
    Posts
    1,075
    I'm pretty sure this error is caused when you are running low on
    GDI resources. It is difficult from this disatance to say why you
    are running low. It can be caused by having too many windows
    open that are performing graphics routines, or if graphics
    routines are not "cleaning up after themselves"

    From the Start menu select Accessories/System Tools/Resource
    Monitor and have it runnning when you are running your app.
    Check the monitor before you start your app and when you get
    the error check the monitor again.

    If you have a lot of tight loops in conjection with graphics
    routines this could be a cause. Try peppering your code with a
    few Doevents.

    Greg
    Free VB Add-In - The Reference Librarian
    Click Here for screen shot and download link.

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2001
    Posts
    9
    Thanks for the suggestion.
    Even i get the feeling that there are so many loops in the program.
    My project requirement is like this -
    i need to display the hierarchies in an organization.These require so many lines to display the flow chart.

    How do i use DoEvents ??? in my code.
    What does it do ??

    Thanks in advance.

  4. #4
    Frenzied Member
    Join Date
    Aug 2001
    Posts
    1,075
    Maybe you've notices at times when your program is churning away that it becomes unresponsize. If you add some Doevents it frees up the CPU to proccess other things like mouse clicks, drawing graphics, and what not. To use doevents you just put it in a loop like this.

    VB Code:
    1. For k =  1 to 500
    2.      lCounter = lCounter + 1
    3.      Doevents
    4. Next

    You don't always have to call Doevents each itereation of the loop. Each time you call it it will slow your program down every so slightly. You can do something like this.

    VB Code:
    1. 'Only call doevents every 100 loops
    2. For k =  1 to 500
    3.      lCounter = lCounter + 1
    4.      If lCounter Mod 100 = 0 then
    5.          Doevents
    6.      End If
    7. Next

    Greg
    Free VB Add-In - The Reference Librarian
    Click Here for screen shot and download link.

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