Results 1 to 9 of 9

Thread: Trouble with BitBlt

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2001
    Location
    Maumelle, AR
    Posts
    624

    Trouble with BitBlt

    If the form is already painted will it not repaint it? I know this is not TRUE skinning, but it suits my program. I want this to change the main forms background when a user selects it from the dropdown list so they can have a preview before saving the setting. Here's my code. Do I have to erase the form or something of the sort first?
    VB Code:
    1. Private Sub comboSkin_Click()
    2. Kamo2.Picture1.Picture = Kamo2.ImageList1.ListImages(liboptions.comboSkin.ListIndex).Picture
    3.  
    4. ScaleMode = 3
    5.     Kamo2.Picture1.AutoRedraw = True
    6.     Kamo2.AutoRedraw = True
    7.    
    8.     For X = 0 To Width Step Kamo2.Picture1.Width
    9.         For Y = 0 To Height Step Kamo2.Picture1.Height
    10.             DoEvents
    11.             BitBlt hDC, X, Y, Kamo2.Picture1.ScaleWidth, Kamo2.Picture1.ScaleHeight, Kamo2.Picture1.hDC, 0, 0, vbSrcCopy
    12.         Next Y
    13.     Next X
    14. ScaleMode = 1
    15. End Sub

  2. #2
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125
    After you call bitblt, you have to call Kamo.Refresh, or whatever window you are drawing to. You have to do this because you have set autoredraw to true. It won't update it until you refresh it.
    <removed by admin>

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2001
    Location
    Maumelle, AR
    Posts
    624

    Still not working.

    I put Kamo2.refresh after the bitblt function, and you can see a flash on the form,but the image doesn't change. Any ideas?

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2001
    Location
    Maumelle, AR
    Posts
    624

    ^Bump^

    ^Bump^

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2001
    Location
    Maumelle, AR
    Posts
    624

    ^Bump^

    Anyone? Repainting the form can't be that difficult can it?

  6. #6
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125
    Are you repainting the source as well? Make sure the source is changing. You will probably have to refresh the source as well as the destination.
    <removed by admin>

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2001
    Location
    Maumelle, AR
    Posts
    624

    Ok, Midgetsbro......

    Here's my new code:
    VB Code:
    1. Private Sub comboSkin_Click()
    2.  
    3. Kamo2.Picture1.Picture = Kamo2.ImageList1.ListImages(liboptions.comboSkin.ListIndex).Picture 'set new pic
    4.      Kamo2.Picture1.Refresh
    5. ScaleMode = 3
    6.     Kamo2.Picture1.AutoRedraw = True
    7.     Kamo2.AutoRedraw = True
    8.    
    9.     For x = 0 To Width Step Kamo2.Picture1.Width
    10.         For y = 0 To Height Step Kamo2.Picture1.Height
    11.             DoEvents
    12.             BitBlt hDC, x, y, Kamo2.Picture1.ScaleWidth, Kamo2.Picture1.ScaleHeight, Kamo2.Picture1.hDC, 0, 0, vbSrcCopy
    13.         Next y
    14.     Next x
    15. ScaleMode = 1
    16. Kamo2.Refresh
    17. End Sub
    What I'm trying to do here is set picture1.picture on my main form (Kamo2) = to a new image (the listindex value of the combobox in my options form), and then repaint the Kamo2 form with the new image. Someone please help. This is rediculous. I don't see why it shouldn't work. I change the image and call Bitblt again.

  8. #8
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125
    I am just wondering why you are looping through the whole width and height of the picture and re-bitblting the image. Don't you only need to bitblt it once into the form, and refresh and it should show? Make sure you have your picturebox's autoredraw property set to true if you have it's visible property set to false. You may not be loading the images correctly from the imagelist, but I am not sure, since I never use imagelists. If you are using this for skins, why not just load the pictures from the hard drive using LoadPicture?
    <removed by admin>

  9. #9
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Well

    The last post before the accident...

    MidgetsBro : What did you break ?
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

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