Win32下,不使用MFC,如何实现HIMETRICtoDP功能

来源:百度知道 编辑:UC知道 时间:2024/06/17 21:04:00
如题

象这类问题可以参照MFC的源代码
我没有进一步展开
void CDC::HIMETRICtoDP(LPSIZE lpSize) const
{
ASSERT(AfxIsValidAddress(lpSize, sizeof(SIZE)));

int nMapMode;
if (this != NULL && (nMapMode = GetMapMode()) < MM_ISOTROPIC &&
nMapMode != MM_TEXT)
{
// when using a constrained map mode, map against physical inch
((CDC*)this)->SetMapMode(MM_HIMETRIC);
LPtoDP(lpSize);
((CDC*)this)->SetMapMode(nMapMode);
}
else
{
// map against logical inch for non-constrained mapping modes
int cxPerInch, cyPerInch;
if (this != NULL)
{
ASSERT_VALID(this);
ASSERT(m_hDC != NULL); // no HDC attached or created?
cxPerInch = GetDeviceCaps(LOGPIXELSX);
cyPerInch = GetDeviceCaps(LOGPIXELS