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