Article ID: 100973
Article Last Modified on 5/6/2003
Option Compare Database
Option Explicit
Type RECT_Type
left As Integer
top As Integer
right As Integer
bottom As Integer
End Type
Declare Function GetActiveWindow% Lib "User" ()
Declare Function GetDesktopWindow% Lib "User" ()
Declare Sub GetWindowRect Lib "User" (ByVal Hwnd%, _
lpRect As RECT_Type)
Declare Function GetDC% Lib "User" (ByVal Hwnd%)
Declare Function CreateCompatibleDC% Lib "GDI" (ByVal hdc%)
Declare Function CreateCompatibleBitmap% Lib "GDI" (ByVal hdc%, _
ByVal nWidth%, ByVal nHeight%)
Declare Function SelectObject% Lib "GDI" (ByVal hdc%, ByVal hObject%)
Declare Function BitBlt% Lib "GDI" (ByVal hDestDC%, ByVal X%, _
ByVal Y%, ByVal nWidth%, _
ByVal nHeight%, ByVal hSrcDC%, _
ByVal XSrc%, ByVal YSrc%, _
ByVal dwRop&)
Declare Function OpenClipboard% Lib "User" (ByVal Hwnd%)
Declare Function EmptyClipboard% Lib "User" ()
Declare Function SetClipboardData% Lib "User" (ByVal wFormat%, _
ByVal hMem%)
Declare Function CloseClipboard% Lib "User" ()
Declare Function ReleaseDC% Lib "User" (ByVal Hwnd%, ByVal hdc%)
Declare Function DeleteDC% Lib "GDI" (ByVal hdc%)
Global Const SRCCOPY = &HCC0020
Global Const CF_BITMAP = 2
Function ScreenDump ()
Dim AccessHwnd%, DeskHwnd%
Dim hdc%
Dim hdcMem%
Dim rect As RECT_Type
Dim junk%
Dim fwidth%, fheight%
Dim hBitmap%
DoCmd Hourglass True
'---------------------------------------------------
' Get window handle to Windows and Microsoft Access
'---------------------------------------------------
DeskHwnd = GetDesktopWindow()
AccessHwnd = GetActiveWindow()
'---------------------------------------------------
' Get screen coordinates of Microsoft Access
'---------------------------------------------------
Call GetWindowRect(AccessHwnd, rect)
fwidth = rect.right - rect.left
fheight = rect.bottom - rect.top
'---------------------------------------------------
' Get the device context of Desktop and allocate memory
'---------------------------------------------------
hdc = GetDC(DeskHwnd)
hdcMem = CreateCompatibleDC(hdc)
hBitmap = CreateCompatibleBitmap(hdc, fwidth, fheight)
If hBitmap <> 0 Then
junk = SelectObject(hdcMem, hBitmap)
'---------------------------------------------
' Copy the Desktop bitmap to memory location
' based on Microsoft Access coordinates.
'---------------------------------------------
junk = BitBlt(hdcMem, 0, 0, fwidth, fheight, hdc, rect.left, _
rect.top, SRCCOPY)
'---------------------------------------------
' Set up the Clipboard and copy bitmap
'---------------------------------------------
junk = OpenClipboard(DeskHwnd)
junk = EmptyClipboard()
junk = SetClipboardData(CF_BITMAP, hBitmap)
junk = CloseClipboard()
End If
'---------------------------------------------
' Clean up handles
'---------------------------------------------
junk = DeleteDC(hdcMem)
junk = ReleaseDC(DeskHwnd, hdc)
DoCmd Hourglass False
End Function
Additional query words: dump
Keywords: kbhowto kbprogramming KB100973