Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I'm trying to print a page using below function:
hr = lpOleCommandTarget->Exec(NULL, OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER,NULL, NULL);


But the problem is,it is always printing one copy only even if I give more than 1. I'm doing printer setup on top of it using CPrintDLg class as below:
CPrintDialog dlgl(FALSE);
	INT_PTR userResult = dlgl.DoModal();

I'm doing it because I have some extra functionality based on the printer which I selected. Here I'm getting proper count but when I call lpOleCommandTarget->Exec(""), it is printing only one. So can any one suggest how can I pass number of copies to Exec("") function?

What I have tried:

<pre>hr = lpOleCommandTarget->Exec(NULL, OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER,NULL, NULL);
Posted
Updated 4-Apr-17 3:43am
v3

1 solution

According to IDM_PRINT Command ID ()[^] there is no option to specify the number of pages copies.

But you can get the number of copies selected by the user from the print dialog and execute the print job multiple times.
 
Share this answer
 
v2
Comments
cppcoder1 5-Apr-17 9:03am    
Thanks Jochen. I meant number of copies, Not pages.
If you call multiple times, it will create multiple print jobs. So I have to select each job separately to print.It will be difficult if I want to print more copies ryt?
Jochen Arndt 5-Apr-17 9:15am    
I meant copies too (mentioning pages was a typo).
Sorry no solution.
But print jobs are queued. So it should be not too much overhead to use something like
for (int i = 0; i < copies; i++)
    lpOleCommandTarget->Exec(...);
cppcoder1 6-Apr-17 2:52am    
It will be problem when user sets a password to print.For each job password will be required.It is overhead.
Jochen Arndt 6-Apr-17 3:08am    
That is off course a problem.
It seems that there is no satisfying solution.
cppcoder1 6-Apr-17 7:36am    
Hmmmm...so there is no way to pass no.of copies to Exec(...)???

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900