Solved

Rotation of Metafile or page rotation

Posted on 1997-07-14
8
435 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
Comment Utility
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
Comment Utility
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
Comment Utility
you can use GetEnhMetaFileHeader(..).check the rclBounds or rclFrame. and setting printer
0
 

Author Comment

by:alistair
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:alistair
Comment Utility
Adjusted points to 200
0
 

Expert Comment

by:tflex
Comment Utility
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
Comment Utility
Sorry, the application must run under windows 95
0
 
LVL 10

Accepted Solution

by:
RONSLOW earned 200 total points
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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 demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

772 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

14 Experts available now in Live!

Get 1:1 Help Now