SystemCaptionFont.cpp
上传用户:kssdz899
上传日期:2007-01-08
资源大小:79k
文件大小:1k
- #include "StdAfx.h"
- #include "SystemCaptionFont.h"
- //////////////////////////////////////////////////////////////////////////////////////////
- // CSystemCaptionFont provides self-contained access to the default system caption font.
- //
- // operator() returns a CFont pointer to a font created on demand.
- //
- // The destructor deletes the font object attached to CSystemCaptionFont.
- //
- ///////////
- // Destructor deletes any font object associated with CFont member.
- //
- CSystemCaptionFont::~CSystemCaptionFont()
- {
- if (m_Font.m_hObject)
- m_Font.DeleteObject();
- }
- /////////////
- // Returns a lazy-created CFont*
- //
- CFont* CSystemCaptionFont::operator()()
- {
- if (!m_Font.m_hObject)
- CreateFont();
- return &m_Font;
- }
- /////////////////
- // Creates a caption font using the system caption defaults
- //
- void CSystemCaptionFont::CreateFont()
- {
- NONCLIENTMETRICS ncm;
- memset(&ncm, 0, sizeof(ncm));
- ncm.cbSize = sizeof(ncm);
- SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0);
- if (m_Font.m_hObject)
- m_Font.DeleteObject();
-
- m_Font.CreateFontIndirect(&ncm.lfCaptionFont);
- }