Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Printing in VC++ ,     GetDeviceCaps()

Posted on 2000-02-29
4
Medium Priority
?
350 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 225 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses

963 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