-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfoxrefprint.sc2
277 lines (234 loc) · 6.84 KB
/
foxrefprint.sc2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
*--------------------------------------------------------------------------------------------------------------------------------------------------------
* (EN) AUTOGENERATED - ATTENTION!! - NOT INTENDED FOR EXECUTION!! USE ONLY FOR MERGING CHANGES AND STORING WITH SCM TOOLS!!
*--------------------------------------------------------------------------------------------------------------------------------------------------------
*< FOXBIN2PRG: Version="1.21" SourceFile="foxrefprint.scx" CPID="1252" /> (Solo para binarios VFP 9 / Only for VFP 9 binaries)
*
*
DEFINE CLASS dataenvironment AS dataenvironment
*< CLASSDATA: Baseclass="dataenvironment" Timestamp="" Scale="" Uniqueid="" ClassIcon="1" />
*<PropValue>
DataSource = .NULL.
Height = 0
Left = 0
Name = "Dataenvironment"
Top = 0
Width = 0
*</PropValue>
ENDDEFINE
DEFINE CLASS frmfoxrefprint AS cfoxrefform OF "foxctrls.vcx"
*< CLASSDATA: Baseclass="form" Timestamp="" Scale="" Uniqueid="" />
*-- OBJECTDATA items order determines ZOrder / El orden de los items OBJECTDATA determina el ZOrder
*< OBJECTDATA: ObjPath="cmdPrint" UniqueID="" Timestamp="" />
*< OBJECTDATA: ObjPath="cmdCancel" UniqueID="" Timestamp="" />
*< OBJECTDATA: ObjPath="opgScope" UniqueID="" Timestamp="" />
*< OBJECTDATA: ObjPath="Cfoxlabel1" UniqueID="" Timestamp="" />
*< OBJECTDATA: ObjPath="cboSet" UniqueID="" Timestamp="" />
*< OBJECTDATA: ObjPath="lblSet" UniqueID="" Timestamp="" />
*< OBJECTDATA: ObjPath="cmdPreview" UniqueID="" Timestamp="" />
*< OBJECTDATA: ObjPath="cboReport" UniqueID="" Timestamp="" />
*< OBJECTDATA: ObjPath="Cfoxlabel2" UniqueID="" Timestamp="" />
*<DefinedPropArrayMethod>
*m: doreport
*m: updatecontrols
*p: csortcolumns
*p: ofoxref
*</DefinedPropArrayMethod>
*<PropValue>
AlwaysOnTop = .T.
AutoCenter = .T.
Caption = "Print"
cresourceid = FOXREF
csortcolumns =
Desktop = .T.
DoCreate = .T.
Height = 123
MaxButton = .F.
MinButton = .F.
Name = "frmFoxRefPrint"
ofoxref = .NULL.
Width = 426
WindowType = 1
*</PropValue>
ADD OBJECT 'cboReport' AS cfoxcombo WITH ;
BoundTo = .T., ;
Height = 21, ;
Left = 95, ;
Name = "cboReport", ;
Style = 2, ;
TabIndex = 6, ;
Top = 96, ;
Width = 241
*< END OBJECT: ClassLib="foxctrls.vcx" BaseClass="combobox" />
ADD OBJECT 'cboSet' AS cfoxcombo WITH ;
BoundColumn = 2, ;
BoundTo = .T., ;
Height = 21, ;
Left = 95, ;
Name = "cboSet", ;
Style = 2, ;
TabIndex = 2, ;
Top = 12, ;
Width = 241
*< END OBJECT: ClassLib="foxctrls.vcx" BaseClass="combobox" />
ADD OBJECT 'Cfoxlabel1' AS cfoxlabel WITH ;
Alignment = 2, ;
BackStyle = 1, ;
Caption = "Scope", ;
Height = 15, ;
Left = 106, ;
Name = "Cfoxlabel1", ;
Style = 3, ;
TabIndex = 3, ;
Top = 40, ;
Width = 33
*< END OBJECT: ClassLib="foxctrls.vcx" BaseClass="label" />
ADD OBJECT 'Cfoxlabel2' AS cfoxlabel WITH ;
Caption = "\<Report:", ;
Height = 15, ;
Left = 12, ;
Name = "Cfoxlabel2", ;
TabIndex = 5, ;
Top = 100, ;
Width = 78
*< END OBJECT: ClassLib="foxctrls.vcx" BaseClass="label" />
ADD OBJECT 'cmdCancel' AS cfoxbutton WITH ;
Cancel = .T., ;
Caption = "Cancel", ;
Left = 347, ;
Name = "cmdCancel", ;
TabIndex = 9, ;
Top = 66
*< END OBJECT: ClassLib="foxctrls.vcx" BaseClass="commandbutton" />
ADD OBJECT 'cmdPreview' AS cfoxbutton WITH ;
Caption = "Pre\<view", ;
Left = 347, ;
Name = "cmdPreview", ;
TabIndex = 8, ;
Top = 39
*< END OBJECT: ClassLib="foxctrls.vcx" BaseClass="commandbutton" />
ADD OBJECT 'cmdPrint' AS cfoxbutton WITH ;
Caption = "\<Print", ;
Default = .T., ;
Left = 347, ;
Name = "cmdPrint", ;
TabIndex = 7, ;
Top = 12
*< END OBJECT: ClassLib="foxctrls.vcx" BaseClass="commandbutton" />
ADD OBJECT 'lblSet' AS cfoxlabel WITH ;
Caption = "\<Search set:", ;
Height = 15, ;
Left = 12, ;
Name = "lblSet", ;
TabIndex = 1, ;
Top = 16, ;
Width = 78
*< END OBJECT: ClassLib="foxctrls.vcx" BaseClass="label" />
ADD OBJECT 'opgScope' AS cfoxoptiongroup WITH ;
Height = 42, ;
Left = 95, ;
Name = "opgScope", ;
TabIndex = 4, ;
Top = 47, ;
Width = 240, ;
Option1.Caption = "\<All", ;
Option1.Height = 17, ;
Option1.Left = 9, ;
Option1.Name = "Option1", ;
Option1.Top = 12, ;
Option1.Width = 55, ;
Option2.Caption = "Selected \<items only", ;
Option2.Height = 17, ;
Option2.Left = 66, ;
Option2.Name = "Option2", ;
Option2.Top = 12, ;
Option2.Width = 149
*< END OBJECT: ClassLib="foxctrls.vcx" BaseClass="optiongroup" />
PROCEDURE doreport
#include "foxpro.h"
#include "foxref.h"
LPARAMETERS lPreview
LOCAL lSuccess
LOCAL nRecordCnt
THIS.Visible = .F.
* returns negative value on error, otherwise number of records printed
m.nRecordCnt = THIS.oFoxRef.PrintReferences(THIS.cboReport.Value, m.lPreview, THIS.cboSet.Value, (THIS.opgScope.Value == 2), THIS.cSortColumns)
THIS.Visible = .T.
DO CASE
CASE m.nRecordCnt == 0
MESSAGEBOX(PRINT_NOTHING_LOC, MB_ICONINFORMATION, THISFORM.Caption)
CASE m.nRecordCnt < 0
MESSAGEBOX(ERROR_PRINT_LOC, MB_ICONINFORMATION, THISFORM.Caption)
ENDCASE
RETURN m.lSuccess
ENDPROC
PROCEDURE Init
#include "foxref.h"
LPARAMETERS oFoxRef, cSetID, cSortColumns
LOCAL i
LOCAL nCnt
LOCAL nIndex
LOCAL lA4
LOCAL oReportAddIn
LOCAL ARRAY aSearchSets[1]
DODEFAULT()
THIS.BorderStyle = 2 && fixed dialog
IF VARTYPE(cSortColumns) == 'C'
THIS.cSortColumns = cSortColumns
ENDIF
IF VARTYPE(oFoxRef) == 'O'
THIS.oFoxRef = oFoxRef
ENDIF
WITH THIS.cboSet
.AddItem("<" + ALLRESULTS_LOC + ">")
.AddListItem('', .NewItemID, 2)
IF !ISNULL(THIS.oFoxRef)
SELECT Symbol, SetID ;
FROM (THIS.oFoxRef.RefTable) ;
WHERE RefType == REFTYPE_SEARCH ;
INTO ARRAY aSearchSets
nCnt = _TALLY
FOR i = 1 TO nCnt
.AddItem(aSearchSets[i, 1])
.AddListItem(aSearchSets[i, 2], .NewItemID, 2)
ENDFOR
ENDIF
IF VARTYPE(cSetID) == 'C' AND !EMPTY(cSetID)
.Value = cSetID
ELSE
.ListIndex = 1
ENDIF
.Enabled = (.ListCount > 1)
ENDWITH
* if Paper Size for current printer is A4,
* select the A4 report by default
m.lA4 = INLIST(PRTINFO(2), 9, 10)
IF VARTYPE(THIS.oFoxRef) == 'O'
m.nIndex = 1
FOR EACH oReportAddIn IN THIS.oFoxRef.oReportCollection
THIS.cboReport.AddItem(oReportAddIn.ReportName)
IF m.nIndex == 1 AND m.lA4 AND "A4" $ oReportAddIn.ReportName
m.nIndex = THIS.cboReport.NewIndex
ENDIF
ENDFOR
THIS.cboReport.ListIndex = m.nIndex
ENDIF
IF THIS.cboReport.ListCount <= 1
THIS.cboReport.Visible = .F.
THIS.Height = THIS.cboReport.Top
ENDIF
THIS.UpdateControls()
ENDPROC
PROCEDURE updatecontrols
ENDPROC
PROCEDURE cmdCancel.Click
THISFORM.Release()
ENDPROC
PROCEDURE cmdPreview.Click
THISFORM.DoReport(.T.)
ENDPROC
PROCEDURE cmdPrint.Click
IF THISFORM.DoReport()
THISFORM.Release()
ENDIF
ENDPROC
ENDDEFINE