Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Get the default printer

Get the default printer

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    Wim Engberts
    wrote on last edited by
    #1

    Hi all, When I print a document, I use the CPrinterDialog class. This works fine when I want to show the user the dialog and then het the printer's device context using "GetPrinterDC ()". But when the user clicks the print icon on the toolbar, I want to print without asking for the relevant printer, i.e. using the default printer. However, when I call "CPrintDialog::CreatePrinterDC ()", I do not get a DC. Microsoft's doc says that you then still need to initialise the dialog by DoModal, but I do not want that, since I do not want to show the user this dialog. Any bright ideas on how to get the default printer directly? Thanks in advance William

    W H 2 Replies Last reply
    0
    • W Wim Engberts

      Hi all, When I print a document, I use the CPrinterDialog class. This works fine when I want to show the user the dialog and then het the printer's device context using "GetPrinterDC ()". But when the user clicks the print icon on the toolbar, I want to print without asking for the relevant printer, i.e. using the default printer. However, when I call "CPrintDialog::CreatePrinterDC ()", I do not get a DC. Microsoft's doc says that you then still need to initialise the dialog by DoModal, but I do not want that, since I do not want to show the user this dialog. Any bright ideas on how to get the default printer directly? Thanks in advance William

      W Offline
      W Offline
      Wim Engberts
      wrote on last edited by
      #2

      Found the solution meanwhile (in case anybody is interested) call the printDialog's "GetDefaults ()" function will do the job. If there is no default printer, the function will return FALSE, in which case a print dialog should be shown anyway. Regards, WIlliam

      1 Reply Last reply
      0
      • W Wim Engberts

        Hi all, When I print a document, I use the CPrinterDialog class. This works fine when I want to show the user the dialog and then het the printer's device context using "GetPrinterDC ()". But when the user clicks the print icon on the toolbar, I want to print without asking for the relevant printer, i.e. using the default printer. However, when I call "CPrintDialog::CreatePrinterDC ()", I do not get a DC. Microsoft's doc says that you then still need to initialise the dialog by DoModal, but I do not want that, since I do not want to show the user this dialog. Any bright ideas on how to get the default printer directly? Thanks in advance William

        H Offline
        H Offline
        Hamid Taebi
        wrote on last edited by
        #3

        Is GetDefaultPrinter good?

        _**


        **_

        WhiteSky


        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups