Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print Sreen/screen shot problem 1

Status
Not open for further replies.

hawkieboy

Programmer
Apr 30, 2002
49
0
0
GB
Hi

i am having trouble finding a way of enabling the user to be able to click a button which captures the active form and prints it(ie. the same as pressing "prt scr" and pasting it in word then printing it). is this possible if so could you please point me in the right direction


your help is appreciated in advance



 
HawkieBoy,

I use the following code which I got from someone else which pastes the form into the clipboard, which gets you most of the way. It works for me.

Hope it helps,

Stewart

Code:
* Author : Mauricio Atanache G.* Date : December 10/97
* This function puts the image of the form in the clipboard, you can use
* it to send form images to other aplications as Word etc.
* Also you can modify this function to print or copy any object on* screen.
* Parameters : oForm is an object FORM, for example THISFORM,ACTIVEFORM, _SCREEN
**************************************************************************
*Function TomaFoto
******************
lParameters oForm
Local nHwnd, tnHwnd, hDC, hDC_Mem, hBitMap, hPrevBmp
* Must use the Foxtools library, somewhere.
Declare integer FindWindow in Win32Api String cClassName, String cWindName
Declare integer GetDC in Win32Api integer nhwnd
Declare integer CreateCompatibleDC in Win32Api integer nhcd
Declare Integer BitBlt in Win32Api Integer hDestDC, Integer x, Integer y, ;
	Integer nWidth, Integer nHeight, Integer hScrDC, ;
	Integer xsrc, Integer ysrc, Integer dwRop
Declare Integer SelectObject in Win32Api Integer hDC, Integer hObject
Declare Integer CreateCompatibleBitmap in Win32Api Integer hDC, Integer nWidth, ;
	Integer nHeight
Declare Integer SetClipboardData in Win32Api Integer nFormat, Integer hObject
Declare Integer DeleteDC in Win32Api Integer hDC
Declare Integer ReleaseDC in Win32Api Integer nwnd, Integer hdc
Declare Integer DeleteObject in Win32Api Integer hDC
lnwhandle = _WFindTitl(oForm.Caption)
nHwnd = _WhToHWnd(lnwhandle)
hDC = GetDC( nHwnd )
hDC_Mem = CreateCompatibleDC( hDC )
hBitMap = CreateCompatibleBitMap( hDC, oForm.Width, oForm.Height )
If hBitMap#0
	hPrevBmp = SelectObject( hDC_Mem, hBitMap )
	BitBlt( hDC_Mem, 0, 0, oForm.Width, oForm.Height, hDC, 0, 0, 13369376 )
	If OpenClip( nHwnd )
		EmptyClip()
		SetClipboardData( 2, hBitMap )
		CloseClip()
	Else	
		MessageBox( 'Error opening the clipboard', 48, 'Message' )
	Endif
Else
	MessageBox( 'Error creating bitmap', 48, 'Menssage' )
Endif
DeleteDC( hDC_Mem )
ReleaseDC( nHwnd, hDC )
Return .t.
*******************************************
 
Stewart

thanks for the help it works great, topstuff

thanks again
Nick
 
Nick,
For another, more complete solution, go to the UT at click the Downloads picture on the left, choose Visual FoxPro, then enter "print screen" (without the quotes) in the Title box and press enter. You should get back a link to:
Print Screens from VFP November 15, 2000 22:56
Print screens and forms directly from VFP using custom classes and DibApi32.dll.

Rick
 
Hi:

For something simple that works just about anywhere ...except DOS.

If you press the ALT+PRINTSCREEN button, the screen will be captured to the clipboard. You can then go to MS Word or whatever and paste it from the clipboard.

Great for manuals or presentations.

Works for me.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top