Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Drawing / printing shapes in VFP ?
Message
De
04/07/2002 01:03:53
Vladimir Zhuravlev
Institute of the Physics of Earth,Russia
Moscow Region, Russie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00675170
Message ID:
00675238
Vues:
13
>Is drawing and printing shapes too fiddly in VFP to try natively ?
>
>eg. Getting user to enter lengths and angles in a triangle and displaying on
>form - printing on report.
>
>Has anyone done this sort o thing ? Or do I create some sort of class in VB ...
>
>Cheers,
>Jamie
Jamie
Here is the code, how to print all from the form
I made coment, where changes are required to provide good quality
If you will do it,please inform me, because I use now Delphi for this goal.
Vladimir

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()
* The handle of the Fox window
hwd=GetDC(hd)
hd1=GetACTIVEWindow()
hwd1=GetWindowDC(hd1)
* 2 options , with common dialog activex and without it
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'
*
* The folowing commented code must be completed to provide good printer copy
*!* 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-2006-2011, PHD in Math and Physics ,
host of www.foxclub.ru,
VFP lector at Interface and Microinform companies
Head science researcher of VNIIA Rosatom.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform