?
Solved

Rotation of Metafile or page rotation

Posted on 1997-07-14
8
Medium Priority
?
496 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

Industry Leaders: 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!

Question has a verified solution.

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

If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

777 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