1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
#include <iostream>
#include <Windows.h>
using namespace std;
int WINAPI WinMain( HINSTANCE hInst, HINSTANCE hprev, LPSTR lpcmdline, int ncmdshow)
{
LPSTR PrintIn;
cout << "Enter in code to print:" << endl;
cin >> PrintIn;
cin.get();
PRINTDLG pd;
memset( &pd, 0, sizeof( pd ) );
pd.lStructSize = sizeof( pd );
pd.Flags = PD_RETURNDEFAULT | PD_RETURNDC;
if( !PrintDlg( &pd) )
{
MessageBox( NULL, "Printing Failed", "Fatal Error", MB_OK | MB_ICONERROR);
return -1;
}
DOCINFO di;
HDC hPrinter = pd.hDC;
memset( &di, 0, sizeof( di ) );
di.cbSize = sizeof( di );
StartDoc( hPrinter, &di );
StartPage( hPrinter );
TextOut( hPrinter, 100, 100, PrintIn, 13);
EndPage( hPrinter );
EndDoc( hPrinter );
DeleteDC( hPrinter );
return 0;
}
|