Results 1 to 8 of 8

Thread: [RESOLVED] BitBlt on Hidden PictureBox

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2014
    Posts
    13

    Resolved [RESOLVED] BitBlt on Hidden PictureBox

    Hello everyone,

    So today I have begun experimenting with BitBlt. What I am attempting to do is copy an image of a picturebox including all the images and other controls contained within it to a second picturebox. However, the picturebox I am copying from must be hidden, but it appears when I attempt to do this that the copy made will just be of whatever is visible in the position where the picturebox is. i.e. If I hide the picturebox or put it behind the second picturebox, it will not copy the contents of it. Sorry, I am still relatively new to all this. If anyone knows how to accomplish the task I have here, please let me know (even if it involves something other than BitBlt). I would rather not have to individually .paintpicture every image from the first picturebox to the second as some of them are transparent gifs so this would require some extra steps (I will do this as a last resort).

    Thanks in advance!!
    Dill

  2. #2
    Frenzied Member
    Join Date
    Mar 2008
    Posts
    1,176

    Re: BitBlt on Hidden PictureBox

    Try setting the AutoRedraw Property in the source PictureBox to True.

  3. #3
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,481

    Re: BitBlt on Hidden PictureBox

    BitBlt doesn't handle transparency. Not sure your GIFs will work. PaintPicture doesn't handle GIF transparency either, but each picture object has a .Render function and it can deal with GIF/Icon transparency.

    For more info, see this link in our codebank
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  4. #4

    Thread Starter
    New Member
    Join Date
    Oct 2014
    Posts
    13

    Re: BitBlt on Hidden PictureBox

    The pictureboxes already have autoredraw set to true. No difference.

    The transparent gif has a second image acting as a background behind it on the source picturebox. I don't need to bitblt the transparency over. I just want everything I see in picturebox 1 to go into picturebox 2.

  5. #5
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,481

    Re: BitBlt on Hidden PictureBox

    Think you may have to show us your BitBlt statement. Both source & destination should have AutoRedraw=True. BitBlt will not copy controls. It only copies the picbox background which includes any .Picture property assignment

    BitBlt is for bitmaps. Controls in a container are not part of the bitmap
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  6. #6

    Thread Starter
    New Member
    Join Date
    Oct 2014
    Posts
    13

    Re: BitBlt on Hidden PictureBox

    I will just play around with this and see if I can figure out a solution. Ill reply with what I discover if I figure out what I'm attempting to do.

  7. #7

    Thread Starter
    New Member
    Join Date
    Oct 2014
    Posts
    13

    Re: BitBlt on Hidden PictureBox

    So what I ended up doing:
    1. Make 2 forms and have one picturebox on each form.
    2. Set Autoredraw to FALSE on each.
    3. BitBlt from source picturebox to destination picturebox on other form

    This allowed me to eliminate flicker of moving transparent gifs that would normally flicker when you move an image in a picturebox. The other solution I used to use required using .paintpicture to paint each image to the picturebox, however this made the game laggy and it required painting 2 pictures for every transparent .gif in order to avoid flicker. If anyone wants me to send them my function for using paintpicture to paint transparent .gif let me know. This new method is a lot more efficient, although it requires two forms to be running at the same time, one hidden behind the other. Although this is probably not the most efficient or best solution to this problem, it will do for me for today as I am just trying to program a little fun game for my father as a Christmas present. :P Doesn't have to be too crazy!

    Thank you everyone who tried to assist me in my inexperience.

  8. #8
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,121

    Re: BitBlt on Hidden PictureBox

    Doesn't seem to make sense to me based on my understanding of how bitblt and the hDCs work.
    If you have two forms, but don't have Autoredraw set true on the pictureboxes, then when you bitblt from the form "behind" with an hDC of a non-AutoRedraw picturebox, you are bitblting the visible desktop area of the screen to somewhere.
    I used that technique all the time to capture areas of the screen. You just move a non-visible form to the area you want to capture and use it's hDC to bitblt from.

    I don't know how you're doing the drawing, but bitblt between two pictureboxes that are located in the same area, with AutoRedraw set to false on both should just be bitblting an area of the screen to itself, so have no effect at all (and it won't flicker, that's true).

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