GridDefaultCell.cpp
资源名称:MyStock.rar [点击查看]
上传用户:wenjimin
上传日期:2014-08-12
资源大小:111k
文件大小:2k
源码类别:
金融证券系统
开发平台:
Visual C++
- // GridDefaultCell.cpp: implementation of the CGridDefaultCell class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "GridDefaultCell.h"
- #ifdef _DEBUG
- #undef THIS_FILE
- static char THIS_FILE[]=__FILE__;
- #define new DEBUG_NEW
- #endif
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- IMPLEMENT_DYNCREATE(CGridDefaultCell, CGridCell)
- CGridDefaultCell::CGridDefaultCell()
- {
- m_crFgClr = CLR_DEFAULT;
- m_crBkClr = CLR_DEFAULT;
- m_Size = CSize(30,20);
- m_dwStyle = 0;
- #ifdef _WIN32_WCE
- LOGFONT lf;
- GetObject(GetStockObject(SYSTEM_FONT), sizeof(LOGFONT), &lf);
- SetFont(&lf);
- #else // not CE
- NONCLIENTMETRICS ncm;
- ncm.cbSize = sizeof(NONCLIENTMETRICS);
- VERIFY(SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0));
- SetFont(&(ncm.lfMessageFont));
- #endif
- }
- CGridDefaultCell::~CGridDefaultCell()
- {
- }
- void CGridDefaultCell::SetFont(const LOGFONT* plf)
- {
- ASSERT(plf);
- if (!plf) return;
- m_Font.DeleteObject();//释放内存
- m_Font.CreateFontIndirect(plf);//创建字体
- CGridCell::SetFont(plf);//设置字体
- // Get the font size and hence the default cell size
- CDC* pDC = CDC::FromHandle(::GetDC(NULL));
- if (pDC)
- {
- CFont* pOldFont = pDC->SelectObject(&m_Font);
- m_Size = pDC->GetTextExtent(_T(" XXXXXXXXXXXX "), 16);
- m_Size.cy = (m_Size.cy * 3) / 2;
- pDC->SelectObject(pOldFont);
- ReleaseDC(NULL, pDC->GetSafeHdc());
- }
- else
- {
- m_Size = CSize(40,16);
- }
- }
- LOGFONT* CGridDefaultCell::GetFont() const
- {
- ASSERT(m_plfFont); // This is the default - it CAN'T be NULL!
- return m_plfFont;
- }