Printing using the default printer from within a function

Posted on 1998-07-15
Last Modified: 2013-11-20
How do I call the default printing in a View from other than the menu?  I would also like to suppress the Print Dialog.  I have a POS application (MDI) in progress with buttons in the main view class indicating payment methods.  When the user presses the appropriate button, I would like to do some calcs, open the cash drawer, then print the invoice without further users intervention.  I have the default printing in the view class implemented and working from the menu and toolbar.


Question by:patrickm
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Expert Comment

ID: 1319249
I have done something similar, what you do, I don't know the exact code off hand but can get it if you can't figure it out, is Post a Messeage to your application the windows message you post is something like ID_FILE_PRINT_DIRECT, I think, if you look at the menu handler for the toolbar option print, it will tell you, since that suppresses the dialog, not showing it, which is what I think you want.  comment if you have any further questions.

Author Comment

ID: 1319250
Thanks TAMC, I am very weak on MFC and VC++, if you could provide me with syntax, I would appreciate it.


LVL 23

Accepted Solution

chensu earned 50 total points
ID: 1319251
There are several methods. One of them is the following.

BOOL bSucc = ::AfxGetApp()->GetPrinterDeviceDefaults(&PrintDlg) &&
if (bSucc)
    // use PrnDC to print
    // failed to create the printer DC


Author Comment

ID: 1319252
I ended up with


in my View Class. Works like a charm.

Thanks for the syntax chensu

Featured Post

ClickHouse in a General Analytical Workload

We have mentioned ClickHouse in some recent posts, where it showed excellent results.

In this article on Experts Exchange, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

632 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question