Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: mk sharma
  Where is mk sharma?
 mumbai
 India
 mk sharma
 To: Murali Narayanan
  Where is Murali Narayanan?
 Mumbai
 India
 Murali Narayanan
 Tags
Subject: RE: embed printer settings in report
Thread ID: 416275 Message ID: 416306 # Views: 40 # Ratings: 2
Version: Visual FoxPro 9 SP2 Category: Reports and Printers
Date: Friday, December 26, 2014 3:25:00 PM         
   


> Thanks,
> I would really like to know how to hack the report file.
> Murali
>
> >
> > So then you need to allow the user to select the correct printer with the correct settings?
> > You can use this code that I wrote a while back, that brings up the windows printer prompt and returns the settings that the user selected, the rest is up to you to 'hack< your report to incorporate the setting into your report environment.
> > http://www.atoutfox.org/articles.asp?ACTION=FCONSULTER&ID=0000000797
> >
> > Mike Gagnon

Download the Class From Below Link
http://www.atoutfox.org/articles.asp?ACTION=FCONSULTER&ID=0000000797



** Use Below code to Hack the Frx

m.lc_Report = FULLPATH("test.frx") && Your Report here

SET CLASSLIB TO pdialog ADDITIVE
m.o=CREATEOBJECT("pdialog.pdialog")
m.o.showprinter()

IF !EMPTY(m.o.printername)
	SET PRINTER TO NAME (m.o.printername)

	akt_sel = SELECT(0)
	
	m.lc_Tmp_Report = ADDBS(SYS(2023)) + SYS(2015) + '.FRX'
	
	*- Copy report into Temp-Report
	COPY FILE (JUSTPATH(FULLPATH(m.lc_Report))+'\'+JUSTSTEM(m.lc_Report)+'.FRX') TO (m.lc_Tmp_Report)
	COPY FILE (JUSTPATH(FULLPATH(m.lc_Report))+'\'+JUSTSTEM(m.lc_Report)+'.FRT') TO (STRTRAN(m.lc_Tmp_Report,'.FRX','.FRT'))
	
	*- Modify Temp-Report
	USE (m.lc_Tmp_Report) ALIAS _TMP_Report IN 0
	SELECT _TMP_Report 
	LOCATE FOR Objtype = 1 AND Objcode = 53 
	REPLACE tag WITH "", tag2 WITH "" IN _TMP_Report 	&& Clear Tag/Tag2
	
	lc_Expr = ""
	=ALINES(larr_Expr,_TMP_Report.Expr,1+4)
	SET EXACT OFF

	*- Orientation
	Expr_Replace(@larr_Expr,'ORIENTATION',o.ORIENTATION - 1)
	*- Papersize
	Expr_Replace(@larr_Expr,'PAPERSIZE',o.PAPERSIZE)
	*- COLOR
	Expr_Replace(@larr_Expr,'COLOR',o.COLOR)
	*- DUPLEX
	Expr_Replace(@larr_Expr,'DUPLEX',o.DUPLEX)
	*- COPIES
	Expr_Replace(@larr_Expr,'COPIES',o.papercopies)
	*- DEFAULTSOURCE
	Expr_Replace(@larr_Expr,'DEFAULTSOURCE',o.DEFAULTSOURCE)
	*- COLLATE
	Expr_Replace(@larr_Expr,'COLLATE',o.COLLATE)
	*- SCALE
	Expr_Replace(@larr_Expr,'SCALE',o.Paperscale)
	*- PRINTQUALITY
	Expr_Replace(@larr_Expr,'PRINTQUALITY',o.PRINTQUALITY)
	*- YRESOLUTION
	Expr_Replace(@larr_Expr,'YRESOLUTION',o.YRESOLUTION)
	*- TTOPTION
	Expr_Replace(@larr_Expr,'TTOPTION',o.TTOPTION)
	*- PAPERLENGTH
	Expr_Replace(@larr_Expr,'PAPERLENGTH',o.PAPERLENGTH)
	*- PAPERWIDTH
	Expr_Replace(@larr_Expr,'PAPERWIDTH',o.PAPERWIDTH)

	*- Build 
	FOR ln_i = 1 TO ALEN(larr_Expr,1)
		lc_Expr = lc_Expr + larr_Expr(m.ln_i) + CHR(13)
	ENDFOR
	
	REPLACE Expr WITH m.lc_Expr IN _TMP_Report
	
	USE IN SELECT('_TMP_Report')
	
	*- Run Temp-Report
	SELECT (akt_sel)
	REPORT FORM (m.lc_Tmp_Report) NEXT 1 NOCONSOLE TO PRINTER 
	
	* Delete Temp-Report
	DELETE FILE (m.lc_Tmp_Report)
	DELETE FILE (STRTRAN(m.lc_Tmp_Report,'.FRX','.FRT'))
	
	
	SET PRINTER TO DEFAULT
ENDIF 

PROCEDURE Expr_Replace
**********
LPARAMETERS tarr_Expr, tc_Searched, t_Value
LOCAL ln_Pos, lc_Exact 

m.lc_Exact = SET("Exact")
SET EXACT OFF 

m.ln_Pos = ASCAN(m.tarr_Expr,m.tc_Searched)
IF m.ln_Pos > 0
	m.tarr_Expr(m.ln_Pos) = m.tc_Searched + "="+TRANSFORM(m.t_Value)
ELSE
	DIMENSION m.tarr_Expr(ALEN(m.tarr_Expr,1)+1)
	m.tarr_Expr(ALEN(m.tarr_Expr)) = m.tc_Searched + "="+TRANSFORM(m.t_Value)
ENDIF
SET EXACT &lc_Exact.
ENDPROC	&& Expr_Replace  




Warm Regards,
mk.

ENTIRE THREAD

embed printer settings in report Posted by Murali Narayan @ 12/25/2014 5:13:03 PM
RE: embed printer settings in report Posted by Mike Gagnon @ 12/26/2014 1:44:47 PM
RE: embed printer settings in report Posted by Murali Narayan @ 12/26/2014 2:05:00 PM
RE: embed printer settings in report Posted by Mike Gagnon @ 12/26/2014 2:32:14 PM
RE: embed printer settings in report Posted by Murali Narayan @ 12/26/2014 3:21:17 PM
RE: embed printer settings in report Posted by mk sharma @ 12/26/2014 3:25:00 PM