1//*************************************************************************
2//* *
3//* Confidential Trade Secret. *
4//* Copyright (c) 2011-2012 Mertech Data Systems Inc, Miami Florida *
5//* All rights reserved. *
6//* DataFlex is a registered trademark of Data Access Corporation. *
7//* *
8//*************************************************************************
9Use DFADlg.pkg
10Use cFlex2CrystalActiveXReportViewer.pkg
11
12Class cFlex2CrystalPreview is a View
13
14 Procedure Construct_Object
15 Handle hoViewer
16 Integer liCapBarHeight ix iy iSize
17
18 Property Handle phoActiveXReportViewer 0
19 Property Integer piZoom 1 // 1- fit width, 2 fit page, all other numbers are a percentage
20 Property Boolean pbOpenMaximized False
21
22
23 Forward Send Construct_Object
24
25 Set Border_Style to Border_Thick
26 Set Maximize_Icon to True
27
28 Set Size to 300 420
29 Set piMinSize to 300 420
30 Get Create U_cFlex2CrystalActiveXReportViewer to hoViewer
31 Send CreateComObject of hoViewer
32
33 Set Location of hoViewer to 0 0
34 Set phoActiveXReportViewer to hoViewer
35 Move (GetSystemMetrics(SM_CYCAPTION)) to liCapBarHeight
36
37 Get GuiSize to iSize
38 Move (Hi(iSize)) to iy
39 Move (Low(iSize)) to ix
40
41 #IF (!@<140)
42 Set GuiSize of hoViewer to (iy - liCapBarHeight -2 ) (ix -2) // window size same as parent client area size
43 #ELSE
44 Set GuiSize of hoViewer to (iy - 2) (ix -2) // window size same as parent client area size
45 #ENDIF
46 Send Adjust_Logicals of hoViewer
47 Set peAnchors of hoViewer to anAll
48
49 End_Procedure
50
51 Procedure Entering_Scope Returns Integer
52 Integer iRetval
53 Forward Send Entering_Scope to iRetval
54 If (pbOpenMaximized(Self)) Begin
55 Set View_Mode to ViewMode_Zoom
56 End
57 End_Procedure
58
59 //Displays report in the preview control.
60 Procedure DisplayReport Handle hoReport
61 Handle hoViewer
62 Get phoActiveXReportViewer to hoViewer
63 If (hoViewer) Begin
64 Send Popup
65 Set ComReportSource of hoViewer to (pvComObject(hoReport))
66 Send ComRefresh of hoViewer
67 Send ComZoom of hoViewer (piZoom(Self))
68 End
69 Else Begin
70 Error DFERR_CRYSTAL_REPORT C_$CrystalCOMPreviewerNotCreated
71 Send Destroy
72 End
73 End_Procedure // DisplayReport
74
75 //Destroy report when it is closed.
76 { NoDoc=True }
77 Procedure Deactivate Integer iScope Returns Integer
78 Integer iRet
79 If (Num_Arguments) Begin
80 Forward Get msg_Deactivate iScope to iRet
81 End
82 Else Begin
83 Forward Get msg_Deactivate to iRet
84 Send Destroy
85 End
86 End_Procedure
87
88End_Class