How destroy a preview report object

Post Reply
Piscicelli Zingoni
Posts: 76
Joined: Wed Oct 12, 2005 5:52 pm
Location: Milan,Italy

How destroy a preview report object

Post 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
Vladimir Grigoriev
Posts: 54
Joined: Fri Oct 21, 2005 10:45 am
Location: Russia, Moscow
Contact:

Post 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.
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: How destroy a preview report object

Post 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
Vladimir Grigoriev
Posts: 54
Joined: Fri Oct 21, 2005 10:45 am
Location: Russia, Moscow
Contact:

Post 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.
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Post by Otto »

Is there a solution for closing preview from outside the preview available.
Regards,
Otto
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

If you have created the TPreview object for yourself then try

Code: Select all

oPreview:oWnd:End()
EMG
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Post 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
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

Without the handle to the TPreview object you can't close it.

EMG
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Post by Otto »

Do you maybe know a way how to get a handle?

Regards,
Otto
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

Through FindWindow(), but you must know the title of the preview window.

EMG
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Post 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
Post Reply