Solved

Printing in VC++ ,     GetDeviceCaps()

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

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 30

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
This video discusses moving either the default database or any database to a new volume.

747 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

8 Experts available now in Live!

Get 1:1 Help Now