Is there some free SDK or library that I can download that has printing functions that get rid of the need of everything except a couple lines of code when I need to print?
This is a discussion on Printing: The Lazy Way within the Windows Programming forums, part of the Platform Specific Boards category; Is there some free SDK or library that I can download that has printing functions that get rid of the ...
Is there some free SDK or library that I can download that has printing functions that get rid of the need of everything except a couple lines of code when I need to print?
Last edited by face_master; 07-30-2002 at 04:15 AM.
Please direct all complaints regarding this post to the nearest brick wallHave a nice day.
This is something I posted on another thread....its only a little code...and half of it is to diplay that nice print dialog.........Originally posted by face_master
Is there some free SDK or library that I can download that has printing functions that get rid of the need of everything except a couple lines of code?
Your best bet is to spend an hour reading the actual functions in the SDK......IMHO, it will take just as long to grasp the usage of a 3rd party lib.....and I think its less hassle
Code:#include <string>//I am lazy when it comes to char arrays using std::string; #include <windows.h>//The all important header #include <commdlg.h>//Dont forget comdlg32.lib!!! int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR,int) { PRINTDLG pd;//To initialise dialog & accept results string str = "API rules!! :p";//catchy phrase DOCINFO di = { sizeof(DOCINFO), "Fordy's Doc", NULL };//This gives details on doc...like its name when spooled ZeroMemory(&pd,sizeof(PRINTDLG));//saves initiliasing to zero pd.lStructSize = sizeof(PRINTDLG); pd.hwndOwner = HWND_DESKTOP; pd.Flags = PD_RETURNDC;//This gives DC to printer selected pd.nCopies = 1; if(!PrintDlg(&pd)) return 0;//If the user cancels....? if(StartDoc(pd.hDC,&di)>0 && StartPage(pd.hDC)>0){//new doc...new page TextOut(pd.hDC,10,10,str.c_str(),str.length()); //Write some text EndPage(pd.hDC);//end of page EndDoc(pd.hDC); //end of doc } DeleteDC(pd.hDC);//Clean up! return 0; }
Thanks, I try that!
Please direct all complaints regarding this post to the nearest brick wallHave a nice day.
I just have on question, to avoid heaps of confusion, could you please tell me how to replace this call using a character array instead of a string please?Code:TextOut(pd.hDC,10,10,str.c_str(),str.length());
Please direct all complaints regarding this post to the nearest brick wallHave a nice day.
Originally posted by face_master
I just have on question, to avoid heaps of confusion, could you please tell me how to replace this call using a character array instead of a string please?Code:TextOut(pd.hDC,10,10,str.c_str(),str.length());Code:char* buff = "Hello World"; int nLen = strlen(buff); TextOut(pd.hDC,10,10,buff,nLen);
Thanks.
Please direct all complaints regarding this post to the nearest brick wallHave a nice day.