Results 1 to 8 of 8

Thread: Copying Picturebox Contents With BitBlit?

  1. #1

    Thread Starter
    Member
    Join Date
    May 2000
    Location
    Marietta, GA.
    Posts
    32

    Copying Picturebox Contents With BitBlit?

    Hi all! Got another question for all you guys out there. First, let explain what I've got and then what I want to do.

    First off, I have a graphic that is solid (no transparency), that I have moving underneath a transparent graphic (made transparent with BitBlt).

    I've gotten it to SRCCOPY the solid picture first to a picturebox, then SRCAND and SRCPAINT the one with transparency on top of it. Then, I SRCCOPY the whole image to another PictureBox which I'm using as the drawing plane. By changing the Y coordinates of the SRCCOPY when copying the solid image, it appears that it is moving up and down. So, it looks a lot like a shutter door opening and closing. So far, so good.

    The problem I'm running into is this... when the "door" goes back up, revealing what's underneath, I can't seem to get anything to show up! I want to cover up controls with the door, and then reveal new controls as the door opens.

    Is there any way to do this? So far, when I try to SRCCOPY the picturebox with the controls on it, it only copies the picturebox's background.

    Any help would be great!

    - Amp
    Thanks!
    --AMP

  2. #2
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    As I understood that right you need to make buffers to store each 'layer' of your game. So you'll have 1 layer/buffer for the backgrouns and 1 for objects (like the door). Now when you draw the game you first copy the background layer, then the doors. This will prevent the door from overwriting the background and you won't get into problems...

    See my animation demo if you need an example

  3. #3

    Thread Starter
    Member
    Join Date
    May 2000
    Location
    Marietta, GA.
    Posts
    32
    That's pretty much what I'm doing, but on the background layer I have regular VB controls (textbox, buttons, etc). When I draw the background layer, none of the controls get drawn along with it!

    All I'm looking for really is a way to draw the controls underneath the door layer and on top of the background layer (I think).

    - Amp
    Thanks!
    --AMP

  4. #4
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Unfortunately that's a really hard question

    My advice is to scroll the PICTUREBOX ITSELF up and down, as BitBlt draws to the picture, the picture draws to the form, etc. so you should change the PICTUREBOX itself.

    To do this, you must set a WINDOW REGION for the hWnd of the picturebox. I can post some code on how to do this.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  5. #5
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Declarations:
    Code:
    Public Declare Function CreatePolygonRgn Lib "gdi32" _
    (lpPoint As POINTAPI, ByVal nCount As Long, ByVal _
    nPolyFillMode As Long) As Long
    
    Public Declare Function CreatePolyPolygonRgn Lib "gdi32" _
    (lpPoint As POINTAPI, lpPolyCounts As Long, ByVal nCount As _
    Long, ByVal nPolyFillMode As Long) As Long
    
    Public Declare Function CombineRgn Lib "gdi32" _
    (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, _
    ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long
    
    Public Declare Function SetWindowRgn Lib "user32" _
    (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
    
    Public Declare Function DeleteObject Lib "gdi32" _
    (ByVal hObject As Long) As Long
    This code works very much like using AREAS in an IMAGE MAP in HTML, if you've ever used that. But don't take it from me; take it from VB-WORLD because that's where I got this code from
    (http://www.vbworld.com/articles/shapedforms/index3.html)

    At the above link it will show you how to use them; good luck!
    And also make sure in SetWindowRgn you have like Picture1.hWnd as hWnd.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  6. #6

    Thread Starter
    Member
    Join Date
    May 2000
    Location
    Marietta, GA.
    Posts
    32
    Thanks! I'll try this out when I get back in a while.
    Thanks!
    --AMP

  7. #7

    Thread Starter
    Member
    Join Date
    May 2000
    Location
    Marietta, GA.
    Posts
    32
    Looks like that's going to work for me, I'll just have to play around with it a bit.

    Thanks for the help!
    Thanks!
    --AMP

  8. #8
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Always here

    24 hours a day, unfortunately
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

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