Solved

Rotation of Metafile or page rotation

Posted on 1997-07-14
8
460 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to match SAS datasets by multiple key variables and then rename and create new variables? 2 89
sameEnds challenge 3 160
ShiftLeft challenge 21 82
post4 challenge 28 100
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…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

810 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