-
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 :D
Skeeks
-
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. "