Click here to Skip to main content
15,918,516 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello All,

Can anyone let me know a way to print data of edit box or listctrl from CFormview of SDI Application?
Posted

You can get read the data from editbox or list control and draw (May be TextOut()) it using GDI functions to printer DC.
 
Share this answer
 
When we draw something on the window, we use window DC with GDI functions. Similarly to draw to a printer we have to use printer DC instead of window DC with the GDI functions. May be you can take a look at the following articles for details:
http://msdn.microsoft.com/en-us/library/df9f4ta6(VS.80).aspx[^]
Printing with MFC Made Easy[^]
 
Share this answer
 
Please try :) :
{
...
  CRect crLocation(0, 0, 1000, 1000);
  pDC->Rectangle(crLocation);
  crLocation.DeflateRect(20, 20, 20, 20);
 
  CString cszTest(_T("this is a long test line to be printed here and now :)"));
  pDC->DrawText(cszTest,
                crLocation,
                DT_LEFT | DT_NOPREFIX | DT_TOP | DT_WORDBREAK);
...
}
 
Share this answer
 
v2
Eugen,

This is not working, I am not getting Print Preview for this.
 
Share this answer
 
Hi Rejeesh,

I can take data from Edit box, but when i call Printer command, and window pops up and i say print, then it am not getting anything on paper.

How to send data to printer so that i can get data on paper thru printer?
 
Share this answer
 
Hi Rejeesh,

I went thru your suggested link. I am able to get print out of the data.
But now problem is: My data is multiline data and printer is not able to recognize this.

Do you have any idea, how to make printer working as MS Word Document?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900