Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Vladimir Zhuravlev
  Where is Vladimir Zhuravlev?
 Medvezhie ozera, Schelkovskiy raion
 Russia
 Vladimir Zhuravlev
 To: Luca Moioli
  Where is Luca Moioli?
 Venezia
 Italy
 Luca Moioli
 Tags
Subject: RE: Print Screen
Thread ID: 134034 Message ID: 134089 # Views: 29 # Ratings: 0
Version: Visual FoxPro 9 Category: Win32API programming
Date: Thursday, June 07, 2007 1:49:51 PM         
   


Here is one my very encient code to
to print any vfp form,
if we put on this form common dialog activex with name
olecontrol1
We need it to get printer handle content.
In the code this is also commets without this control
The lack of this code is printer picture size
It can be fixed by using getdevicecaps winipi

dimension ss(19)
ss(1) = 66 
ss(2) = null
ss(3) = null
ss(4) = null
ss(5) = null
ss(6) = null
ss(7) = 1
ss(8)= 1
ss(9)= null 
ss(10) = null 
ss(11)= 1
ss(12)= null
ss(13) = null
ss(14)= NULL 
ss(15) = NULL 
ss(16) = null
ss(17) = null 
ss(18) = null
ss(19) = null
*

declare INTEGER PrintDlg in comdlg32.dll INTEGER @ss[19]
* The code before is dedicated , if common dialog activex is not available on your computer 
dimension sz(5)
sz(1)=20
sz(2)=0
sz(3)=0
sz(4)=0
sz(5)=0
declare INTEGER GetForegroundWindow in user32.dll
declare INTEGER GetActiveWindow in user32.dll
declare INTEGER GetWindowDC in user32.dll INTEGER HDC 
declare INTEGER DeleteDC in gdi32.dll INTEGER HDC
declare INTEGER GetDC in user32.dll INTEGER HDC
declare INTEGER ReleaseDC in user32.dll INTEGER HDC,INTEGER HWD
declare INTEGER StartDoc in gdi32.dll integer hdcPrint, integer @sz[5], ;
integer fn, integer ou , integer dt, integer fw 
declare integer StartPage in gdi32.dll integer hdcprint
declare integer EndPage in gdi32.dll integer hdcprint
declare integer EndDoc in gdi32.dll integer hdcprint
declare integer GetDeviceCaps in gdi32.dll integer i, integer ii
declare SHORT BitBlt in gdi32.dll INTEGER HDC, ;
INTEGER nXDest, ;
INTEGER nYDest, ;
INTEGER nWidth, ;
INTEGER nHeight,;
INTEGER hdcSrc, ;
INTEGER nXSrc, ;
INTEGER nYSrc, ;
INTEGER dwRop
hd=GetForegroundWindow()
hwd=GetDC(hd)
hd1=GetACTIVEWindow()
hwd1=GetWindowDC(hd1) 
thisform.olecontrol1.flags=256 
* some printers require thisform.olecontrol1.flags=512 
* check out hdc<>0 
thisform.olecontrol1.flags=256 
thisform.olecontrol1.showprinter()
thisform.olecontrol1.flags=256 
phd=thisform.olecontrol1.hdc
*********************************************** * in case common dialog is not available on your computer 
* use the following code instead of the calling common dialog before 
ss(1) = 66 
ss(2) = hd 
ss(3) = 0 
ss(4) = 0 
ss(5) = 0
ss(6) = 0x100
ss(7) = 1
ss(8)= 1
ss(9)= 0
ss(10) = 0
ss(11)= 1
ss(12)= 0
ss(13) = 0
ss(14)= NULL 
ss(15) = NULL
ss(16) = null
ss(17) = null
ss(18) = 0
ss(19) = 0
=PrintDlg(@ss) 
phd=ss[5]
*************************************************
if phd<=0 
wait window 'Printer is not ready or not selected' 
endif 
*!* if getdevicecaps(phd,0x2)!=2
*!* * look technology parameter in win32api.txt
*!* wait window 'Your printer does not support raster copy '
*!* return 
*!* endif' 
*!* if (2*int(getdevicecaps(phd,38)/2)-getdevicecaps(phd,38))=0
*!* * look capability parameter in win32api.txt
*!* wait window 'Your printer does not support BITS transfer operation'
*!* return 
*!* endif
if StartDoc(phd,@sz)<=0 
wait window 'Some problems with printer'
return 
endif 
=startPage(phd)
thisform.text1.value=BitBlt(phd,10,10,5 ,thisform.width,5,thisform.height,hwd ,thisform.left,thisform.top,0xCC0020) 
* for those who has luck, it will make nice copy of the form on the printer, much better than printscreen
=ReleaseDc(hd,hwd)
=ReleaseDc(hd1,hwd1) 
=EndPage(phd)
=EndDoc(phd) 
=DeleteDC(phd)




MVP , www.foxclub.ru domain owner
100 friends are better than 100 dollars.

COMPLETE THREAD

Print Screen Posted by Luca Moioli @ 6/6/2007 6:18:10 PM
RE: Print Screen Posted by Cesar Chalom @ 6/6/2007 6:56:10 PM
RE: Print Screen Posted by Luca Moioli @ 6/7/2007 6:45:31 AM
RE: Print Screen Posted by Vladimir Zhuravlev @ 6/7/2007 1:49:51 PM
RE: Print Screen Posted by Cesar Chalom @ 6/7/2007 2:12:03 PM
RE: Print Screen Posted by Vladimir Zhuravlev @ 6/7/2007 3:09:30 PM
RE: Print Screen Posted by Cesar Chalom @ 6/7/2007 4:57:47 PM
RE: Print Screen Posted by Vladimir Zhuravlev @ 6/8/2007 8:27:56 AM
RE: Print Screen Posted by Luca Moioli @ 6/7/2007 2:48:59 PM