Resumen Detectar si ya está abierta una venta de Crystal Report

Mensaje enviado por "Marcelino Pastor Martin" <marce2@teleline.es>

Hola Omar:
Te mando un articulo sacado de KBase de Crystal, referente a tu primera pregunta, espero sea lo que necesitas.

Marcelino Pastor Martin
MARCE2@teleline.es


Detecting when the Crystal preview window is closed with the OCX control


The information in the article refers to:
Seagate Crystal Reports 8


Applies to:

Reported version only
Crystal ActiveX (OCX) control
Preview window
Detecting when the preview window is closed


Synopsis

After previewing a report using the Crystal ActiveX (OCX) control, is there any way to detect when the preview window has been closed?

Solution

There are no events which are programmed into the OCX control to determine when an event occurs on the preview window (such as clicking the Close button). However the following Microsoft Visual Basic code segment shows how you can simulate this using Microsoft Windows API calls:

' Declare the following Windows API declarations in a Visual Basic Module (BAS) file:

Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal _
lpClassName As Any, ByVal lpWindowName As Any) As Long

Public Declare Function IsWindow Lib "user32" (ByVal hWnd As Long) As Long


' Preview the report on a form using an OCX control.
' This example uses a command button to preview the report

Private Sub cmdReport_Click()

     ' Declare a Long for the Crystal preview window handle
     Dim hWndPreviewWindow As Long

     ' Set the report filename
     CrystalReport1.ReportFileName = App.Path & "/report.rpt"

     ' The WindowTitle property needs to be set in order to get the window handle
     CrystalReport1.WindowTitle = "Crystal Report"
     CrystalReport1.Action = 1

     ' Get the window handle for the preview window. This references the window title
     ' (on the title bar) of the Crystal preview window to obtain it's handle. This assumes
     ' that no other window will have the same Window title, and that there is only one
     ' preview window being displayed at a time.
     hWndPreviewWindow = FindWindow(vbNullString, CrystalReport1.WindowTitle)

     ' Determine whether the handle to the preview window still exists (preview window not closed)
     Do While IsWindow(hWndPreviewWindow)
         DoEvents
     Loop

     ' Insert any code here to be done after the preview window is closed
     MsgBox "Preview Window closed"

End Sub


==

This example assumes that only one Crystal preview window is displayed at a time.


NOTE: =====

The Crystal Report Viewer for ActiveX (CRViewer.dll) used to preview reports with Crystal Report Designer Component (RDC) contains built in functionality for recognizing when the preview window (viewer) is closed. Clicking the close button on the viewer triggers the 'CloseButtonClicked' event in the 'CRViewer' object.

For more information on migrating from the OCX control to the RDC, refer to the document:

scr8-ocxtordc.pdf

in the Documentation area of the Seagate Software Support web site at:

http://www.seagatesoftware.com/docs

=========



Resumen Resumen

Visual Basic Página de Visual Basic

Página principal Página principal

www.jrubi.com