FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for CA-Clipper How destroy a preview report object
Posts: 76
Joined: Wed Oct 12, 2005 05:52 PM
How destroy a preview report object
Posted: Mon Oct 24, 2005 07:55 AM

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

Posts: 54
Joined: Fri Oct 21, 2005 10:45 AM
How destroy a preview report object
Posted: Mon Oct 24, 2005 08:45 AM

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.

Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: How destroy a preview report object
Posted: Mon Oct 24, 2005 09:30 AM

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

Posts: 54
Joined: Fri Oct 21, 2005 10:45 AM
How destroy a preview report object
Posted: Mon Oct 24, 2005 10:06 AM

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.

Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: How destroy a preview report object
Posted: Mon Oct 24, 2005 10:28 AM

I agree, but I don't think it is possible as TReport is today.

EMG

Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
How destroy a preview report object
Posted: Tue Feb 19, 2008 11:28 AM

Is there a solution for closing preview from outside the preview available.
Regards,
Otto

Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
How destroy a preview report object
Posted: Tue Feb 19, 2008 11:34 AM
If you have created the TPreview object for yourself then try

oPreview:oWnd:End()


EMG
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
How destroy a preview report object
Posted: Tue Feb 19, 2008 03:28 PM

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

Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
How destroy a preview report object
Posted: Tue Feb 19, 2008 03:34 PM

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

EMG

Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
How destroy a preview report object
Posted: Tue Feb 19, 2008 04:17 PM

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

Regards,
Otto

Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
How destroy a preview report object
Posted: Tue Feb 19, 2008 04:49 PM

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

EMG

Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
How destroy a preview report object
Posted: Tue Feb 19, 2008 05:10 PM

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

Continue the discussion