hello mydear helpers,
This is venu.
I'm facing a problem in order to write a program, which will set the printer setting programatically.
I downloaded the code given here, but problem with this is , when i am executing the program throu VC++, itz displaying a printer window, which the enduser has to set the things manually, but i need them to be done programatically, and that window shd not open....
i need to change these 4 settings thr program and when execute my prograam, it has to print directly the txt file ...
1)printer (when more than one exists, bydefault itselects one)
2)no of pages
3)no of copies
4)Tray settings i.e., (letter , legal, A4size..)
I am having a problem printing multiple copies of a custom print function I wrote.
Basically I want a printout when my function is called, no user interface. I can get
a single printout, but not multiple copies. Also I can get multiple copies if I bring
up the print dialog which I don't want to do. Here is my code... Any suggesstions thanks!
//DONT WANT TO BRING UP THE DIALOG
//if (printDlg.DoModal() == IDCANCEL) // Get printer settings from user
//THOUGHT THIS LINE WOULD WORK. HAS BEEN BEFORE AND AFTER GET DEFAULTS
dc.Attach(printDlg.GetPrinterDC()); // Attach a printer DC
dc.m_bPrinting = TRUE;
DOCINFO di; // Initialise print document details
::ZeroMemory (&di, sizeof (DOCINFO));
di.cbSize = sizeof (DOCINFO);
di.lpszDocName = _T("TEST");
BOOL bPrintingOK = dc.StartDoc(&di); // Begin a new print job
// Get the printing extents and store in the m_rectDraw field of a
// CPrintInfo object
Thanks to Joel Matthias who told me there is an
bug in the second constructor. It will never
call the default constructor as intended.
Here is how to correct the code:
First throw out the seconde constructor in
Modify the default constructor.
It should then read like this:
class CPrinterSettings : public CObject
// default construction
CPrinterSettings(const CString dirname = "");
// copy construction
CPrinterSettings(const CPrinterSettings& cp);
// for use e.g. in CArray
In printersettings.cpp do the following modification:
Throw out the implementation of the second constructor.
Modify the default constructor as follows:
Cool stuff, but how can I create a DC, especially without displaying the PrintDialog?
if (PrintInfo.m_pPD->DoModal() == IDOK)
PrintInfo.m_pPD->m_pd.hDC = dcPrint.hDC;
// copy the ID of the new valid handle
- if PrintDialog is displayed, the stored printer is not the selected one in the printer dropdown.
- AfxGetApp()->CreatePrinterDC returns a valid DC, put there is no information availabe about the output port etc.
I could use
How do I change system's default printer settings?
Can anyone help me on this?
My application does printing thorugh OLE call on an automation server which uses default printer settings (we cannot control on the automation server)
What I want to do is to set a default, let the automation server to use it.