[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 265
  • Last Modified:

How to print in a dialog type application?

Hi, I'm now writing a dialog type applciation using VC++6.0. I want to print some images and text but since i'm not using MDI or SDI, I don't know how to do that.. can anyone tell me how to do that?
0
rw8
Asked:
rw8
1 Solution
 
Vinayak KumbarSr Program ManagerCommented:
Hi,

U want to display them on the dialog or U want to print to a paper using printer?

VinExpert
0
 
rw8Author Commented:
Sorry that I didn't make it clear. I want to printer to a paper using printer. I have no problem in drawing the objectws on the screen (dialog) using the OnPaint() function
0
 
ZoppoCommented:
Hi rw8,

I assume it's not the dialog itself you wanna get printed ... am I right?

Then do something like this:

- use a CPrintDialog to let the user select the printer/page size ...
- use CPrintDialog::CreatePrinterDC to get a device context for the selected printer
- with this device context you can use CDC::StartDoc() and CDC::EndDoc() to start and end a printjob; within this printjob you can use CDC::StartPage() and CDC::EndPage() to control output pages. Between each StartPage() and EndPage() you can print to the printer dc using CDC functions you need. It maybe a good idea to test some capabilities of the printer using CDC::GetDeviceCaps() if you need to print i.e. bitmaps using StretchBlt().

hope that helps,

ZOPPO
0
 
maknightCommented:
I'm not sure about printing bitmaps, but printing text can be quite an undertaking if you want to track pages and such accurately. I wrote a class and an ActiveX control to handle that for me b/c it was so "fun".
0
 
rw8Author Commented:
Exellent.. Thanx Zoppo.. I can print something using the printer now..
0

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now