Hi everyone,

I'm busy working on a word processor in Visual C++ 2008 and I need some help with a Print option, and a Page Setup option. What I'm trying to do is print the contents of a RichTextBox control (txtdisplay), and can't find any way to get it to work. Google hasn't helped at all, and I'm a true noob...

Here are the controls I currently have:

txtdisplay (the RichTextBox)
printDocument1 (Printdocument control)
pageSetup1 (Page Setup Dialog)
PrintDialog1 (Print Dialog Box)


So if anyone experienced with Visual C++ 2008 could lend a hand in terms of printing, it would be greatly appreciated.

Thanks in advance.

The Win32 GDI abstracts a DC over the printer, so using the printer is very much like drawing a form.

Here's the MSDN Printing and Print Spooler reference.

It includes all the information you need to know about the printer GDI and provides a number of good examples.

Hope this helps.

Thanks for the links, but I don't think you quite understand what I need.

You see, I'm trying to print the content of the richtextbox control, like in Windows Notepad. Click the Print button, it opens the dialog, and prints the content of the text area.

I've tried searching google, it gives a million ways to do it, but only in Visual Basic :(

Don't forget that I'm a total noob, sorry.

Would this be of any help?

You also need to convert the RichTextBox's Handle to a window handle (i.e. HWND).