How do you print stuff using the winapi in C

This is a discussion on How do you print stuff using the winapi in C within the Windows Programming forums, part of the Platform Specific Boards category; It may not be supported, I'm not sure. All I found when I looked it up were pure C++ and ...

  1. #1
    Registered User HelpfulPerson's Avatar
    Join Date
    Jun 2013
    Location
    Over the rainbow
    Posts
    288

    How do you print stuff using the winapi in C

    It may not be supported, I'm not sure. All I found when I looked it up were pure C++ and C# samples.

  2. #2
    Registered User HelpfulPerson's Avatar
    Join Date
    Jun 2013
    Location
    Over the rainbow
    Posts
    288
    Oh and by printing I'm talking text documents.

  3. #3
    Registered User
    Join Date
    Jun 2009
    Posts
    87
    Do you mean sending the edit control text to a printer for printing? If so, then wouldn't that fall under winapi GDI category? I know that writing a printer function in C can be a bit challenging sometimes.

  4. #4
    Registered User HelpfulPerson's Avatar
    Join Date
    Jun 2013
    Location
    Over the rainbow
    Posts
    288
    Quote Originally Posted by TAZIN View Post
    Do you mean sending the edit control text to a printer for printing? If so, then wouldn't that fall under winapi GDI category? I know that writing a printer function in C can be a bit challenging sometimes.

    Yea, I just want to make a function that can print a normal average text document in your default printer.

  5. #5
    Registered User
    Join Date
    Jun 2009
    Posts
    87
    There are a few basic tutorials on line that illustrate the basics for winapi printing. Also check out the Multipad example program supplied with earlier Win32 SDK discs. I think Petzold also has an example in one of his text editor programs.

  6. #6
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    You can use print action of ShellExecute ShellExecute function (Windows)
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  7. #7
    Registered User HelpfulPerson's Avatar
    Join Date
    Jun 2013
    Location
    Over the rainbow
    Posts
    288
    Quote Originally Posted by vart View Post
    You can use print action of ShellExecute ShellExecute function (Windows)
    Oh, thanks Vart, I've used that function before.

  8. #8
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    Otherwise search here for more info.

    In WIN32 API is used to be;

    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.
    "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. Game-related stuff with WinAPI
    By YuriKahn in forum C Programming
    Replies: 2
    Last Post: 05-23-2013, 04:17 AM
  2. Replies: 15
    Last Post: 06-13-2012, 12:34 PM
  3. Why does this print some stuff
    By kool_hamster in forum C Programming
    Replies: 1
    Last Post: 01-27-2010, 09:11 AM
  4. Replies: 2
    Last Post: 06-27-2003, 01:45 PM
  5. Tab key stuff. C+WinAPI is killing me. Please help.
    By Templario in forum Windows Programming
    Replies: 5
    Last Post: 11-21-2002, 02:35 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21