Thread: print TextOut

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    10

    print TextOut

    how do i get this to print what's been copied to the clipboard?




    Code:
    TextOut (pd.hDC, 0, 0, "", 15);



    here's my compleate code

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <windows.h>
    
    main ()
    {
    	PRINTDLG	pd;
    	DOCINFO		di;
    	char*		szMessage;
    
    	memset (&pd, 0, sizeof(PRINTDLG));
    	memset (&di, 0, sizeof(DOCINFO));
    
    	di.cbSize = sizeof(DOCINFO);
    	di.lpszDocName = "Test";
    
    	pd.lStructSize = sizeof(PRINTDLG);
    	pd.Flags = PD_PAGENUMS | PD_RETURNDC;
    	pd.nFromPage = 1;
    	pd.nToPage = 1;
    	pd.nMinPage = 1;
    	pd.nMaxPage = 1;
    
    	szMessage = 0;
    
    	if (PrintDlg (&pd))
    	{
    		if (pd.hDC)
    		{
    			if (StartDoc (pd.hDC, &di) != SP_ERROR)
    			{
    				StartPage (pd.hDC);
    
    				TextOut (pd.hDC, 0, 0, "", 15);
    
    				EndPage (pd.hDC);
    
    				EndDoc (pd.hDC);
    
    				szMessage = "Printed.";
    			}
    			else
    			{
    				szMessage = "Could not start document.";
    			}
    		}
    		else
    		{
    			szMessage = "Could not create device context.";
    		}
    	}
    	else
    	{
    		szMessage = "Canceled or printer could not be setup.";
    	}
    
    	if (szMessage)
    	{
    		MessageBox (NULL, szMessage, "Print Test", MB_OK);
    	}
    
    	return 0;
    }
    Andrew Ferguson!

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    Still cutting and pasting as your compleate code has not be run thru a compiler.

    Learning much?



    to get the common dialogs to show you need to include

    commdlg.h

    watch out for truncation in the DevMode->dmDeviceName if using a network printer (or one with a long driver name).

    Don't forget to free the GDI resources you are allocating.

    Use winmain() not main() in win32 apps
    "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

  3. #3
    Emotionally Unstable DarkViper's Avatar
    Join Date
    Oct 2002
    Posts
    343
    GOOD GOD ANDEW!!!! i knew that one! im in the same info tech class as you and you didn;t ask me first!@!!! god damnit man!
    ~DJ DarkViper signing out
    ----------------------------------------
    My Site:
    Black Jaguar Studios

    Languages:
    Fluent English, Starter German, HTML, Javascript, Actionscript, Intermediate PHP

    Verteran Despiser of: ASP, Java, BASIC, Pascal, Cobalt

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. merging linked lists
    By scwizzo in forum C++ Programming
    Replies: 15
    Last Post: 09-14-2008, 05:07 PM
  2. Personal Program that is making me go wtf?
    By Submeg in forum C Programming
    Replies: 20
    Last Post: 06-27-2006, 12:13 AM
  3. Scope And Parameter Passing
    By djwicks in forum C Programming
    Replies: 6
    Last Post: 03-28-2005, 08:26 PM
  4. What kind of programs should I start writing?
    By Macabre in forum C++ Programming
    Replies: 23
    Last Post: 04-12-2003, 08:13 PM
  5. Replies: 1
    Last Post: 07-31-2002, 11:35 AM