Changing Paper Size

I have one last issue with my application.  I have to change the paper size to what the user selects in the web interface.  I pass over the value DMPAPER_... When I set the dmPaperSize in the DEVMODE struct it doesn't work.  It continues to print on the 8.5 x 11.  I even tried hard coding the 11 x 17 paper into DEVMODE but it came out 8.5 x 11.  Do I have to select the tray somehow?  I have messed around with DM_DEFAULTSOURCE with no success and with the DeviceCapabilities function.  Any ideas?  Thanks.
paulcaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nietodCommented:
Not you again :-)

Do you set the DM_PAPERSIZE bit of the DEVMODE's dmFields member?

If not, that is likely to be the problem.  If so, can you post the code?  
0
paulcaAuthor Commented:
Yes, I set that.  So, I guess that's not the problem.

if (pDevMode->dmFields & DM_PAPERSIZE)
 pDevMode->dmPaperSize = DMPAPER_11X17;
0
nietodCommented:
Sorry, I meant all the code (all the related code.)

Also, have you tried doing this "manually" (i.e. using the printer dialog from some commercial application.) to make sure the printer and its driver are capable of using the paper sizes you selected.  (some cut-sheet printers support and paper size so long as it is 8 1/2 X 11.)
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

paulcaAuthor Commented:
//  Parse m_printerinfo string
device = strtok(m_dpr.m_printerinfo, cmp);      
driver = strtok(NULL, cmp);
output = strtok(NULL, cmp);

// Start by opening the printer
OpenPrinter(device, &hPrinter, NULL);

dwNeeded = DocumentProperties(hWnd,hPrinter,device,NULL, NULL,0);

pDevMode = (LPDEVMODE)malloc(dwNeeded);

dwRet = DocumentProperties(hWnd,hPrinter,device,pDevMode,NULL,DM_OUT_BUFFER);

if (pDevMode->dmFields & DM_ORIENTATION)
// if the printer supports paper orientation, set it
pDevMode->dmOrientation = DMORIENT_LANDSCAPE;

if (pDevMode->dmFields & DM_COPIES)
// if the printer supports multiple copies, set it
pDevMode->dmCopies = m_dpr.m_copies;

if (pDevMode->dmFields & DM_PAPERSIZE)
pDevMode->dmPaperSize = DMPAPER_11X17; // m_dpr.m_papersize;

dwRet = DocumentProperties(hWnd,hPrinter,device,pDevMode,pDevMode,DM_IN_BUFFER |DM_OUT_BUFFER);

// Done with the printer
ClosePrinter(hPrinter);

0
nietodCommented:
That looks pretty good.

Just to check, you did confirm paper size flag was set, right?  if it wasn't you code would skip the if() that sents the paper size.

You might try changing the last DocumentPriperties() call so that it stores the properties in a 2nd (seperate) DEVMODE.  It is possible that the same devmode can't be used for both.  (Although I really doubt that is the case.)
0
paulcaAuthor Commented:
I don't know what to tell you.  I am printing to Xerox DocuCenter where the 1st 3 trays are 8.5 x 11 and the 4th tray is 11 x 17.  Do I have to tell the printer to take the paper from Tray 4 somehow?
0
nietodCommented:
Try doing this manually from Word or other program that lets you print, and see if you can make it work manually and what you have to do to make it work.
0
paulcaAuthor Commented:
I printed from Word.  All I had to do was select 11 x 17 from the Scale to Paper Size drop down list box.  Nothing more to it.  I wonder what that translates to in C++ by selecting the 11 x 17.
0
nietodCommented:
Perhaps the problem is the paper bin (tray)--as you suggested.

try setting the dmDefaultSource to DM_LARGERFMT or LARGECAPACITY and set the DM_DEFAULTSOURCE flag if the dmFields member.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
paulcaAuthor Commented:
I have tried both of those.  I think I am going to have to return a list of bins and papersizes from DeviceCapabilites.  If I see anything in here that I can set dmDefaultSource to, I'll try that.  Maybe it's just a matter of setting the dmDefaultSource to the correct bin.
0
nietodCommented:
An "A"?  I didn't think I contributed ANYTHING.  You got it to work I assume.
0
paulcaAuthor Commented:
Yeah, I got it to work.  I put in the A because you have been very helpful in the past also.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.