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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mgagnon's top level print preview - error when click 'x'

Status
Not open for further replies.

dc509

IS-IT--Management
Feb 27, 2003
16
US
When using the example from faq184-2490 for a print preview window and the user clicks the 'X' in the upper right corner to close the preview window, an error occurs: oprint is not an object.

It works great if the user clicks the 'door' on the tool bar to exit.

I know I can disable the 'X' with closable=.F. but I would like to keep this enabled.

The error is occuring on this line:

oPrint.Release()

How can I do this?

Thanks
David

 
dc509

Thank for pointing that out, I have amended the FAQ, and here are the changes. The reason it that when you use the "X" you in fact destroy the oPrint object, so we just check for its presence:
1. In your main program, define a window:

DEFINE CLASS printpreview as Form
titlebar = 0
Showwindow = 2 &&Top level
autocenter = .t.
name = "PrintPreview"
height = SYSMETRIC(2) && This will maximize the preview
width = SYSMETRIC(1)&& This will maximize the preview
ENDDEFINE


2. In your command button (that generates the report)

PUBLIC oPrint
oPrint= CREATEOBJECT("printPreview")
oPrint.SHOW()
REPORT FORM COUNTRY.FRX PREVIEW WINDOW PrintPreview IN WINDOW PrintPreview NOWAIT && This is borrowed from rgbean
DO WHILE EMPTY(WONTOP()) OR ;
'Printpreview' $ UPPER(WONTOP())
DOEVENTS
ENDDO
IF VARTYPE("oPrint") = "O"
oPrint.RELEASE()
ENDIF




Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Thanks for quick response!

I have found this faq very useful.

David
 
I don't mean to be a pain, but now when I click the toolbar button to close the preview the report disappears but the preview window is still there. I have to click the 'X' to close it.

 

Sorry typo...change the line:
IF VARTYPE("oPrint") = "O"

to

IF VARTYPE(oPrint) = "O"



Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Mike,

The DO WHILE LOOP with doevents will close the preview window, if the preview window is even minimised. So report preview has got to be lost, before anything else is attempted. I also blink for a suggestion. :-(



ramani :)
(Subramanian.G)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top