PrinterSettings - Changing, Storing and Loading Printer Settings
Posted
by Franz Brunner
on August 1st, 1999
Description
Several years ago I had to implement the ability to change the printer and it's settings from within a programm. The output had to be distributed to 3 or more printers. The settings had to be stored to disk to be able to be loaded. It was desired to conform to the MFC Framework.
How to use
Declare the class CPrinterSettings in a CDocument derived class or wherever you find it useful.
#include "PrinterSettings.h"
class CPrnsetupDlg : public CDialog
{
public:
CPrinterSettings m_prn_setting1;
CPrinterSettings m_prn_setting2;
To get a copy of the original MFC printer settings
call CopyDefaultMfcPrinter().
// Get MFC's default printer m_prn_setting1.CopyDefaultMfcPrinter(); m_prn_setting2.CopyDefaultMfcPrinter();To let the user change the settings e.g. paper orientation or printer resolution call PrinterSetup( CWnd* pWnd ).
m_prn_setting1.PrinterSetup(this);To cause MFC to use your settings call SetThisPrinter().
// make m_prn_setting1 the MFC standard printer m_prn_setting1.SetThisPrinter(); // later you may call RestorePrinter() to // restore earlier settings.To load or save your settings call Save(LPCTSTR filename ) or Load(LPCTSTR filename ).
// Save our settings to file m_prn_setting1.Save( "testfilename"); ... ... // load settings, store them in m_prn_settings1 m_prn_setting1.Load( "testfilename" ));
Downloads
The name of the project is "prnsetup.dsw" (build with VC 6 )
The source files are named: PrinterSettings.h and PrinterSettings.cpp

Comments
More concessions with herveleger, more move upon!
Posted by Mrleftcoqiq on 04/19/2013 09:32pmmaidentoms store christian louboutin shoes picayune shavertoms outlet online aviditytoms shoes cheap toms shoes cheap stablecheap toms sale undefiledtoms store rep
ReplyHere is how to print to a network printer
Posted by Legacy on 02/12/2004 12:00amOriginally posted by: Jocelyn Gennesseaux
ReplyLong Printer Names - THANKS
Posted by Legacy on 12/10/2003 12:00amOriginally posted by: Deyvi Pilosof
ReplyLoad a setups across different OS's
Posted by Legacy on 10/24/2003 12:00amOriginally posted by: Jens Froslev-Nielsen
Hi Here,
I've having a problem with loading print setups saved from W2K in XP and visa-verse. In my case I've a EPSON 2100 and the dmPrintQuality param is not loaded correctly across the OS's. Saving/Loading from the same! OS seems to work ok.
Does anyone has a (quick and dirty??) solution? .
Currently I've two saved to setup's MyPrintEPSON2100-XP and
MyPrintEPSON2100-W2K.
Thx - Jens
ReplyModifying printer default setting in dialog based application
Posted by Legacy on 08/02/2003 12:00amOriginally posted by: Rick
Many thanks to the earlier posters. The following is an example of what worked in a dialog based application where I wanted to use the CPrintDialog DoModal function where a user could change printer options but where I wanted to printer dialog box to open with certain defaults already in place ( such as for printing out an envelope ). This was in a function in the Dlg class, not the App class.
When the print dialog box opens the defaults are set to #10 envelope and landscape orientation typical for most envelopes. The user still can change to something else ( another sized envelope if needed ).
void CCPhoneDlg::OnCopyEnvelopes()
{
CDC dcPrint;
PRINTDLG pDdlg;
DEVMODE *mode = NULL;
CPrintDialog dlgPrint(FALSE, PD_ALLPAGES,this);
if(AfxGetApp()->GetPrinterDeviceDefaults(&pDdlg))
{
mode = (DEVMODE *) GlobalLock(pDdlg.hDevMode);
mode->dmOrientation = DMORIENT_LANDSCAPE;
mode->dmPaperSize = DMPAPER_ENV_10;
GlobalUnlock(pDdlg.hDevMode);
}
dlgPrint.m_pd.hDevMode = mode;
// Note above line worked,
// dlgPrint.ResetDC(mode) did not work
if(dlgPrint.DoModal() == IDOK)
{
dcPrint.Attach(dlgPrint.GetPrinterDC());
DOCINFO myPrintJob;
myPrintJob.cbSize = sizeof(myPrintJob);
myPrintJob.lpszDocName = "MyPrintJob";
myPrintJob.lpszOutput = NULL;
myPrintJob.fwType = NULL;
...continue with print job......
Reply
http://www.ucancode.net
Posted by Legacy on 08/01/2003 12:00amOriginally posted by: MFC Diagramming,Flow Class Library with Full Source Code!
Great!
ReplyHow can my application see all system's printing operation?
Posted by Legacy on 04/07/2003 12:00amOriginally posted by: hnim
I have to build an application that manages all operations of a desktop such as count number operations that are sucessful/fail or canceled...But i don't know where to begin: which hooks i have to use,how to use it...
Replyi need help...
Thanks
Pl help me ... to Control the Printer using a programme (VB)
Posted by Legacy on 03/03/2003 12:00amOriginally posted by: Isuru Binduhewa
Pl can anybody help me...
I need to restrict getting printouts. Such that I need to set a password on any printing job (Ms Word, Notepad, Adobe, etc.) and control the no of printouts allowed.(In VB or c++)
If some one can help me on this would greately appreciated
ReplyI want to change the size of the page in print preview
Posted by Legacy on 07/31/2002 12:00amOriginally posted by: Ashutosh
i am using the class CView for printing. So, i want to set the page size of(800x480) pixels which will show in print preview. since when i saw print preview it showing things on approx half of the page. So, anyone can help me.
Replythanks in advance.
ashutosh
HTML printing problem
Posted by Legacy on 04/24/2002 12:00amOriginally posted by: Bahar
ReplyLoading, Please Wait ...