how to copy a Picturebox region define by SetWindowRgn

how to copy a Picturebox region define by SetWindowRgn

Post by Do » Sat, 25 Apr 1998 04:00:00

Hi there,

Can anyone tell me how I can copy a Picturebox (visible=false)  region
that was define by SetWindowRgn to another PictureBox(visible=true).

I have tried using PaintPicture but it copies the entire picture
instead of only the region shown by SetWindowRgn.

I am using VB5.

Any help or suggestions much appreciated.

Replies here or by email are both fine.



1. copying offscreen picturebox to another picturebox

I am trying to do a simple animation in a vb app...

I am using 6 Image controls embedded in a picture box. With a timer, I
change which image is visible. This works to animate the picture, but I get
a flicker...

I have been trying to use some code I found and modified slightly to copy
the picture to a device context and then to the destination picturebox, but
nothing seems to happen, I get a blank in the destination picture... I'm
sure it's something simple I've forgotten, perhaps someone can help.

I am including the code I am using below.

Thanks in advance for your expertise.

' imgAnim() is an array of Image controls
' picture1 and picBackground are the source and destination pictures,

Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal X
As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal
hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long)
As Long
Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hDC As Long)
As Long
Private Declare Function DeleteDC Lib "gdi32" (ByVal hDC As Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hDC As Long, ByVal
hObject As Long) As Long

dim intAnimFrame as integer

Private Sub Timer1_Timer()
    intAnimFrame = intAnimFrame + 1

    If intAnimFrame > 6 Then intAnimFrame = 1

    For i = 1 To 6
        imgAnim(i).Visible = False

    imgAnim(intAnimFrame).Visible = True
    CopyFrame Picture1, picBackground.hDC

End Sub

Private Sub CopyFrame(SrcControl As PictureBox, DestHDC As Long)
    Dim CompDC As Long, hBmp As Long
    Dim SourceHDC As Long, SourceBMP As Long
    Dim xpos As Long, ypos As Long, rtn As Long

    SourceHDC = SrcControl.hDC
    CompDC = CreateCompatibleDC(SourceHDC)

    SourceBMP = SrcControl.Picture
    hBmp = SelectObject(CompDC, SourceBMP)

    rtn = BitBlt(DestHDC, 0, 0, SrcControl.Width, SrcControl.Height, CompDC,
0, 0, vbSrcCopy)
    rtn = DeleteDC(CompDC)
End Sub

2. gif

3. SetWindowRgn and the super region.

4. PSP v70 cut and past to new pictures has a margin

5. Drawing Region in PictureBox

6. 3d models for immediate download

7. define a rectangular region on screen

8. Mesa 3D vs OpenGL

9. Trying to define a clipping region

10. Copy string buffer to picturebox

11. How To Copy Capture Video Frame to PictureBox?

12. Copy the contents of a PictureBox to Clipboard

13. Copy Region?