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 42 43 44 45 46 47
|
#include <windows.h>
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
int WINAPI WinMain( HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, int nCmdShow ){
PRINTDLG pd;
memset( &pd, 0, sizeof( pd ) );
pd.lStructSize = sizeof( pd );
pd.Flags = PD_RETURNDEFAULT | PD_RETURNDC;
if( !PrintDlg( &pd ) ){
MessageBox( NULL, L"PrintDlg( &pd ) failed!", L"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 );
//print text to printer
TextOut( hPrinter, 100, 100, L"Hello, World!", 13 );
EndPage( hPrinter );
EndDoc( hPrinter );
DeleteDC( hPrinter );
return 0;
}
int main(){
string name;
cout << "Enter Your Name:";
getline(cin,name);
cout << "Please enter you choice <1 = Print , 2 = Exit> :";
int choice;
cin >> choice;
if (choice == 1){}
if(choice == 2){
cout<<"Please select 1....because this system is trying to print !!"<<endl;
return 0;
}
}
|