By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,326 Members | 1,899 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,326 IT Pros & Developers. It's quick & easy.

How to constrain a screen-dump to include only the current form...

P: n/a
MLH
Last month, I posted this...

http://support.microsoft.com/d*efaul...;en-us;1009*73
shows Function Screendump(). It is code that effectively does the
same thing as pressing SHIFT-PRTSCR on your keyboard. I am
trying to modify that code to copy only the screen image of the
current form to the clipboard, rather than the entire Access window.
Here is a small snippet from the function...
'-----------------------------*----------------------
' 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 its possible to drill down the "Get window handle to Windows
and Microsoft Access" operation and do the same sort of thing
for a specific form displayed in the MS Access window, I would
like to do so. That way, when I paste the clipboard contents into
PBrush.exe, only the subject form's image appears - none of the
surrounding image data.
I need read coordinates and make assignments to rect.right,
rect.left, rect.bottom & rect.top for form in the window rather than
the window itself. Suggestions anyone?

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxx

Terry Kreft was so kind as to post an excellent recommendation...

Replace the line
AccessHwnd = GetActiveWindow()

with
AccessHwnd = Screen.ActiveForm.Hwnd

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxx

I would now like to ask for a solution that would capture some
other types of windows. Specifically, the relationships window,
the database window and the macro design window
Nov 13 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
A simple method is to use the FindWindow API. This API allows you to
find a WIndow handle by the Caption of a Window and/or its Window class.
Here is sample code showing you how to find the Relationship window.
http://www.lebans.com/saverelationshipview.htm

If you have access to Spy++ then it is easy to determine the
Caption/Class of any window you want to programmatically find. If you do
not have Spy++ then there are several Freeware alternatives out there.
Alternatively, you could go to the Access Web where you'll find a
solution produced by Dev and Terry that can be used to find the
information you require.
http://www.mvps.org/access/modules/mdl0032.htm

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"MLH" <CR**@NorthState.net> wrote in message
news:k9********************************@4ax.com...
Last month, I posted this...

http://support.microsoft.com/d*efaul...;en-us;1009*73
shows Function Screendump(). It is code that effectively does the
same thing as pressing SHIFT-PRTSCR on your keyboard. I am
trying to modify that code to copy only the screen image of the
current form to the clipboard, rather than the entire Access window.
Here is a small snippet from the function...
'-----------------------------*----------------------
' 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 its possible to drill down the "Get window handle to Windows
and Microsoft Access" operation and do the same sort of thing
for a specific form displayed in the MS Access window, I would
like to do so. That way, when I paste the clipboard contents into
PBrush.exe, only the subject form's image appears - none of the
surrounding image data.
I need read coordinates and make assignments to rect.right,
rect.left, rect.bottom & rect.top for form in the window rather than
the window itself. Suggestions anyone?

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxx

Terry Kreft was so kind as to post an excellent recommendation...

Replace the line
AccessHwnd = GetActiveWindow()

with
AccessHwnd = Screen.ActiveForm.Hwnd

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxx

I would now like to ask for a solution that would capture some
other types of windows. Specifically, the relationships window,
the database window and the macro design window


Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.