Thread: Printing

  1. #1
    Sunny M
    Guest

    Question Printing

    How do i print to a printer given a text in the edit box

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    WIN32 API or MFC/C++?

    In WIN32 API.
    Roughtly;

    Get the printer/s with GetProfileString() or EnumPrinters() ect. Using the right PRINTER_INFO_# (1-5) depending on the OS ect.

    Use PageSetupDlg() with a PAGESETUPDLG struc to allow the user to change the settings of the printer in the common dlgs (ensure that you have included/init common dlgs)

    Get a HDC for the printer the user selected. (In the *DEVMODE struct.)

    Send the StartDoc()

    Send StartPage()

    Print the data to the HDC of the printer. (TextOut())

    Send the EndPage()

    Send EndDoc()

    Release the printer HDC.

    Don't forget the AbortProc if the user wants to cancel the print.
    Read Petzold's 'Prgramming Windows'
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C# Printing Problem
    By silverlight001 in forum C# Programming
    Replies: 0
    Last Post: 03-23-2009, 01:13 AM
  2. generic printing preferences dialog box
    By stanlvw in forum Windows Programming
    Replies: 8
    Last Post: 06-27-2008, 02:20 AM
  3. printing data to a file
    By coralreef in forum C Programming
    Replies: 3
    Last Post: 11-02-2006, 08:10 PM
  4. need help relating printing?
    By omarlodhi in forum Linux Programming
    Replies: 0
    Last Post: 03-03-2006, 04:46 AM
  5. Printing
    By Dual-Catfish in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 05-25-2002, 08:10 PM