PDA

Click to See Complete Forum and Search --> : Trap 'close' in Crystal viewer?


Anakim
Jan 10th, 2001, 03:37 AM
I think this comes under the API juristiction.....

How can I catch the 'close' event from a Crystal Report viewer preview window? The help given in the Seagate help files doesn't help me much.

I do something like.....

Set crwApp = CreateObject("Crystal.crpe.application")
Set crReport = crwApp.OpenReport("D:\DVD Ordering System\Reports\DVD002.rpt")
Set repView = crReport.Preview


which is fine except that the viewer is not modal. I either want to be able to set the view to modal or loop until the viewer is closed by the user - but I don't know how to achieve either. The help does mention API calls but these examples aren't in VB, and I'm far too much of a cabbage to figure out how to translate them!

Aaron Young
Jan 10th, 2001, 12:47 PM
You can use the IsWindow API on the Views Parent's WindowHandle property, i.e.Private Declare Function IsWindow Lib "user32" (ByVal hwnd As Long) As Long

Private Sub cmdOpen_Click()
Set crwApp = CreateObject("Crystal.crpe.application")
Set crReport = crwApp.OpenReport("D:\DVD Ordering System\Reports\DVD002.rpt")
Set repView = crReport.Preview

While IsWindow(repView.Parent.WindowHandle)
DoEvents
Wend

MsgBox "Done"
End Sub

Anakim
Jan 11th, 2001, 03:25 AM
Thanks Aaron, I'd got some assistance on this from another thread. Think Seagate should add a nicer interface to their viewer to allow this without API's though!