Printdlg - Xp

This is a discussion on Printdlg - Xp within the Windows Programming forums, part of the Platform Specific Boards category; I am doing some test printing from my application - using Dev-cpp. I am using the following which works fine ...

  1. #1
    Registered User
    Join Date
    Nov 2004
    Posts
    1

    Printdlg - Xp

    I am doing some test printing from my application - using Dev-cpp.

    I am using the following which works fine under Win 2000 but won't even raise the print dialog in Windows XP

    Code:
     PRINTDLG pd;
    memset( &pd, 0, sizeof( pd ) );
    pd.lStructSize = sizeof( pd );
    /* 
    * get rid of PD_RETURNDEFAULT on the line below if you'd like to
    * see the "Printer Settings" dialog!
    *
    */
    pd.Flags = PD_RETURNDC;
    // try to retrieve the printer DC
    if( !PrintDlg( &pd ) )
    {
    MessageBox( NULL, "PrintDlg( &pd ) failed!", "Fatal Error", MB_OK | MB_ICONERROR );
    return;
    }
    DOCINFO di = {
    sizeof(DOCINFO),
    "Printer Test",
    NULL
    };
     
    HDC hPrinter = pd.hDC;
    // initialization of the printing!
    memset( &di, 0, sizeof( di ) );
    di.cbSize = sizeof( di );
    StartDoc( hPrinter, &di );
    // start the first and only page
    StartPage( hPrinter );
    // uncomment the following line to print in colour! :)
    //SetTextColor( hPrinter, 0x0000FF );
    // write "Hello, World!" to the printer's DC
    TextOut( hPrinter, 100, 100, "Hello, World!", 13 );
    // finish the first page
    EndPage( hPrinter );
    // end this document and release the printer's DC
    EndDoc( hPrinter );
    DeleteDC( hPrinter );
    return;
    Anybody know why this won't work under XP - and what will

    Skeeks

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    Have you tried using PrintDlgEx()?

    or

    MSDN
    "The PrintDlg function can also display a Print Setup dialog box. However, new applications should not use PrintDlg for this purpose. The Print Setup dialog box has been superseded by the Page Setup dialog box created by the PageSetupDlg function."

    "Windows 2000/XP: The PrintDlg function has been superseded by the PrintDlgEx function. PrintDlgEx displays a Print property sheet, which has a General page containing controls similar to the Print dialog box. "
    "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. Replies: 8
    Last Post: 05-07-2009, 11:31 AM
  2. Trying to Install XP over Vista with SATA HD
    By Shamino in forum Tech Board
    Replies: 2
    Last Post: 12-13-2008, 05:56 PM
  3. Need help with program
    By HAssan in forum C Programming
    Replies: 8
    Last Post: 06-10-2007, 08:05 PM
  4. Question..
    By pode in forum Windows Programming
    Replies: 12
    Last Post: 12-19-2004, 06:05 PM
  5. Windows XP regression over time
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 12-17-2002, 09:49 AM

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