Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Print Dialog using API
Message
 
To
29/04/2002 11:10:09
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Germany
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00649502
Message ID:
00650596
Views:
28
>>Agnes,
>>
>>I'm not exactly sure what you're asking here. If you wish to programmatically change the default printer, I'd use the WScript.Network object's SetDefaultPrinter() method (yes, it work with local printers as well). Ed Rauh and I documented how to do this in the December, 2000 issue of the VFUG newsletter in the fourth of our five articles on the Windows Script Host. It's available on-line at www.vfug.org.
>>
>>The Common Dialog Control's ShowPrinter() method may or may not change the default printer, depending on the value assigned to the PrinterDefault property.
>
>George,
>let's try in other words.
>
>1. My customer will not allow install of scripting host. (I myself avoid this as well)
>2. I will change only the printer for next REPORT FORM.
>3. I can not use the easy REPORT ... TO PRINTER PROMPT, because I need total pages in front of preview.
> If I change printer after counting with REPORT FORM xxxx TO PRINTER PROMPT it may change the total number of pages.
>4 I've use sys(1037) in the moment, but this is not what I like because is doesn't give any information about 'Cancel'.
>
>
>I add CommonDlg to a form, nothing is changed on it.
>My code looks like:
>
>...
>  THISFORM.oleCommonDialog.Flags = 0x100000+0x8+0x4
>  THISFORM.oleCommonDialog.ShowPrinter()
>*find 'Cancel'
>  IF THISFORM.gnFormError=1 THEN
>    RETURN
>  ENDIF &&thisform.gnFormError=1
>*count total
>  pcPageCount = ''
>  REPORT FORM xxxx NOCONSOLE TO FILE (lcTempFile)
>  pcPageCount = TRANSFORM(_PAGENO)
>  REPORT FORM xxxx to printer preview
>...
>
>The REPORT is printed to the printer I select on ShowPrinter and windows default printer is changed
>
>if I change to
>
>...
>  THISFORM.oleCommonDialog.Flags = 0x100000+0x8+0x4
>  THISFORM.oleCommonDialog.PrinterDefault = .F.
>  THISFORM.oleCommonDialog.ShowPrinter()
>*find 'Cancel'
>  IF THISFORM.gnFormError=1 THEN
>    RETURN
>  ENDIF &&thisform.gnFormError=1
>*count total
>  pcPageCount = ''
>  REPORT FORM xxxx NOCONSOLE TO FILE (lcTempFile)
>  pcPageCount = TRANSFORM(_PAGENO)
>  REPORT FORM xxxx to printer preview
>...
>
>the printer for REPORT FORM is not changed. ShowPrinter works in this case like a OK/Cancel messagebox with some controls to play with.
>
>I hope this describes my problem better.
>
>Maybe I run completely in the wrong direction, but what I finaly need is a report with totalpages, printer selectable, wich stops reporting if I press 'cancel' on print dialog.
>
>A far dream is to select a range of pages from preview, but as I see the problem I cannot do this.
>
>Any ideas to do this are welcome

Agnes,

SET PRINTER TO NAME < Windows Printer Name > won't work for you?

Just one comment about what you mentioned above (for both you and the customer). After Win98 the Windows Script Host isn't optional. IOW, if you ever upgrade Windows, it's going to be there. There is nothing "evil" about it, except that some people of highly questionable ethics, have used it to create worms.

Basically, the choice for both you and your customer is either stick with outdated and eventually unsupported technology, or not. The WSH isn't going away anytime soon. I wrote a "Postscript" article on the original WSH series for the VFUG newsletter that appeared last year. In it, I discuss these issues and what you can do about it.
George

Ubi caritas et amor, deus ibi est
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform