Groups | Search | Server Info | Keyboard shortcuts | Login | Register
Groups > comp.databases.ms-access > #811
| From | "Phil" <phil@stantonfamily.co.uk> |
|---|---|
| Newsgroups | comp.databases.ms-access |
| Subject | Dump a subform to paint |
| Date | 2011-04-05 11:02 +0100 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <inepcg$6ud$1@speranza.aioe.org> (permalink) |
I need to save a subform to MS paint.
Background. I want to be able to print transparent images (with writing on
them). I can create the transparent images on a form OK, and also on a report
in Design view. However, due to a bug??? in Access 2010, when the report is
in print preview the images become opaque.
So I have partially got out of the problem by dumping the picture to the
Clipboard, and pasting it into paint. Prints perfectly from there. My problem
is that I am saving the whole screen to the clipboard, whereas I want to save
just a subform which has all the images on it.
Sorry - lot of code, much of which I don't understand. Can anyone suggest the
modifications to save only Subform3 which is a sub form of Form2 Thanks
Phil
Type RECT_Type
left As Long
top As Long
right As Long
bottom As Long
End Type
'The following declare statements are case sensitive.
Declare Function GetActiveWindow Lib "User32" () As Long
Declare Function GetDesktopWindow Lib "User32" () As Long
Declare lare Sub GetWindowRect Lib "User32" (ByVal Hwnd As Long, lpRect As
RECT_Type) Declare Function GetDC Lib "User32" (ByVal Hwnd As Long) As Long
Declare lare Function CreateCompatibleDC Lib "Gdi32" (ByVal hdc As Long) As
Long Declare Function CreateCompatibleBitmap Lib "Gdi32" (ByVal hdc _
As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
Declare Function SelectObject Lib "Gdi32" (ByVal hdc As Long, _
ByVal hObject As Long) As Long
Declare Function BitBlt Lib "Gdi32" (ByVal hDestDC As Long, _
ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, _
ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal XSrc As Long, _
ByVal YSrc As Long, ByVal dwRop As Long) As Long
Declare Function OpenClipboard Lib "User32" (ByVal Hwnd As Long) As Long
Declare Function EmptyClipboard Lib "User32" () As Long
Declare Function SetClipboardData Lib "User32" (ByVal wFormat As Long, _
ByVal hMem As Long) As Long
Declare Function CloseClipboard Lib "User32" () As Long
Declare Function ReleaseDC Lib "User32" (ByVal Hwnd As Long, _
ByVal hdc As Long) As Long
Declare Function DeleteDC Lib "Gdi32" (ByVal hdc As Long) As Long
Global Const SRCCOPY = &HCC0020
Global Const CF_BITMAP = 2
Function ScreenDump()
Dim AccessHwnd As Long, DeskHwnd As Long
Dim hdc As Long
Dim hdcMem As Long
Dim rect As RECT_Type
Dim junk As Long
Dim fwidth As Long, fheight As Long
Dim hBitmap As Long
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 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
Private Sub Output_Click()
Dim Paint As Integer
On Error GoTo Output_Click_Error
ScreenDump ' Dump form to clipboard
' Paint
Paint = Shell("C:\Windows\System32\MSPaint.Exe", vbNormalFocus)
DoEvents
Activate:
Call apWait(1, True)
AppActivate Paint, False
DoEvents
SendKeys "^v"
Exit Sub
Output_Click_Error:
If Err = 5 Then ' Invalid procedure call or argument
Resume Activate
Else
MsgBox MsgBox "Error " & Err.Number & " (" & Err.Description & ") in
procedure Output_Click of VBA Document Form_Form3" End If
End Sub
Back to comp.databases.ms-access | Previous | Next — Next in thread | Find similar
Dump a subform to paint "Phil" <phil@stantonfamily.co.uk> - 2011-04-05 11:02 +0100
Re: Dump a subform to paint "zuckermanf@gmail.com" <zuckermanf@gmail.com> - 2011-04-05 07:55 -0700
Re: Dump a subform to paint "Phil" <phil@stantonfamily.co.uk> - 2011-04-05 18:04 +0100
Re: Dump a subform to paint The Frog <mr.frog.to.you@googlemail.com> - 2011-04-05 08:29 -0700
Re: Dump a subform to paint "Phil" <phil@stantonfamily.co.uk> - 2011-04-05 18:00 +0100
Re: Dump a subform to paint The Frog <mr.frog.to.you@googlemail.com> - 2011-04-06 00:25 -0700
Re: Dump a subform to paint imb <imb4u@onsmail.nl> - 2011-04-06 01:08 -0700
Re: Dump a subform to paint "JHB" <jhb183@hotmail.com> - 2011-04-06 14:15 +0200
Re: Dump a subform to paint "Phil" <phil@stantonfamily.co.uk> - 2011-04-06 15:00 +0100
csiph-web