Solved

Printing in VC++ ,     GetDeviceCaps()

Posted on 2000-02-29
4
326 Views
Last Modified: 2013-11-20
How and where do i set the boundary for printing the data ?

the GetDeviceCaps() is returning me different values for different printer devices, how can i use that function to set the boundary?

how and where do i set the logical coordinates for setting the print boundary??
0
Comment
Question by:Naveen_kr
  • 2
  • 2
4 Comments
 
LVL 31

Expert Comment

by:Zoppo
ID: 2568297
Hi Naveen_kr,

You cannot change these values, because different printers just have different physical capabilities. The boundary you mean depends on paper size and printer resolution selected by the user.

You should try to use CDC::SetMapMode(), CDC::SetWindowExt() and CDC::SetViewportExt() to scale your dc to fit into the printable area of the printer selected.

hope that helps,

ZOPPO
0
 

Author Comment

by:Naveen_kr
ID: 2568351
Dear Zoppo,

First thing is our application is a client server application, we don't have any documents as document view architecture is not used, we take the data from the backend, put them to the variables on the view and then print , the print is independant of the display we have on the screen, the problem that i am having is that the preview and the printout are coming fine but the printouts( also on preview ) are different in different printers.

This is because the m_rectdraw is being set using getdevicecaps() and so is setting differently for different printers.

In which function do i have to set the mode and to what mode do i have to set, i don't think setwindowext()is necessary and so is setviewport()or do we need them to set the preview size or print page size ?.

-Naveen
0
 
LVL 31

Accepted Solution

by:
Zoppo earned 75 total points
ID: 2568407
Hi Naveen,

You can use map modes MM_TWIPS, MM_HIENGLISH, MM_HIMETRIC, MM_LOENGLISH and MM_LOMETRIC to make sure i.e. printed lines have the same length and printed texts the same height independant of the used printer.

You can even use map modes MM_ISOTROPIC and MM_ANISOTROPIC with SetWindowExtEx and SetViewportExtEx to map your logical coordinates to the printer's device coordinated. Let's say your printing code uses logical coordinates within a bounding rectangle of logical size 0,0-3000,5000. Now you can simply say SetMapMode( MM_ANISOTROPIC ); SetWindowExt( 3000, 5000 ); SetViewportExt( XRes, YRes );, where XRes and YRes are the extents of the printable area in printer's device units. With this the output will be scaled to fit in the printable area independant of the printer's paper size and resolution, but i.e. the printed lines length and the texts height will differ from printer to printer.

So, now you'll have to say in which way you want the output to be independant: do you need the scale to be printer independant (i.e. a line has to be 5mm long on any printer) or the relation between the paper size and the output?

ZOPPO
0
 

Author Comment

by:Naveen_kr
ID: 2571434
Dear Zoppo,

I want it the second way , i.e the relation between the paper size and the output...

How do i go about??.

I will set the mode to MM_ANISOTROPIC with SetWindowExeEx and setViewportExtEx as you have mentioned in the second paragraph, i will do these things in OnPrepareDC, is that ok?, is this all that i have to do?.
one more thing, does SetViewportExtEx function set the m_rectDraw structure to the specified values ?..

pls answer to these questions of mine ..

-Naveen
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Get filename and folder into excel 7 68
if loop in java 3 129
Execute multiple curl cmds with sleep and send output to file 10 89
Line meaning 9 82
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now