Using bitblt API on DXDrawSurface7
Hello people. I am trying to copy an image from a picture box onto a directdrawsurface7. For some reason the bitblt API just wont do its job. Every example I have seen on the web seems to be the same
Code:
'Create The Image
DDSD.lFlags = DDSD_CAPS + DDSD_HEIGHT + DDSD_WIDTH
DDSD.ddsCaps.lCaps = DDSCAPS_3DDEVICE
DDSD.lWidth = DXRect.Right - DXRect.Left
DDSD.lHeight = DXRect.Bottom - DXRect.Top
Set DXSurface = DDraw.CreateSurface(DDSD)
SurfaceDC = DXSurface.GetDC
Debug.Print BitBlt(SurfaceDC, 1, 1, DDSD.lWidth, DDSD.lHeight, PBBox.Image, DXRect.Left + 1, DXRect.Top + 1, vbSrcCopy)
DXSurface.ReleaseDC SurfaceDC
Anybody got any advice as to why it wont be working? :confused:
Re: Using bitblt API on DXDrawSurface7
Not sure about BitBlting to a directdrawsurface7, but I am familiar with BitBlt.
BitBlt requires a hDC for both the source and destination, your using a Bitmap handle for the source, try this
Code:
Debug.Print BitBlt(SurfaceDC, 1, 1, DDSD.lWidth, DDSD.lHeight, PBBox.hDC, DXRect.Left + 1, DXRect.Top + 1, vbSrcCopy)
BitBlt also does not invoke a refresh so normally you have to also refresh the target to see the result, I don't now how that would apply to a directdrawsurface7.
Re: Using bitblt API on DXDrawSurface7
No sorry that didnt work either. Thanks for the help though :)
Re: Using bitblt API on DXDrawSurface7
Did you refresh? What code did BitBlt return?
If it was non zero, BitBlt was successful, at least it thinks it was.
Re: Using bitblt API on DXDrawSurface7
Oh it always returns 0. I thought that meant success :oS
I dont think there is a refresh in DX.
Re: Using bitblt API on DXDrawSurface7
Hmmm it does work but its returning some weird image as though its off my screen. Its a block from the center of my screen not the picturebox :oS
Re: Using bitblt API on DXDrawSurface7
Ahh, set the source pictureboxes autoredraw property to true. If false the picturebox does not have it's own DC, and BitBlt will copy a portion of the desktop instead.
Re: Using bitblt API on DXDrawSurface7
Found it. The hdc is what I need but the picturebox HAS TO HAVE AUTOREFRESH ON. Otherwise it copies the image behind the picturebox :)
Thanks for your help. Wouldnt have got anywhere if I didnt know the hdc and the fact that bitblit returns non zero as a success
:D