Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Hiding the Printing window
Message
 
 
To
02/10/2002 16:41:02
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Miscellaneous
Thread ID:
00707087
Message ID:
00707095
Views:
32
Hi Manuel,

I faced similar situation, as yours. You can not hide this window, but you can move it outside the screen (tip by Cathy Pountney):
********************************************************************
*  Description.......: Hides Printing window
*  Calling Samples...:
*  Parameter List....:
*  Created by........: Cathy Pountney  #028660
*  Modified by.......: 
********************************************************************
if wexist('Printing...')
	move window 'Printing...' to -1000, -1000
endif
wait window nowait "Processing report... Please, wait..."
return ''
*********************
*!*	DECLARE INTEGER GetDesktopWindow IN WIN32API
*!*	DECLARE INTEGER LockWindowUpdate IN WIN32API INTEGER lnHandle
*!*	hWin = GetDeskTopWindow()
*!*	LockWindowUpdate(hWin)
*!*	*COMPILE 123.prg
*!*	REPORT FORM x TO PRINT
*!*	LockWindowUpdate(0)
This function could be called from the title of your report.

The commented code shows, how to supress this window completely. It's a little bit dangerous, because program could not respond in case of error... (you would have to kill VFP).

Now, you can either use animation (start it before report command) or create a progress bar. I finally choose animation for simplicity. Here is the sample:
********************************************************************
*  Description.......: SpecialMTD() - initializes MTD Report
*  Calling Samples...:
*  Parameter List....: tcTable, tlPDF, tlChooseVersion
*  Created by........: Nadya Nosonovsky 01/08/2001 11:02:27 AM
*  Modified by.......: Nadya Nosonovsky 02/11/2002 01:36:41 PM
********************************************************************
lparameter tcTable, tlPDF, tlChooseVersion
if empty(m.tcTable)
	if vartype(oJC)="O"
		tcTable=oJC.outTable
	else
		tcTable="\redp\output\Products\mtd\MTDCT0011Toll" && For tests only
	endif
endif
local lnSelect, loMessage, lcMessageCaption, ccAviFile, lnResult, llProcessed, ;
	  llReturn
llReturn = .t.
llProcessed = .f.
lnResult = 0
lnSelect=select()

if !OpenTble(m.tcTable,"WorkTable",,"Situs")
	return .f.
endif
if vartype(oJC)="O"
	oJC.StepRecCount=reccount("WorkTable")
endif

&& Updated:NN: 07/02/02 - don't run report for no records
if reccount("WorkTable")= 0 && No transactions for these towns    
   return .f.
endif   
*!*	select WorkTable
*!*	locate for BlankPage=.t.
*!*	if found() && Already processed
*!*		llProcessed = .t.
*!*	endif

*!*	if !m.llProcessed
*!*		#define icMessageBoxCaption "Preparing MTD Report..."
*!*		private llHidePrinting
*!*		llHidePrinting=.t.
*!*		local lcFileName
*!*		llReturn=.t.
*!*		if vartype(m.gcTempPath)='C'
*!*			lcFileName=addbs(m.gcTempPath)+'dummy.pdf'
*!*		else
*!*			lcFileName=addbs(sys(2023))+'dummy.pdf'
*!*		endif
*!*	endif

if m.tlChooseVersion
	if not 'vfpevent.fll' $ lower(set('library'))
		set library to vfpEvent.fll additive
	endif
	#include foxpro.h
	lnResult =  EventMBox("Do you want to produce PDF or print directly ?", ;
		MB_YESNOCANCEL + MB_ICONQUESTION + MB_DEFBUTTON2, ;
		"Which report type?", ;
		"&PDF", ;
		"&To Printer", "&Cancel")
endif

do case
case m.tlPDF or (m.tlChooseVersion and m.lnResult = IDYES)
*!*		if !m.llProcessed
*!*			if CreatePDF(m.lcFileName)
*!*				lcMessageCaption = 'Printing to PDF'
*!*				ccAviFile = "DocToPdf2.avi"
*!*				loMessage = newobject("Animation", "Animation.vcx", "", ; && Now use Daniel's vcx class instead
*!*				lcMessageCaption, ;
*!*					icMessageBoxCaption, ;
*!*					ccAviFile)
*!*				set message to m.lcMessageCaption
*!*				loMessage.show()
*!*				report form XPMTDReport to printer noconsole
*!*				delete file (m.lcFileName)
*!*				release loMessage
*!*			else
*!*				llReturn =.f. && Failure
*!*			endif
*!*		endif
	
	if m.llReturn and !CreatePDF(m.tcTable)
		llReturn=.f.
	endif
	
case (m.tlChooseVersion and m.lnResult = IDNO) && Printed version
*!*		if not m.llProcessed
*!*			lcMessageCaption = 'Printing to temp file'
*!*			ccAviFile = "Printing.avi"
*!*			loMessage = newobject("Animation", "Animation.vcx", "", ; && Now use Daniel's vcx class instead
*!*			lcMessageCaption, ;
*!*				icMessageBoxCaption, ;
*!*				ccAviFile)
*!*			set message to m.lcMessageCaption
*!*			loMessage.show()
*!*			report form XPMTDReport to file (m.lcFileName) noconsole
*!*			delete file (m.lcFileName)
*!*			release loMessage
*!*		endif
otherwise
	llReturn = .f. && User canceled
endcase
wait clear
if !m.llReturn
	use in select('WorkTable')
endif
select (m.lnSelect)
return m.llReturn
See the commented code. The reason, this code is commented, is that with Cathy and Sergey Berezniker's help I was able to generate this report in one pass instead of original two (where I showed animation)...


>Hi There
>
>Is there a way to eliminate or "hide" the window that appears when you send a report to a printer?
>
>I need to do it in order to show mine.
>
>My window has a timer and in the timer event it changes the image to simulate a printer "printing".
>
>I've tried Hiding the window "printing" from the report but the window does not release the focus to my own window.
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform