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?
Printable View
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 something I posted on another thread....its only a little code...and half of it is to diplay that nice print dialog.........Quote:
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!
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());
Quote:
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.