?
Solved

Rotation of Metafile or page rotation

Posted on 1997-07-14
8
Medium Priority
?
511 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 400 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

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 Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
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.
Suggested Courses

830 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