Results 1 to 2 of 2

Thread: Passing control out of a loop

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 1999
    Posts
    5

    Post

    I am using the following VB code to display the bitmap into an image control. I am taking the values of each pixel from the bitmap file , do some processing, and finally plot each individual pixel on to the image control.Take a look at it.

    For x = 1 To head.width
    For y = 1 To head.height
    img1.PSet (x, y), RGB(r,g,b)
    Next y
    Next x

    The problem with this code is, the user cannot do anything when the bitmap is being displayed, while control is in this loop. I want to give a cancel button to stop the display of the bitmap ie. exit from this loop. Is there a method for this ?

    Alternatively, it would be nice if there is a method to speed up the display of the bitmap,like writing the pixel array directly to video memory. [ Using VB only, not using directx ] .In this way, the need for the cancel button would be eliminated.

  2. #2
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844

    Post

    a DoEvents in the middle of the loop will allow the app to yield to the O/S (and therefore the user).

    You could also use the LoadPicture function which would be much faster....

    Tom

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