Printing files

Printing files

Postby chiaiese » Fri Mar 03, 2006 7:26 pm

I know it is possible to print a file using ShellExecute() but it prints to the default printer.
There is a way to redirect the print to another printer ?
I need to print various types of files to a specified printer (doc rtf pdf ecc.)
chiaiese
 
Posts: 84
Joined: Wed Feb 08, 2006 10:32 pm
Location: Roma, Italia

Re: Printing files

Postby Enrico Maria Giordano » Fri Mar 03, 2006 8:17 pm

Use SetPrintDefault() function just before calling ShellExecute().

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8716
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby chiaiese » Sat Mar 04, 2006 2:30 pm

Enrico,
thanks for your answer

however I have found this other way that is simpler than setting and then restoring the default printer:

ShellExecute(0,"PrintTo",cMyDocument,"PDFCreator",0,1)

Roberto
chiaiese
 
Posts: 84
Joined: Wed Feb 08, 2006 10:32 pm
Location: Roma, Italia

Postby Enrico Maria Giordano » Sat Mar 04, 2006 2:45 pm

Wonderful!

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8716
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby chiaiese » Sun Mar 05, 2006 5:28 pm

On one PC *only* I have this problem:

though I have set wordpad as the standard app to open rtf files, when I issue the ShellExecute(0,"PrintTo",cMyDoc,cMyPrinter0,0) statement, the document is printed using MsWord
If I double-click the rtf file, then WordPad is used
Normally the application used to open the file is the same that is used to print it. How can I force printing using WordPad ?

Roberto
chiaiese
 
Posts: 84
Joined: Wed Feb 08, 2006 10:32 pm
Location: Roma, Italia

Postby Enrico Maria Giordano » Sun Mar 05, 2006 5:46 pm

Check the properties of the RTF extension association. Specifically, look inside Open method. Try to compare it with those of a working PC.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8716
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby chiaiese » Mon Mar 06, 2006 8:38 am

do you mean by right-clicking the file, or something else in the windows registry (or INI file) ?
chiaiese
 
Posts: 84
Joined: Wed Feb 08, 2006 10:32 pm
Location: Roma, Italia

Postby Enrico Maria Giordano » Mon Mar 06, 2006 10:38 am

No, Tools -> Folder options -> File types (Strumenti -> Opzioni cartella -> Tipi di file in Italian).

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8716
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Ollie » Thu Mar 13, 2008 3:02 pm

ShellExecute(0,"PrintTo",cMyDocument,"MyPrinter",0,1)

works well, but it prompts the user to select the printer. Is there a way to just print directly with out the PrintSetup screen?
Many thanks
Ollie.

Using:
xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 6406)
Borland C++ 5.5.1
FWH 9.04 (2009 Apr)
Ollie
 
Posts: 233
Joined: Sat Dec 30, 2006 6:10 am

Postby chiaiese » Mon Mar 17, 2008 8:18 am

It should not prompt the user.
Check for the correct printer name as you find it in the printer folder

regards
Roberto
Roberto Chiaiese
R&C Informatica S.n.c.
http://www.recinformatica.it
info@recinformatica.it
chiaiese
 
Posts: 84
Joined: Wed Feb 08, 2006 10:32 pm
Location: Roma, Italia

Postby Ollie » Fri Mar 28, 2008 3:03 pm

It definitely prompts the user.

I even tried:

ShellExecute( 0, "PrintTo", cHTMOut, PrnGetName() , 0, 1 )

? PrnGetName()
reports the correct name.
Many thanks
Ollie.

Using:
xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 6406)
Borland C++ 5.5.1
FWH 9.04 (2009 Apr)
Ollie
 
Posts: 233
Joined: Sat Dec 30, 2006 6:10 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 74 guests