i did 1 class for working with DC's(double buffering):
why instead copy\draw the image, copy a mask image?Code:Option Explicit Private Type DC handleDC As Long handleBMP As Long handleRefBMP As Long End Type Private Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hdc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long Dim SourceDC As DC Dim lngWidth As Long Dim lngHeight As Long Public Sub GetImage(ByRef hdc As Long, ByRef Width As Long, ByRef Height As Long) SourceDC.handleDC = CreateCompatibleDC(hdc) SourceDC.handleBMP = CreateCompatibleBitmap(SourceDC.handleDC, Width, Height) SourceDC.handleRefBMP = SelectObject(SourceDC.handleDC, SourceDC.handleBMP) BitBlt SourceDC.handleDC, 0, 0, Width, Height, hdc, 0, 0, vbSrcCopy lngHeight = Height lngWidth = Width End Sub Public Sub DrawImage(ByRef hdc As Long) BitBlt hdc, 0, 0, lngWidth, lngHeight, SourceDC.handleDC, 0, 0, vbSrcCopy End Sub Private Sub Class_Terminate() DeleteObject SelectObject(SourceDC.handleDC, SourceDC.handleRefBMP) DeleteObject SourceDC.handleBMP DeleteDC SourceDC.handleDC End Sub


Reply With Quote
Bookmarks