Solved

Rotation of Metafile or page rotation

Posted on 1997-07-14
8
469 Views
Last Modified: 2013-11-20
I have a metafile which has to be printed as landscape.   I have the choice of rotating the metafile or rotating the page to fit.  

Can anyone help me?

(p.s. The pages preceding and following are to be in portrait mode)
0
Comment
Question by:alistair
8 Comments
 
LVL 4

Expert Comment

by:tflai
ID: 1302562
Interesting, it seems that a lot of people are puzzled
in changing printer default without user having to
manually change it.  I had the same problem before.
I do have a little trick to imitate the effect of
user changing printer setting.  In member function
CYourApp::OnInitInstance(), add the following:

  CPrintDialog pd(TRUE);
  CWinApp::UpdatePrinterSelection(FALSE);
  pd.m_pd.hDevMode = m_hDevMode;
  LPDEVMODE DevMode = pd.GetDevMode();
  DevMode->dmOrientation = DMORIENT_LANDSCAPE;

Here, I make my MSVC application to start out
with landscape orientation regardless of what the
default printer setting is.
0
 

Author Comment

by:alistair
ID: 1302563
I have already tried this solution but find that the printer becomes set to landscape for all pages sent to it.   My problem is to print page 1 in portrait, page 2 in landscape and page 3 in portrait.
0
 
LVL 1

Expert Comment

by:pcs071997
ID: 1302564
you can use GetEnhMetaFileHeader(..).check the rclBounds or rclFrame. and setting printer
0
Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

 

Author Comment

by:alistair
ID: 1302565
The code I use at present is:
///////////////////////
// co-ordinates of rectangle within which metafile is to be printed
left = 4000;
right = 26800;
top1 = -4900;
bottom1 = -17350;

if(!printout)  // To Screen  draws on a landscape dialog box
 rectangle.SetRect(0,0,emh.rclFrame.right,emh.rclFrame.bottom);
else // to printer  
 rectangle.SetRect(left,top1,right,bottom1);

pDC->PlayMetaFile(metahandle, LPCRECT(rectangle));
////////////////////////

It is important that the aspect ratio is retained as the metafiles are drawings of rotating equipment (i.e. circles)
0
 

Author Comment

by:alistair
ID: 1302566
Adjusted points to 200
0
 

Expert Comment

by:tflex
ID: 1302567
If you want to rotate metafile, use 'SetWorldTransform' function.
But it will work only under NT. Here is a piece of my code:


          .......
          double si = sin (angle/180*M_PI);
          double co = cos (angle/180*M_PI);
          XFORM xform;
         
          xform.eM11 = (float) co;
          xform.eM12 = (float) -si;
          xform.eM21 = (float) si;
          xform.eM22 = (float) co;
          xform.eDx = (float)  0.;
          xform.eDy = (float) 0.;
          .......

          SetViewportOrgEx (pdc->GetSafeHdc (), p.x, p.y, &origin);
         
          SetGraphicsMode (pdc->GetSafeHdc (),GM_ADVANCED);
          SetWorldTransform(pdc->GetSafeHdc (), &xform);
         
          if (pdc->PlayMetaFile( ghMetaf, (LPRECT) &rc))
            {
            char    text[128];
           
            wsprintf(text, "Fail in PlayEnhMetaFile! Error %ld\n", GetLastError());
            OutputDebugString(text);
            }
         
          ModifyWorldTransform(pdc->GetSafeHdc (), NULL, MWT_IDENTITY);
          SetGraphicsMode (pdc->GetSafeHdc (), GM_COMPATIBLE);
          SetViewportOrgEx (pdc->GetSafeHdc (), origin.x, origin.y, &p);
      ......
0
 

Author Comment

by:alistair
ID: 1302568
Sorry, the application must run under windows 95
0
 
LVL 10

Accepted Solution

by:
RONSLOW earned 200 total points
ID: 1302569
Use  EnumEnhMetaFile to read your metafile one record at a time.  Apply transforms to the points as approriate for each record, swapping x and y values for all points.  You can either syntheses the action yourself, or try copying to another metafile with the swapped points and then playing that metafile back.

It's not nice - but should work :-)

Roger

0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Different colored text in ComboBox without Subclassing 8 66
Whole sheet autoscrub still needed 19 52
Tab names are off by one 5 54
fix34  challenge 9 148
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 …
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…
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.

820 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