PRB: Metafile Distorted in OLE Client Application

ID: Q89552

The information in this article applies to:

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

Last Reviewed: February 17, 1995