Module Winprint2.pkg
1// WinPrint2.pkg
2//
3Use windows.pkg
4Use LanguageText.pkg
5Use DLL.pkg
6Use WinPrint2_Api.pkg
7Use WinPrint_Constants.pkg
8Use Rgb.pkg
9Use GlobalFunctionsProcedures.pkg
10
11DEFINE INFINITE for -1
12DEFINE WAIT_TIMEOUT for |CI$00000102
13
14
15DEFINE QS_KEY for |CI$0001
16DEFINE QS_MOUSEMOVE for |CI$0002
17DEFINE QS_MOUSEBUTTON for |CI$0004
18DEFINE QS_POSTMESSAGE for |CI$0008
19DEFINE QS_TIMER for |CI$0010
20DEFINE QS_PAINT for |CI$0020
21DEFINE QS_SENDMESSAGE for |CI$0040
22DEFINE QS_HOTKEY for |CI$0080
23DEFINE QS_ALLPOSTMESSAGE for |CI$0100
24DEFINE QS_MOUSE for (QS_MOUSEMOVE ior QS_MOUSEBUTTON)
25DEFINE QS_INPUT for (QS_MOUSE ior QS_KEY)
26DEFINE QS_ALLEVENTS for (QS_INPUT ior QS_POSTMESSAGE ior QS_TIMER ior QS_PAINT ior QS_HOTKEY)
27DEFINE QS_ALLINPUT for (QS_INPUT ior QS_POSTMESSAGE ior QS_TIMER ior QS_PAINT ior QS_HOTKEY ior QS_SENDMESSAGE)
28
29External_Function WaitForSingleObject "WaitForSingleObject" Kernel32.dll Handle hHandle Dword dwMilliseconds Returns DWord
30External_Function GetCurrentProcessId "GetCurrentProcessId" Kernel32.dll Returns DWord
31External_Function GetCurrentProcess "GetCurrentProcess" Kernel32.dll Returns DWord
32
33External_Function MsgWaitForMultipleObjects "MsgWaitForMultipleObjects" User32.dll ;
34 DWORD nCount; // number of handles in the object handle array
35 Address pHandles; // pointer to the object-handle array
36 Boolean fWaitAll; // wait for all or wait for one
37 DWORD dwMilliseconds; // time-out interval in milliseconds
38 DWORD dwWakeMask; // type of input events to wait for
39Returns Dword
40
41Use GlobalFunctionsProcedures.pkg
42
43{ Visibility=Private }
44Class cWinPrint2 is a cObject // JJT: Will we need a windows handle for this like old one
45 Procedure Construct_Object
46 forward send construct_object
47
48 //*** internal properties
49 Property Integer DFCurrent_Color 0
50 Property String DFCurrent_OutPut "WinPrint"
51 Property Integer DFCurrent_Diagram 0
52 Property Integer DFCurrent_HeaderType 0
53 Property Integer DFCurrent_HeaderNr 0
54 Property Number DFCurrent_FontSize 10
55 Property String DFCurrent_Font "Arial"
56
57 //*** Default values for margins 2.53 CM = 1 inch
58 Property Number DFLeft_Margin 2.53
59 Property Number DFTop_Margin 2.53
60 Property Number DFright_Margin 2.53
61 Property Number DFBottom_Margin 2.53
62
63 // If WP1 this defaults to false. In 2, it is true which means that the print job
64 // dialog appears when you hitprint in previewer.
65 Property Integer PrintDlgInPreview 1
66 // This does nothing in Wp2 (because you can't to this anyway)
67 Property Integer EnablePrintSetupFromPreview True
68 Property Integer EnablePrintFromPreview 1
69
70 // is the GUI Suspended. This is privately maintained and is used
71 // to figure out if a preview panel is up or not
72 Property Integer pbIsSuspended False
73
74 Object oDFColorArray is an Array
75 //Moved into array
76 Set Value 0 To RGB_WHITE
77 Set Value 1 To RGB_RED
78 Set Value 2 To RGB_BLUE
79 Set Value 3 To RGB_GREEN
80 Set Value 4 To RGB_YELLOW
81 Set Value 5 To RGB_GREY
82 Set Value 6 To RGB_CYAN
83 Set Value 7 To RGB_MAGENTA
84 Set Value 8 To RGB_DRED
85 Set Value 9 To RGB_DBLUE
86 Set Value 10 To RGB_DGREEN
87 Set Value 11 To RGB_DYELLOW
88 Set Value 12 To RGB_DGREY
89 Set Value 13 To RGB_DCYAN
90 Set Value 14 To RGB_DMAGENTA
91 Set Value 15 To RGB_BLACK
92 End_Object
93
94 Object oDiagramArray is an Array
95 End_Object
96
97 End_Procedure
98
99 Function ViewerWantsToClose returns Boolean
100 Function_return (WP_ViewerWantsToClose())
101 end_Function
102
103 Function IsViewerActive returns boolean
104 Function_Return (WP_GetViewerWindow()<>0)
105 end_function
106
107 Function IsPrinterValid Returns Boolean
108 Function_Return (WP_IsPrinterValid()<>0)
109 End_Function
110
111 Function ArePrintersInstalled returns boolean
112 Function_Return (WP_ArePrintersInstalled()<>0)
113 End_Function
114
115
116 // returns docucument state: dsNotStarted, dsStarted, dsFinished
117 Function DocumentStatus returns Integer
118 Function_Return (WP_GetDocumentStatus())
119 end_function
120
121 // Might still be called from report class. Leave dummy stub
122 Procedure DFZeroCounters
123 End_Procedure
124
125 //***
126 Function DFNewPage Integer Columns Returns Integer
127 Integer iPageNum
128 // This returns a page number used in report object....(this may change)
129 Move (WP_CreatePage(Columns)) To iPageNum
130 If (iPageNum=0) Begin
131 Error DFERR_WINPRINT DFPrintError900
132 End
133 Function_Return iPageNum
134 End_Function
135
136 //***Return handle to use for winprint dialog. If main_window
137 // exists, use it. Else, get object's handle
138 Function Report_Window_Handle returns handle
139 Handle hWnd
140 Handle hoObj
141 Get Focus of desktop to hoObj // start with the focus
142 Move (gOwnerWindowHandle(hoObj)) to hWnd // global function finds the right handle for us
143 function_return hWnd
144 End_Function
145
146
147 //***
148 Function DFPrintDialog Returns Boolean
149 Handle hwnd
150 Boolean bOk
151
152 Get Report_Window_Handle to hWnd
153 Move (WP_ExecutePrintDialog(hwnd)) To bOk
154
155 Function_Return bOk
156 End_Function
157
158
159 //*** You can only invoke the print setup if the report is cleared. If you try to to do this in
160 // the wrong state you will get an error.
161 Function DFPrintSetupDialog Returns Boolean
162 Handle hwnd
163 Boolean bOk
164 Integer iStatus
165 Get ArePrintersInstalled to bOk
166 If not bOk Begin
167 Error DFERR_WINPRINT C_$NoInstalledPrinters
168 End
169 Else Begin
170 Get DocumentStatus to iStatus
171
172 If (iStatus=dsNotStarted) Begin
173 Get Report_Window_Handle to hWnd
174 Move (WP_ExecutePrinterSetupDialog(hwnd)) to bOk
175
176 // test that the selected printer is valid....
177 If bOK Begin
178 Get IsPrinterValid to bOk // if printer not valid, it's not ok
179 If not bOk Begin
180 Error DFERR_WINPRINT DFPrintError936 // could not select a valid printer
181 End
182 End
183 End
184 Else Begin
185 Error DFERR_WINPRINT DFPrintError966 // cannot change printer when report is active
186 End
187 End
188 Function_Return bOk
189 End_Function
190
191
192 //*** Provided for backwards compatibility. DFPrintSetupDialog is more flexible because it returns a
193 // false if cancel was selected.
194 Procedure DFPrintSetup
195 Boolean bOk
196 Get DFPrintSetupDialog to bOk
197 End_Procedure
198
199 //*** This invokes the print job dialog, prints the report, then clears the report document.
200 // This should be called after the report is complete.
201 Procedure DFPrint
202 Integer bOk
203 Get DFPrintDialog To bOk
204 If bOk Begin
205 Send DFPrintDoc
206 Send DFClearDoc
207 End
208 End_Procedure
209
210 Procedure DFSuspendGui boolean bSuspend
211 If (bSuspend<>pbIsSuspended(self)) begin
212 Send SuspendGui of Desktop bSuspend
213 Set pbIsSuspended to bSuspend
214 end
215 end_procedure
216
217 // this is protected so that the queue is only pumped if the
218 // gui is suspended.
219 Procedure PumpMsgQueue
220 If (pbIsSuspended(self)) begin
221 Send PumpMsgQueue of desktop // permit painting
222 end
223 end_procedure
224
225
226 //*** This does a modeless preview. This is what you'd want during
227 // report generation and it may be what you want for report viewing.
228 Procedure DFPreviewNoWait
229 Boolean bOk
230 Boolean bPrntDlg bPrintSetup bPrint
231 integer iStatus
232 Get PrintDlgInPreview to bPrntDlg
233 Get EnablePrintSetupFromPreview to bPrintSetup
234 Get EnablePrintFromPreview to bPrint
235 Get DocumentStatus to iStatus
236 If (iStatus=dsStarted) begin
237 Send DfSuspendGui True
238 end
239 Move (WP_PreviewDocument(bPrntDlg,bPrintSetup,bPrint)) To bOk
240 If not bOk Begin
241 Error DFERR_WINPRINT DFPrintError901
242 Send DfSuspendGui False
243 End
244 End_Procedure
245
246
247 //*** This does a modal preview. You might want this for report
248 // viewing as the program knows when the viewer is closed
249 // Note that this is a private message and it was never intended that this
250 // should be used. We expect winprint reports to use modeless viewers.
251 Procedure DFPreviewWait
252 Handle hViewerProcess
253 Boolean bPrntDlg bPrintSetup bPrint
254 Integer iRetVal
255 Integer hwMain hMain
256
257 Get PrintDlgInPreview to bPrntDlg
258 Get EnablePrintSetupFromPreview to bPrintSetup
259 Get EnablePrintFromPreview to bPrint
260
261 Send DfSuspendGui True
262 Move (WP_PreviewDocument(bPrntDlg,bPrintSetup,bPrint)) To hViewerProcess
263
264 If (hViewerProcess = 0) Begin
265 Error DFERR_WINPRINT DFPrintError901
266 End
267 Else Begin
268 // We need to wait for either the Viewer to close, or a WM_PAINT message in the thread's queue...
269 Repeat
270 Move (MsgWaitForMultipleObjects(1, AddressOf(hViewerProcess), False, INFINITE, QS_PAINT)) To iRetVal
271 Send PumpMsgQueue // permit painting
272 Until (iRetVal = 0) // 0 means that the viewer process terminated
273 end
274 Send DfSuspendGui False
275
276 // Do what we can to force VDF application to the top.
277 // As 12.0 dfSuspendGUI actually properly disables the underlying windows. When the viewer
278 // is closed it cannot give the focus back to this so it goes elsewhere. This will force it
279 // back.
280
281 Get main_window of desktop to hMain
282 If hMain Begin
283 Get window_handle of hMain to hwMain
284 If hwMain Begin
285 If (GetForegroundWindow()<>hwMain) Begin
286 Move (SetForegroundWindow(hwMain)) to hwMain
287 End
288 End
289 End
290
291 End_Procedure
292
293 Procedure DfPreview
294 send DfPreviewNoWait
295 end_procedure
296
297
298 //***
299 Procedure DFPrintDoc
300 Handle hwnd
301 Boolean bOk
302 Get Report_Window_Handle to hWnd
303 Move (WP_PrintDocument(hwnd)) To bOk
304
305 If not bOk Begin
306 Error DFERR_WINPRINT DFPrintError902
307 End
308 End_Procedure
309
310
311 //***
312 Procedure DFClearDoc
313 Boolean bOk
314 Get ArePrintersInstalled to bOk
315 If bOk begin
316 Move (WP_ClearDocument()) To bOk
317 Send DFSuspendGUI False
318 If not bOk Begin
319 Error DFERR_WINPRINT DFPrintError903 // error number right?
320 End
321 End
322 End_Procedure
323
324 Procedure DFNewDoc Boolean bAutoPreview
325 Boolean bOk
326 // this is the most likely place we will encounter when we start a report. Check for
327 // printers and return an explicit error to make it easy to identify the error
328 Get ArePrintersInstalled to bOk
329 If not bOk begin
330 Error DFERR_WINPRINT C_$NoInstalledPrinters
331 end
332 else begin
333 Send DfClearDoc //JJT - a new doc should always start with a clear
334 If bAutoPreview Send DFSuspendGUI True
335 Move (WP_NewDocument(bAutoPreview)) To bOk
336
337 If not bOk Begin
338 Error DFERR_WINPRINT DFPrintError902 // could not print document
339 Send DFSuspendGUI False
340 End
341 end
342 End_Procedure
343
344 //***
345 Procedure DFSetFont String sFontName
346 boolean bOk
347 Move (WP_SetFontName(sFontName)) To bOk
348
349 If not bOK Begin
350 Error DFERR_WINPRINT DFPrintError904
351 End
352 End_Procedure
353
354
355 //***
356 Procedure DFSetFontSize Integer iHeight Integer iWidth
357 boolean bOk
358 // note that width is ignored in new implementation
359 Move (WP_SetFontHeight(iHeight)) To bOk
360
361 If not bOK Begin
362 Error DFERR_WINPRINT DFPrintError905
363 End
364 End_Procedure
365
366
367 //***
368 Procedure DFSetFontStyle DWORD dwStyle
369 boolean bOk
370 Move (WP_SetFontStyle(dwStyle)) To bOk
371
372 If not bOK Begin
373 Error DFERR_WINPRINT DFPrintError906
374 End
375 End_Procedure
376
377
378 //***
379 Procedure DFSetUnderline boolean bUnderline
380 boolean bOk
381
382 Move (WP_SetFontUnderline(bUnderline)) To bOk
383
384 If not bOK Begin
385 Error DFERR_WINPRINT DFPrintError907
386 End
387 End_Procedure
388
389
390 //***
391 Procedure DFSetBold Boolean bBold
392 Boolean bOk
393
394 Move (WP_SetFontBold(bBold)) To bOk
395
396 If not bOK Begin
397 Error DFERR_WINPRINT DFPrintError908
398 End
399 End_Procedure
400
401
402 //***
403 Procedure DFSetItalic Boolean bItalic
404 Boolean bOk
405
406 Move (WP_SetFontItalic(bItalic)) To bOk
407
408 If not bOK Begin
409 Error DFERR_WINPRINT DFPrintError909
410 End
411 End_Procedure
412
413
414 //***
415 Procedure DFSetStrikeout Boolean bStrikeout
416 Boolean bOk
417
418 Move (WP_SetFontStrikeout(bStrikeout)) To bOk
419
420 If not bOK Begin
421 Error DFERR_WINPRINT DFPrintError910
422 End
423 End_Procedure
424
425
426 //***
427 Procedure DFSetMargins Number nLeft Number nTop Number nRight Number nBottom
428 Boolean bOk
429 integer iLeft iRight iTop iBottom
430
431 Move (nLeft * 100) to iLeft
432 Move (nRight * 100) to iRight
433 Move (nTop * 100) to iTop
434 Move (nBottom * 100) to iBottom
435
436 Move (WP_SetMargins(iLeft,iTop,iRight,iBottom)) To bOk
437
438 If bOk Begin
439 Set DFLeft_Margin To nLeft
440 Set DFTop_Margin To nTop
441 Set DFRight_Margin To nRight
442 Set DFBottom_Margin To nBottom
443 End
444 Else Begin
445 Error DFERR_WINPRINT DFPrintError911
446 End
447 End_Procedure
448
449
450 //***
451 Procedure DFSetLeftMargin Number nLeft
452 number nTop nRight nBottom
453 Get DFTop_Margin To nTop
454 Get DFRight_Margin To nRight
455 Get DFBottom_Margin To nBottom
456 Send DFSetMargins nLeft nTop nRight nBottom
457 End_Procedure
458
459
460 //***
461 Procedure DFSetRightMargin Number nRight
462 number nLeft nTop nBottom
463 Get DFLeft_Margin To nLeft
464 Get DFTop_Margin To nTop
465 Get DFBottom_Margin To nBottom
466 Send DFSetMargins nLeft nTop nRight nBottom
467 End_Procedure
468
469
470 //***
471 Procedure DFSetTopMargin Number nTop
472 number nLeft nRight nBottom
473 Get DFLeft_Margin To nLeft
474 Get DFRight_Margin To nRight
475 Get DFBottom_Margin To nBottom
476 Send DFSetMargins nLeft nTop nRight nBottom
477 End_Procedure
478
479
480 //***
481 Procedure DFSetBottomMargin Number nBottom
482 number nLeft nTop nRight
483 Get DFLeft_Margin To nLeft
484 Get DFTop_Margin To nTop
485 Get DFRight_Margin To nRight
486 Send DFSetMargins nLeft nTop nRight nBottom
487 End_Procedure
488
489
490 //***
491 Procedure DFWriteText String sText Integer iStyle Integer iColumn Integer iDecimal Boolean bNewLineAfterPrint
492 Boolean bOk
493
494 Send DFSetFontStyle iStyle
495 Get ToAnsi sText To sText
496 Move (WP_WriteText(sText,bNewLineAfterPrint,iColumn,iDecimal,0)) To bOk
497 If not bOk Begin
498 Error DFERR_WINPRINT DFPrintError918
499 End
500 Send PumpMsgQueue // permit painting //JJT!!!!!!!!!!!
501 End_Procedure
502
503 //***
504 Procedure DFWrite String sText DWORD iStyle Integer iColumn Integer iDecimal Boolean bTrim
505 If (Num_Arguments>=5 and bTrim) Begin
506 Move (Rtrim(sText)) to sText
507 end
508 Send DFWriteText sText iStyle iColumn iDecimal False
509 End_Procedure
510
511 //***
512 Procedure DFWriteLn String sText DWORD iStyle Integer iColumn Integer iDecimal Boolean bTrim
513 If (Num_Arguments>=5 and bTrim) Begin
514 Move (Rtrim(sText)) to sText
515 end
516 Send DFWriteText sText iStyle iColumn iDecimal True
517 End_Procedure
518
519
520 //***
521 Procedure DFWriteTextAtPosition String sText integer iStyle Number nPosition Integer iDecimal ;
522 Number nMaxLength Boolean bNewLineAfterPrint
523 Boolean bOk
524 Integer iPosition iMaxLength
525 Send DFSetFontStyle iStyle
526 Get ToAnsi sText To sText
527 Move (nPosition * 100) to iPosition
528 Move (nMaxLength * 100) to iMaxLength
529 Move (WP_WriteTextAtPosition(sText,bNewLineAfterPrint,iPosition,iDecimal,iMaxLength)) To bOk
530 If not bOk Begin
531 Error DFERR_WINPRINT DFPrintError922
532 End
533 Send PumpMsgQueue // permit painting //JJT!!!!!!!!!!!
534 End_Procedure
535
536 //***
537 Procedure DFWritePos String sText integer iStyle Number nPosition Integer iDecimal Number nMaxLength boolean bTrim
538 Number nMax
539 If (Num_Arguments>=6 and bTrim) Begin
540 Move (Rtrim(sText)) to sText
541 end
542
543 If (Num_Arguments<5) ;
544 Move 0 to nMax
545 Else ;
546 Move nMaxLength to nMax
547 Send DFWriteTextAtPosition sText iStyle nPosition iDecimal nMax False
548 End_Procedure
549
550 //***
551 Procedure DFWriteLnPos String sText integer iStyle Number nPosition Integer iDecimal Number nMaxLength boolean bTrim
552 Number nMax
553 If (Num_Arguments>=6 and bTrim) Begin
554 Move (Rtrim(sText)) to sText
555 end
556
557 If (Num_Arguments<5) ;
558 Move 0 to nMax
559 Else ;
560 Move nMaxLength to nMax
561 Send DFWriteTextAtPosition sText iStyle nPosition iDecimal nMax True
562 End_Procedure
563
564 Procedure DFSetMetrics String sMetrics
565 integer eMetrics
566 // for backwards compatibility support both string names and integer enumerations
567 // it is better to use the enumeration value
568 If (sMetrics="INCH" or sMetrics="CM") Begin
569 Set DFCurrent_Metrics to sMetrics
570 end
571 else Begin
572 Move sMetrics to eMetrics
573 Move (WP_SetMetrics(eMetrics)) To eMetrics
574 End
575 End_Procedure
576
577 Function DFGetMetrics Returns Integer
578 Integer eMetrics
579 Move (WP_GetMetrics()) To eMetrics
580 Function_return eMetrics
581 End_Function
582
583
584 //**** Properties Maintained for compatibility with old Winprint (obsolete)
585 Function DFCurrent_Metrics returns string
586 Integer eMetrics
587 Get DFGetMetrics to eMetrics
588 Function_return (if(eMetrics=WPM_INCH,"INCH","CM"))
589 end_function
590
591 Procedure Set DFCurrent_Metrics string sCMorINCH
592 Send DFSetMetrics (if(sCMorINCH="INCH", WPM_INCH, WPM_CM))
593 End_Procedure
594
595
596
597
598
599 //***
600 Procedure DFBeginHeaderType Integer iHeaderNr Integer eHeaderType
601 Boolean bOk
602
603 If (eHeaderType=DFSubHeader or eHeaderType=DFSubTotal) Begin
604 //*** Do nothing for the moment
605 End
606 Else ;
607 Move 0 to iHeaderNr // If the user made a mistake
608
609 Set DFCurrent_HeaderType To eHeaderType
610 Set DFCurrent_HeaderNr To iHeaderNr
611
612 Move (WP_BeginHeader(eHeaderType, iHeaderNr)) To bOk
613
614 If not bOk Begin
615 Error DFERR_WINPRINT DFPrintError925
616 End
617 End_Procedure
618
619
620 //***
621 Procedure DFEndHeaderType
622 Boolean bOk
623
624 Move (WP_EndHeader()) To bOk
625
626 if not bOk begin
627 Error DFERR_WINPRINT DFPrintError926
628 End
629 End_Procedure
630
631
632 //***
633 Procedure DFWriteHeaderType Integer iHeaderNr Integer eHeaderType
634 Boolean bOk
635 Move (WP_WriteHeader(eHeaderType, iHeaderNr)) To bOk
636 if not bOk begin
637 Error DFERR_WINPRINT DFPrintError927
638 End
639 End_Procedure
640
641
642 //***
643 Procedure DFHeaderPosition Integer ePlace
644 Boolean bOk
645
646 Move (WP_SetHeaderPlacement(ePlace)) To bOk
647
648 if not bOk begin
649 Error DFERR_WINPRINT DFPrintError929
650 End
651 End_Procedure
652
653
654 //***
655 Procedure DFHeaderFrameType Integer eFrame integer iColor Number nWeight;
656 Integer iFillColor Boolean bFillFrame
657 Integer iWeight
658 Boolean bOk
659
660 move (nWeight*100) To iWeight
661
662 Move (WP_SetHeaderFrame(eFrame,iColor,iWeight,iFillColor,bFillFrame)) To bOk
663
664 if not bOk begin
665 Error DFERR_WINPRINT DFPrintError930
666 End
667 End_Procedure
668
669 Procedure DFHeaderMargin Integer eType Number nSize
670 Boolean bOk
671 Integer iSize
672
673 move (nSize * 100) to iSize
674
675 move (WP_SetHeaderMargin(eType, iSize)) To bOk
676
677 if not bOk begin
678 Error DFERR_WINPRINT DFPrintError930
679 end
680 End_Procedure
681
682
683 //***
684 Procedure DFHeaderWrap Integer eOnOff
685 Boolean bOk
686
687 Move (WP_SetHeaderWrap(eOnOff)) To bOk
688
689 if not bOk begin
690 Error DFERR_WINPRINT DFPrintError931
691 End
692 End_Procedure
693
694 //***
695 Procedure DFWriteBMP String sFileName Number nStartX Number nStartY Number nHeight Number nWidth Boolean bUCp
696 Boolean bOk
697 Integer iStartX iStartY iHeight iWidth
698
699 If ((nStartX = -998) or (nStartX = -999));
700 move nStartX to iStartX
701 else ;
702 move (nStartX*100) To iStartX
703
704 If ((nStartY = -998) or (nStartY = -999));
705 move nStartY to iStartY
706 else ;
707 move (nStartY*100) To iStartY
708
709 If ((nWidth = -998) or (nWidth = -999));
710 move nWidth To iWidth
711 else ;
712 move (nWidth*100) To iWidth
713
714 If ((nHeight = -998) or (nHeight = -999));
715 move nHeight To iHeight
716 else ;
717 move (nHeight*100) To iHeight
718
719 Get_File_Path sFileName To sFileName
720 Move (WP_DrawBitmap(sFileName,iStartX,iStartY,iWidth,iHeight,bUCp)) to bOk
721
722 If not bOk Begin
723 Error DFERR_WINPRINT DFPrintError932
724 End
725 End_Procedure
726
727
728 //***
729 Procedure DFHeaderLineCheck Integer iLines
730 Boolean bOk
731
732 Move (WP_SetExtraLineCheck(iLines)) To bOk
733
734 If not bOk begin
735 Error DFERR_WINPRINT DFPrintError934
736 End
737 End_Procedure
738
739
740 //***
741 Procedure DFPrintFlags Integer Flags
742 Boolean bOk
743
744 Move (WP_SetPrintDialogFlags(Flags)) To bOk
745
746 If not bOk begin
747 Error DFERR_WINPRINT DFPrintError935
748 End
749 End_Procedure
750
751
752 //*** obsolete and maintained for winprint-I backwards compatibility (maybe should be removed)
753 //
754 Procedure DFSelectPrinter String sDriver String sDevice String sPort Boolean bUpdate
755 Send DFSetDevice sDevice
756 End_Procedure
757
758 //*** Preferred usage for WinprintII
759 Procedure DFSetDevice String sDevice
760 Boolean bOk
761
762 Move (WP_SelectPrinter(sDevice)) To bOk
763
764 If not bOk Begin
765 Error DFERR_WINPRINT DFPrintError936
766 End
767 End_Procedure
768
769 Procedure DFPrinterBinFirstPage Integer eBin
770 Boolean bOk
771
772 Move (WP_SetFirstPagePaperSource(eBin)) To bOk
773
774 If not bOk Begin
775 Error DFERR_WINPRINT DFPrintError937
776 End
777 End_Procedure
778
779
780 //***
781 Function DFGetDFColor Integer iRed Integer iGreen Integer iBlue Returns Integer
782 Integer iColor
783
784 Move (WP_RGBToDFPrintColor(iRed,iGreen,iBlue)) To iColor
785
786 If (iColor=0) Begin
787 Error DFERR_WINPRINT DFPrintError938
788 End
789 Function_Return iColor
790 End_Function
791
792
793 //***
794 Procedure DFSetDFColor Dword dwColor
795 Integer bOk
796
797 Move (WP_SetFontColor(dwColor)) To bOk
798
799 If not bOk Begin
800 Error DFERR_WINPRINT DFPrintError939
801 End
802 End_Procedure
803
804
805 //***
806 Procedure DFSetTopBottom Number nTop Number nBottom Boolean bAllPages
807 Boolean bOk
808 Integer iTop iBottom
809
810 move (nTop*100) To iTop
811 move (nBottom*100) To iBottom
812
813 Move (WP_SetAbsoluteMargins(iTop,iBottom,bAllPages)) To bOk
814
815 If Not bOk Begin
816 Error DFERR_WINPRINT DFPrintError940
817 End
818 End_Procedure
819
820
821 //***
822 Procedure DFSetJMode Integer eAlign
823 Boolean bOk
824
825 Move (WP_SetAlign(eAlign)) To bOk
826
827 If Not bOk Begin
828 Error DFERR_WINPRINT DFPrintError941
829 End
830 End_Procedure
831
832
833 //***
834 Procedure DFWriteEllip Number nStartX Number nStartY Number nHeight Number nWidth ;
835 Dword dwBColor Dword dwFColor Boolean bFill Number nWeight Boolean bWrap Boolean bUCp
836
837 Boolean bOk
838 Integer iWeight
839 Integer iStartX iStartY iHeight iWidth
840
841 If ((nStartX = -998) or (nStartX = -999));
842 move nStartX To iStartX
843 else ;
844 move (nStartX*100) To iStartX
845
846 If ((nStartY = -998) or (nStartY = -999));
847 move nStartY To iStartY
848 else ;
849 move (nStartY*100) To iStartY
850
851 If ((nWidth = -998) or (nWidth = -999));
852 move nWidth To iWidth
853 else ;
854 move (nWidth*100) To iWidth
855
856 If ((nHeight = -998) or (nHeight = -999));
857 move nHeight To iHeight
858 else ;
859 move (nHeight*100) To iHeight
860
861 move (nWeight*100) To iWeight
862
863
864 Move (WP_DrawEllipse(iStartX,iStartY,iWidth,iHeight,;
865 dwBColor,dwFColor,bFill,iWeight,bUCp,bWrap)) To bOk
866
867 If Not bOk Begin
868 Error DFERR_WINPRINT DFPrintError942
869 End
870 End_Procedure
871
872
873
874
875 //***
876 Procedure DFWriteRect Number nStartX Number nStartY Number nHeight Number nWidth;
877 Dword dwBColor Dword dwFColor Boolean bFill Number nWeight Boolean bWrap Boolean bUCp
878
879 Boolean bOk
880 Integer iWeight
881 Integer iStartX iStartY iHeight iWidth
882
883 If ((nStartX = -998) or (nStartX = -999));
884 move nStartX To iStartX
885 else ;
886 move (nStartX*100) To iStartX
887
888 If ((nStartY = -998) or (nStartY = -999));
889 move nStartY To iStartY
890 else ;
891 move (nStartY*100) To iStartY
892
893 If ((nWidth = -998) or (nWidth = -999));
894 move nWidth To iWidth
895 else ;
896 move (nWidth*100) To iWidth
897
898 If ((nHeight = -998) or (nHeight = -999));
899 move nHeight To iHeight
900 else ;
901 move (nHeight*100) To iHeight
902
903 move (nWeight*100) To iWeight
904
905 Move (WP_DrawRectangle(iStartX,iStartY,iWidth,iHeight,;
906 dwBColor,dwFColor,bFill,iWeight,bUCp,bWrap)) To bOk
907
908 If Not bOk Begin
909 Error DFERR_WINPRINT DFPrintError944
910 End
911 End_Procedure
912
913
914
915
916 //***
917 Procedure DFLineCheck Integer iLines
918 Boolean bOk
919
920 Move (WP_ConfirmLines(iLines)) To bOk
921
922 If Not bOk Begin
923 Error DFERR_WINPRINT DFPrintError946
924 End
925 End_Procedure
926
927
928 //***
929 Procedure DFCreateDiagram Integer eType Integer eFx Number nHeight Number nWidth Integer bXyAxis
930 Handle hDiagram
931 Integer iWidth iHeight
932
933 move (nHeight*100) To iHeight
934 move (nWidth*100) To iWidth
935
936 Set DFCurrent_Color To 0
937
938 Move (WP_CreateDiagram(eType,eFx,iWidth,iHeight,bXyAxis)) To hDiagram
939
940 If (hDiagram) Begin
941 Error DFERR_WINPRINT DFPrintError947
942 End
943 Else Begin
944 Set DFCurrent_Diagram To hDiagram
945 end
946 End_Procedure
947
948
949 //***
950 Procedure DFDiagram_Item handle hDiagram String sLabel Number nValue;
951 Dword dwBColor Dword dwFColor Integer eFill;
952 Integer iDec Integer eValueOrPercent Integer eExt
953
954 Boolean bOk
955 Integer iCurrColor iValue
956
957 If (dwFColor = -1) Begin
958 Get DFCurrent_Color To iCurrColor
959 Increment iCurrColor
960 If (iCurrColor>15) Move 1 To iCurrColor
961 Set DFCurrent_Color To iCurrColor
962 Get DFGetColor iCurrColor To dwFColor
963 End
964
965 Move (nValue *100) to iValue
966
967 Get ToAnsi sLabel To sLabel
968
969 Move (WP_AddDiagramEntry(hDiagram,sLabel,iValue,dwBColor,dwFColor,eFill,iDec,eValueorPercent,eExt)) To bOk
970
971 If not bOk Begin
972 Error DFERR_WINPRINT DFPrintError948
973 End
974 End_Procedure
975
976
977 //***
978 Procedure DFLockDiagram Handle hDiagram
979 Boolean bOk
980
981 Move (WP_LockDiagram(hDiagram)) To bOk
982
983 If not bOk Begin
984 Error DFERR_WINPRINT DFPrintError949
985 End
986 End_Procedure
987
988
989
990 //***
991 Procedure DFDrawDiagram Handle hDiagram Number nYPos Number nXPos Boolean bUCp
992 Boolean bOk
993 Integer iXPos
994 Integer iYPos
995
996 move (nXPos*100) To iXPos
997 move (nYPos*100) To iYPos
998
999 If nYPos Eq -999 Move -999 To iYPos
1000
1001 Move (WP_DrawDiagram(hDiagram,iXPos,iYPos,bUCp)) To bOk
1002
1003 If not bOk Begin
1004 Error DFERR_WINPRINT DFPrintError950
1005 End
1006 End_Procedure
1007
1008
1009
1010 //***
1011 Procedure DFDiagramLabel handle hDiagram String sLabel
1012 Boolean bOk
1013 Integer iLabelLen
1014
1015 Get ToAnsi sLabel To sLabel
1016
1017 Move (WP_SetDiagramCaption(hDiagram,sLabel)) To bOk
1018
1019 if not bOk Begin
1020 Error DFERR_WINPRINT DFPrintError952
1021 End
1022 End_Procedure
1023
1024
1025 //***
1026 Procedure DFDiagramXLabel handle hDiagram String sLabel
1027 Boolean bOk
1028 Get ToAnsi sLabel To sLabel
1029
1030 Move (WP_SetDiagramXText(hDiagram,sLabel)) To bOk
1031
1032 if not bOk Begin
1033 Error DFERR_WINPRINT DFPrintError953
1034 End
1035 End_Procedure
1036
1037
1038 //***
1039 Procedure DFDiagramYLabel handle hDiagram String sLabel Boolean bVertical
1040 Boolean bOk
1041 Get ToAnsi sLabel To sLabel
1042
1043 Move (WP_SetDiagramYText(hDiagram,sLabel,bVertical)) To bOk
1044
1045 if not bOk Begin
1046 Error DFERR_WINPRINT DFPrintError954
1047 End
1048 End_Procedure
1049
1050
1051 //***
1052 Procedure DFWriteXYLine Number nStartX Number nStartY Number nStopX Number nStopY;
1053 Dword dwColor Number nWeight Boolean bWrap Boolean bUCp
1054
1055 Boolean bOk
1056 Integer iStartX iStartY iStopX iStopY
1057 Integer iWeight
1058
1059 move (nStartX*100) To iStartX
1060 move (nStartY*100) To iStartY
1061 move (nStopX*100) To iStopX
1062 move (nStopY*100) To iStopY
1063
1064 move (nWeight*100) To iWeight
1065
1066 If (nStopY = -998) Move -998 To iStopY
1067 If (nStopX = -998) Move -998 To iStopX
1068
1069 If (nStartY = -999) Move -999 To iStartY
1070 If (nStartX = -999) Move -999 To iStartX
1071
1072 Move (WP_DrawXYLine(iStartX,iStartY,iStopX,iStopY,dwColor,iWeight,bUCp,bWrap)) To bOk
1073
1074 if not bOk Begin
1075 Error DFERR_WINPRINT DFPrintError955
1076 End
1077 End_Procedure
1078
1079
1080 //***
1081 Procedure DFWriteLine Number nStartX Number nStartY Number nLength;
1082 Boolean bHorizontal Dword dwColor Number nWeight Boolean bUCp
1083
1084 Boolean bOk
1085 Integer iStartX iStartY iLength
1086 Integer iWeight
1087
1088 move (nStartX*100) To iStartX
1089 move (nStartY*100) To iStartY
1090 move (nLength*100) To iLength
1091 move (nWeight*100) To iWeight
1092
1093 If (nStartY = -999) Move -999 To iStartY
1094 If (nStartX = -999) Move -999 To iStartX
1095 If (nLength = -998) Move -998 To iLength
1096
1097 Move (WP_DrawLine(iSTartX,iStartY,iLength,bHorizontal,dwColor,iWeight,bUCp)) To bOk
1098
1099 if not bOk Begin
1100 Error DFERR_WINPRINT DFPrintError956
1101 End
1102 End_Procedure
1103
1104
1105 //***
1106 Procedure DFClearPrinter
1107 Boolean bOk
1108
1109 Move (WP_ClearPrinter()) To bOk
1110
1111 If not bOk Begin
1112 Error DFERR_WINPRINT DFPrintError957
1113 End
1114 End_Procedure
1115
1116
1117
1118 //***
1119 Function DFGetCurrentDevice Returns String
1120 Boolean bOk
1121 String sDFStr
1122 Address pDFStr
1123
1124 Move (Repeat( Character(0), 255 )) to sDFStr
1125 GetAddress of sDFStr to pDFStr
1126
1127 Move (WP_GetCurrentDevice(pDFStr)) To bOk
1128
1129 If not bOk Begin
1130 Error DFERR_WINPRINT DFPrintError959
1131 End
1132
1133 Move (CString(sDFStr)) To sDFStr
1134 Function_Return sDFStr
1135 End_Function
1136
1137
1138 // Note: DfGetCurrentPort and DFGetCurrentDriver do not exist in winprint2. Trying to
1139 // use these will result in a runtime error (which is good - don't use them)
1140
1141
1142 //***
1143 Function DFGetPrintDialogFlags Returns Dword
1144 Dword dwRetVal
1145
1146 Move (WP_GetPrintDialogFlags()) To dwRetVal
1147
1148 Function_Return dwRetVal
1149 End_Function
1150
1151
1152 //***
1153 //*** Returns PRN_TRUE= if the flag is set (1)
1154 //*** Returns PRN_FALSE= If the flag not is set (0)
1155 //***
1156 Function DFCheckPrintDialogFlag Dword dwPDFlag Returns Boolean
1157 Boolean bIsSet
1158
1159 Move (WP_IsPrintDialogFlagSet(dwPDFlag)) To bIsSet
1160
1161 Function_Return bIsSet
1162 End_Function
1163
1164
1165 //***
1166 Procedure DFSetSpecPrintFlag Dword dwPDFlag
1167 Boolean bOk
1168
1169 Move (WP_SetSpecificPrintDialogFlag(dwPDFlag)) To bOk
1170
1171 If not bOk Begin
1172 Error DFERR_WINPRINT DFPrintError961
1173 End
1174 End_Procedure
1175
1176
1177 //***
1178 Function DFGetUserDefinedLength Returns Number
1179 Integer iRetVal
1180 Number nRetVal
1181
1182 Move (WP_GetUserDefinedPapersize()) To iRetVal
1183
1184 If (iRetVal=0) Begin
1185 Error DFERR_WINPRINT DFPrintError962
1186 Function_Return 0
1187 End
1188
1189 Move (Hi(iRetVal)) To nRetVal
1190 move (nRetVal/100) To nRetVal //Returns CM
1191
1192 Function_Return nRetVal
1193 End_Function
1194
1195
1196 //***
1197 Function DFGetUserDefinedWidth Returns Number
1198 Integer iRetVal
1199 Number nRetVal
1200
1201 Move (WP_GetUserDefinedPapersize()) To iRetVal
1202
1203 If (iRetVal=0) Begin
1204 Error DFERR_WINPRINT DFPrintError963
1205 Function_Return 0
1206 End
1207
1208 Move (Low(iRetVal)) To nRetVal
1209 Move (nRetVal/100) To nRetVal //Returns CM
1210
1211 Function_Return nRetVal
1212 End_Function
1213
1214
1215 //*** To be set in CM
1216 Procedure DFSetUserDefinedPapersize Number nLength Number nWidth
1217 Integer bOk
1218 Integer iLength iWidth iSize
1219
1220 move (nLength*100) To iLength
1221 move (nWidth*100) To iWidth
1222 move ((iLength*65536)+iWidth) To iSize
1223
1224 Move (WP_SetUserDefinedPapersize(iSize)) To bOk
1225
1226 If not bOk Begin
1227 Error DFERR_WINPRINT DFPrintError964
1228 End
1229 End_Procedure
1230
1231 Procedure DFSetNumberOfCopies Integer iNrOfCopies
1232 Boolean bOk
1233
1234 Move (WP_SetNumberOfPrintCopies(iNrOfCopies)) to bOk
1235
1236 If not bOk Begin
1237 Error DFERR_WINPRINT DFPrintError965
1238 end
1239 End_Procedure
1240
1241
1242
1243
1244 //*************************************************************
1245 //*** This procedures and functions are used when building ***
1246 //*** complex graphics when you need to change value of the ***
1247 //*** current diagram, so you can mix diagrams within each ***
1248 //*** other. ***
1249 //*************************************************************
1250
1251
1252 Function DFGetCurrentDiagram Returns Integer
1253 Integer iRetVal
1254 Get DFCurrent_Diagram To iRetVal
1255 Function_Return iRetVal
1256 End_Function
1257
1258 Procedure DFSetCurrentDiagram Integer iDiagram
1259 Set DFCurrent_Diagram To iDiagram
1260 End_Procedure
1261
1262 Procedure DFSetDiagramList Integer iItem Integer iDiagram
1263 Set Value of oDiagramArray iItem To iDiagram
1264 End_Procedure
1265
1266 Function DFGetDiagramList Integer iItem Returns Integer
1267 Integer iRetVal
1268 Get Value of oDiagramArray iItem To iRetVal
1269 Function_Return iRetVal
1270 End_Function
1271
1272 Procedure DFClearDiagramList
1273 Send Delete_Data To oDiagramArray
1274 End_Procedure
1275
1276
1277 Function DFGetColor Integer iColor Returns Dword
1278 Dword dwRetVal
1279 Get Value of oDFColorArray iColor To dwRetVal
1280 Function_Return dwRetVal
1281 End_Function
1282
1283 Function DFGetCurrentColor Returns Dword
1284 Dword dwRetVal
1285 Integer iCurrColor
1286
1287 Get DFCurrent_Color To iCurrColor
1288 Get DFGetColor iCurrColor To dwRetVal
1289
1290 Function_Return dwRetVal
1291 End_Function
1292
1293 Procedure DFEndDocument
1294 integer iVoid
1295 Move (WP_EndDocument()) To iVoid
1296 Send DfSuspendGui False
1297 End_procedure
1298
1299 Procedure DFClosePreview
1300 integer iVoid
1301 Move (WP_ClosePreview()) To iVoid
1302 Send DfSuspendGui False
1303 End_procedure
1304
1305 Procedure SetProgressCaption string sCaption
1306 integer iVoid
1307 Move (ToAnsi(sCaption)) to sCaption
1308 Move (WP_SetProgressCaption(sCaption)) To iVoid
1309 End_procedure
1310
1311 Procedure SetReportTitle string sTitle
1312 integer iVoid
1313 Move (ToAnsi(sTitle)) to sTitle
1314 Move (WP_SetReportTitle(sTitle)) To iVoid
1315 End_procedure
1316
1317 Function PreviewYesNoBox string sCaption string sText returns integer
1318 integer eResult
1319 Move (ToAnsi(sCaption)) to sCaption
1320 Move (ToAnsi(sText)) to sText
1321 Move (WP_DisplayMessageBox(sCaption, sText)) To eResult
1322 Function_return eResult
1323 end_function
1324
1325 // internal function, used to extract different printer flags ranges based on
1326 // the print flag integer. These flags use a decimal style of packing information
1327 // where different printer options (paper, bin, etc) use different ranges and
1328 // different steps. Everything above iTopVal is removed and everything that is not
1329 // within the iStep range is removed.
1330 Function PrintFlagRange integer iTopVal integer iStep returns integer
1331 integer iFgs iFg
1332 Get DFGetPrintDialogFlags to iFg
1333 Move (mod(iFg,iTopVal) / iStep * iStep ) to iFg
1334 function_return iFg
1335 end_Function
1336
1337 Procedure DFSetPrinterPaper integer ePaperType
1338 Send DFSetSpecPrintFlag ePaperType
1339 End_Procedure
1340
1341 Function DFGetPrinterPaper returns integer //ePaperType
1342 integer ePaperType
1343 Get PrintFlagRange 500 10 to ePaperType // 10-490 in steps of 10
1344 function_return ePaperType
1345 End_Function
1346
1347
1348 Procedure DFSetPrinterBin integer eBinType
1349 Send DFSetSpecPrintFlag eBinType
1350 End_Procedure
1351
1352 Function DFGetPrinterBin returns integer //eBinType
1353 integer eBinType
1354 Get PrintFlagRange 10000 500 to eBinType // 1000-9000 steps 500
1355 function_return eBinType
1356 End_Function
1357
1358
1359 Procedure DFSetPrinterResolution integer eResType
1360 Send DFSetSpecPrintFlag eResType
1361 End_Procedure
1362
1363 Function DFGetPrinterResolution returns integer //eResType
1364 integer eResType
1365 Get PrintFlagRange 50000 10000 to eResType // 10000-500000 steps 10000
1366 function_return eResType
1367 End_Function
1368
1369
1370 Procedure DFSetLandscape boolean bIsLandscape
1371 Send DFSetSpecPrintFlag (If(bIsLandscape,DF_Landscape,DF_Portrait))
1372 End_Procedure
1373
1374 Function DFGetLandscape returns boolean // bIsLandscape
1375 boolean bIsLandscape
1376 Get DFCheckPrintDialogFlag DF_Landscape to bIsLandscape
1377 function_return bIsLandscape
1378 End_Function
1379
1380 Function RGBToWPColor integer iRgb returns integer
1381 integer iRed iGreen iBlue
1382 integer iWPColor
1383 Move (R_from_rgb(iRGB)) to iRed
1384 Move (G_from_rgb(iRGB)) to iGreen
1385 Move (B_from_rgb(iRGB)) to iBlue
1386 Get DfGetDfColor iRed iGreen iBlue to iWPColor
1387 function_Return iWPColor
1388 end_function
1389
1390
1391
1392End_Class
1393
1394Global_Variable Integer ghoWinPrint2
1395
1396Get Create of desktop U_cWinPrint2 to ghoWinPrint2
1397
1398
1399