Page 1 of 1

How destroy a preview report object

Posted: Mon Oct 24, 2005 7:55 am
by Piscicelli Zingoni
Hi,
if have:
report oRep preview
.
.
.
end report
.
.
i need later to destroy the preview (also to avoid a second prevew error)

i tried with
oRep:end() and also
oRep:oDevice:end() but them dont work !

Any help ?
Tks
Piscicelli/Zingoni

Posted: Mon Oct 24, 2005 8:45 am
by Vladimir Grigoriev
I advice to define all objects (as all other program variables) as local (or static). After performing the general destroy method for most of objects (oObject:end()) assign NIL value to a object variable. I.e.

oObject:end()
oObject := NIL

I usually use the following command for the statements above
RELEASE OBJECT oObject
where OBJECT should be replaced with the specific class name
For example
RELEASE METER oMeter.

Re: How destroy a preview report object

Posted: Mon Oct 24, 2005 9:30 am
by Enrico Maria Giordano
I think you would have to End() the preview window but its variable oWnd is static inside rpreview.prg. I don't think it's possible to do what you're asking for without modifying rpreview.prg.

EMG

Posted: Mon Oct 24, 2005 10:06 am
by Vladimir Grigoriev
In my turn I think that there is no matter how oWnd is declared. Either a new report object should (and indeed does) rerwite oWnd value or the end() method should assign it to NIL (I have not seen the source code; it is general remarks). If this is not the truth then class REPORT should be corrected.

Re: How destroy a preview report object

Posted: Mon Oct 24, 2005 10:28 am
by Enrico Maria Giordano
I agree, but I don't think it is possible as TReport is today.

EMG

Posted: Tue Feb 19, 2008 11:28 am
by Otto
Is there a solution for closing preview from outside the preview available.
Regards,
Otto

Posted: Tue Feb 19, 2008 11:34 am
by Enrico Maria Giordano
If you have created the TPreview object for yourself then try

Code: Select all

oPreview:oWnd:End()
EMG

Posted: Tue Feb 19, 2008 3:28 pm
by Otto
Hello Enrico,

I tried your suggestion but it does not work.

> If you have created the TPreview object for yourself then try
no. PRINTER created the TPreview

I had a look into printer-class:

METHOD Preview() INLINE If( ::lMeta .and. Len( ::aMeta ) > 0 .and. ::hDC != 0,;
RPreview( Self ), ::End() )

If I understand this right printer calls Rpreview and Printer is ended.

So there is no connection anymore to the event which called the Rpreview.

If you look into Property Inspector the Parent Window of Preview is the MainWindow of the application.
Regards,
Otto

Posted: Tue Feb 19, 2008 3:34 pm
by Enrico Maria Giordano
Without the handle to the TPreview object you can't close it.

EMG

Posted: Tue Feb 19, 2008 4:17 pm
by Otto
Do you maybe know a way how to get a handle?

Regards,
Otto

Posted: Tue Feb 19, 2008 4:49 pm
by Enrico Maria Giordano
Through FindWindow(), but you must know the title of the preview window.

EMG

Posted: Tue Feb 19, 2008 5:10 pm
by Otto
Thank you Enrico.

That’s what I do now.

I changed printer.prg

printer.prg
DATA cFile

METHOD New( cDocument, lUser, lMeta, cModel, lModal, lSelection, cFile ) CONSTRUCTOR

METHOD ImportWMF( cFile, lPlaceable ) CLASS TPrinter
local hMeta, hOld, hWMF
local aData := PrnGetSize( ::hDC )
local aInfo := Array( 5 )

::cFile := cFile



and preview.prg
rprinter.prg
cTitle := ::oDevice:cFile

Now I have the title and with FindWindow() I will – I hope so –
get the handle.

Thanks again,
Regards,
Otto