Questions about releasing handles.
-
I Dim a graphic “Public Ax1g1 As Graphics = MYform1.CreateGraphics” and the call the “bitblt” function to capture the image and then I release the handle “Ax1g1.ReleaseHdc(dc1)” On any subsequent call to this class “Ax1ThumbnailClass.AxCaptureImage” I get an invalid parameter exception on Ax1g1.ReleaseHdc(dc1). I’ve tried not releasing the handles and I do not get the exception but the captured image is blank. Help greatly appreciated!!!! ********************CALLING CODE*********************** Ax1Thumbnail.AxCaptureImage(MYform1.AxWebBrowser1.Location.X, MYform1.AxWebBrowser1.Location.Y) Myform2.thumbScr1.Image = Ax1Thumbnail.Ax1Image.GetThumbnailImage(50, 50, Nothing, Nothing) Public Class Ax1ThumbnailClass Public Ax1g1 As Graphics = MYform1.CreateGraphics() Public Ax1Image = New Bitmap(150, 150, Ax1g1) Public Ax1g2 As Graphics = Graphics.FromImage(Ax1Image) Public dc1 As IntPtr = Ax1g1.GetHdc() Public dc2 As IntPtr = Ax1g2.GetHdc() Public Sub AxCaptureImage(ByVal Browser1 As Integer, ByVal Browser2 As Integer) CallBitBlt.BitBlt(dc2, 0, 0, 150, 150, dc1, Browser1, Browser2, SSRCCOPY) Ax1g1.ReleaseHdc(dc1) Ax1g2.ReleaseHdc(dc2) End Sub End Class Public Class bitbltClass _ Public Shared Function BitBlt(ByVal hdcDest As IntPtr, _ ByVal nXDest As Integer, _ ByVal nYDest As Integer, _ ByVal nWidth As Integer, _ ByVal nHeight As Integer, _ ByVal hdcSrc As IntPtr, _ ByVal nXSrc As Integer, _ ByVal nYSrc As Integer, _ ByVal dwRop As System.Int32) As Boolean End Function End Class Thanks, GregC