hi,
I am new to VC++. Are there any functions which can be used to print
all kind of files to the printer. I have tried, ShellExecute().. But it
is able to print only document files. I am not able to print image
files, ppts and some more.
I tried with OpenPrinter(), but i dont know how to send all kind of
files once we open it.
Then I also tried CDC.. With that also between StartDoc() and EndDoc()
what should be written for printing?

Please give some suggestions...

Re: printing all kind of files by Alex

Alex
Thu Jun 08 03:49:37 CDT 2006

sonijindal@gmail.com wrote:
> I am new to VC++. Are there any functions which can be
> used to print all kind of files to the printer. I have
> tried, ShellExecute().. But it is able to print only
> document files. I am not able to print image files, ppts
> and some more.

You can print any file on Windows if it has associated
programs, which will handle printing. Specify "print" verb
for lpOperation parameter of ShellExecute.

> I tried with OpenPrinter(), but i dont know how to send
> all kind of files once we open it.
> Then I also tried CDC.. With that also between StartDoc()
> and EndDoc() what should be written for printing?

These functions are for the program, which actually makes
printing, i.e. it knows how to open the file and to show it
(either on screen or print or any other device).



Re: printing all kind of files by sonijindal

sonijindal
Thu Jun 08 21:50:30 CDT 2006

first of all thanx...
I tried ShellExecute() with "print" parameter. But I read that this can
print only document files. Probably because of this reason when i am
trying to print jpeg files it simply opens the file in the windows
picture and fax viewer instead of printing it directly. Similarly for
ppt it opens the print dialog. Instead i want these files to directly
print instead of asking anything. Please tell me how can i do this.
And also tell me what does this mean:

>You can print any file on Windows if it has associated
> programs, which will handle printing.


Alex Blekhman wrote:

> sonijindal@gmail.com wrote:
> > I am new to VC++. Are there any functions which can be
> > used to print all kind of files to the printer. I have
> > tried, ShellExecute().. But it is able to print only
> > document files. I am not able to print image files, ppts
> > and some more.
>
> You can print any file on Windows if it has associated
> programs, which will handle printing. Specify "print" verb
> for lpOperation parameter of ShellExecute.
>
> > I tried with OpenPrinter(), but i dont know how to send
> > all kind of files once we open it.
> > Then I also tried CDC.. With that also between StartDoc()
> > and EndDoc() what should be written for printing?
>
> These functions are for the program, which actually makes
> printing, i.e. it knows how to open the file and to show it
> (either on screen or print or any other device).


Re: printing all kind of files by Alex

Alex
Fri Jun 09 05:35:51 CDT 2006

sonijindal@gmail.com wrote:
> first of all thanx...
> I tried ShellExecute() with "print" parameter. But I read
> that this can print only document files. Probably because
> of this reason when i am trying to print jpeg files it
> simply opens the file in the windows picture and fax
> viewer instead of printing it directly. Similarly for ppt
> it opens the print dialog. Instead i want these files to
> directly print instead of asking anything. Please tell me
> how can i do this. And also tell me what does this mean:
>
>> You can print any file on Windows if it has associated
>> program, which will handle printing.

Many file extensions on Windows have associated programs
with them. E.g., when you click on .doc file, then MS Word
opens it, when you click on .mp3 file, Windows Media Player
will open it, or any other program, which is currently
associated with .mp3 extension. Program that associates
itself with some file type usually knows how to open it and,
if file can be printed, how to print it.

There are several common actions that usually performed
while working with file. Windows Shell decided that these
actions are common enough to provide unified mechanism of
handling and registering these actions. So, any application
can choose extensions it want to be associated with and
action (verb) it will handle.

ShellExecute documentaion calls editable files as
"documents". Because, usually user wants to print what
he/she can edit (for example, Word or image file). There is
no common way to print .mp3, though. Most MS Office
documents can be printed programmatically because there are
associated handlers of "print" action. Also, many programs
provide command-line switches to enable programmatic
printing (besides other things), for example Adobe Acrobat
Reader can print .pdf files via command-line switches. You
will need to read program's documentation to figure out
whether it supports printing from command-line.

If currently associated program cannot programmatically
print its documents, then you will need to find (or write by
yourself) other program, which can do it.

HTH
Alex