PRB: Metafile Distorted in OLE Client Application

Last reviewed: February 17, 1995
Article ID: Q89552
The information in this article applies to:
  • Microsoft OLE version 1.0

SYMPTOMS

When an OLE client application displays an object on certain display devices, the object appears smaller than it does when displayed in the OLE server application. The object appears distorted in the client application.

CAUSE

A metafile is used as the OLE object presentation format. The metafile is distorted because the DPtoLP() and LPtoDP() functions should use "logical inches" to convert measurement units into the MM_HIMETRIC mapping mode; however, they do not.

RESOLUTION

Rewrite the DPtoLP() and LPtoDP() functions in the OLE client application to perform the proper metafile scaling. These rewritten functions will not scale bitmaps properly. They should be used only with the metafile presentation format.

MORE INFORMATION

The code below rewrites the DPtoLP() and LPtoDP() functions to correctly map logical inches into the MM_HIMETRIC mapping mode:

#define LOGX GetDeviceCaps(hDC, LOGPIXELSX)
#define LOGY GetDeviceCaps(hDC, LOGPIXELSY)
#define HIMETRICINCH 2540

void FAR PASCAL MyHiMetrictoDP(HDC hDC, POINT FAR *pt)
{
   pt.x = MulDiv(pt.x, LOGX, HIMETRICINCH);

   // The minus sign is required because the Y axis
   // points down in the MM_TEXT mapping mode
   pt.y = -MulDiv(pt.y, LOGY, HIMETRICINCH);
}

void FAR PASCAL MyDPtoHiMetric(HDC hDC, POINT FAR *pt)
{
   pt.x = MulDiv(pt.x, HIMETRICINCH, LOGX);

   // The minus sign is required because the Y axis
   // points down in the MM_TEXT mapping mode
   pt.y = -MulDiv(pt.y, HIMETRICINCH, LOGY);
}


Additional reference words: 3.10 1.00
KBCategory: kbole kbprg kbprb
KBSubcategory: LeoneCliMeta


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 17, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.