Solved

Printing in VC++ ,     GetDeviceCaps()

Posted on 2000-02-29
4
335 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need to retreive data from .TFS file exported by DVR 8 198
tripleUp challenge 7 79
Execute multiple curl cmds with sleep and send output to file 10 97
Path of Workbook 3 77
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
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.

773 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