Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I send a CString to printer inVC++ 6.0?

Status
Not open for further replies.

WebStar

Programmer
May 1, 2002
69
DE
I have a CString variable and it's value is the content of some files... How can i print this content... I thought of a way: to put the CString in a file and print the file with ShellExecute... but i don't want to create a new file. I make the programm in Visual C++ 6.0. Thank You!
 
Hi,
I think some code like this will work for you
CString myTestStr="Test";
CPrintDialog dlg(FALSE);
if (dlg.DoModal() == IDOK)
{
HDC hdc = dlg.GetPrinterDC();
ASSERT(hdc);
CDC* pDC = CDC::FromHandle(hdc);
pDC->TextOut(100,100,myTestStr);
//pDC=&hdc;
// Clean up.

}
//CDC::FromHandle(hdc)->DeleteDC();

I did not test but i think should work
 
Hi,
I think some code like this will work for you
CString myTestStr="Test";
CPrintDialog dlg(FALSE);
if (dlg.DoModal() == IDOK)
{
HDC hdc = dlg.GetPrinterDC();
ASSERT(hdc);
CDC* pDC = CDC::FromHandle(hdc);
pDC->TextOut(100,100,myTestStr);
//pDC=&hdc;
// Clean up.

}
//CDC::FromHandle(hdc)->DeleteDC();

I did not test but i think should work
in MFC if using SDK then
if (PrintDlg(&pd)==TRUE)
{
TextOut(pd.hDC,100,100,"PANKAJ",strlen
("PANKAJ"))
}
will do
hope it helps upto some extent
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top