VB Code:
'in a module Public Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hDC As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long Public Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long Public Declare Function SelectObject Lib "gdi32" (ByVal hDC As Long, ByVal hObject As Long) As Long 'when you need a handle to the bitmap in memoryDC Dim hBitmap As Long, hDummyBitmap As Long 'make a 1x1 pixel bitmap compatible with the memory DC hDummyBitmap = CreateCompatibleBitmap(memoryDC, 1, 1) 'put that bitmap into the DC, which causes the handle to the old one to be returned hBitmap = SelectObject(memoryDC, hDummyBitmap) 'put that bitmap back into the DC SelectObject memoryDC, hBitmap 'delete the dummy bitmap DeleteObject hDummyBitmap 'at this point, your DC is unchanged, but you now have the handle to the bitmap that was in it 'hBitmap is the handle



Reply With Quote