FontSize.cpp
资源名称:MiniCA2.rar [点击查看]
上传用户:dengkfang
上传日期:2008-12-30
资源大小:5233k
文件大小:1k
源码类别:
CA认证
开发平台:
Visual C++
- // FontSize.cpp Version 1.0
- //
- // Author: Hans Dietrich
- // hdietrich2@hotmail.com
- //
- // This software is released into the public domain.
- // You are free to use it in any way you like.
- //
- // This software is provided "as is" with no expressed
- // or implied warranty. I accept no liability for any
- // damage or loss of business that this software may cause.
- //
- ///////////////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "FontSize.h"
- ///////////////////////////////////////////////////////////////////////////////
- // GetFontPointSize()
- int GetFontPointSize(int nHeight)
- {
- HDC hdc = ::CreateDC(_T("DISPLAY"), NULL, NULL, NULL);
- ASSERT(hdc);
- int cyPixelsPerInch = ::GetDeviceCaps(hdc, LOGPIXELSY);
- ::DeleteDC(hdc);
- int nPointSize = MulDiv(nHeight, 72, cyPixelsPerInch);
- if (nPointSize < 0)
- nPointSize = -nPointSize;
- return nPointSize;
- }
- ///////////////////////////////////////////////////////////////////////////////
- // GetFontHeight()
- int GetFontHeight(int nPointSize)
- {
- HDC hdc = ::CreateDC(_T("DISPLAY"), NULL, NULL, NULL);
- ASSERT(hdc);
- int cyPixelsPerInch = ::GetDeviceCaps(hdc, LOGPIXELSY);
- ::DeleteDC(hdc);
- int nHeight = -MulDiv(nPointSize, cyPixelsPerInch, 72);
- return nHeight;
- }