|
// DescriptionFrame.cpp : implementation file
//
#include "stdafx.h"
#include "DescriptionFrame.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDescriptionFrame
CDescriptionFrame::CDescriptionFrame()
{
m_strText.Empty();
NONCLIENTMETRICS ncm = {0};
ncm.cbSize = sizeof(ncm);
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0);
// Font do write description string
LOGFONT lfBold = ncm.lfMessageFont;
lfBold.lfWeight = FW_BOLD;
m_fnFont.CreateFontIndirect(&lfBold);
}
CDescriptionFrame::~CDescriptionFrame()
{
m_fnFont.DeleteObject();
}
BEGIN_MESSAGE_MAP(CDescriptionFrame, CStatic)
//{{AFX_MSG_MAP(CDescriptionFrame)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDescriptionFrame message handlers
void CDescriptionFrame::OnPaint()
{
CPaintDC dc(this); // device context for painting
CRect rc;
GetClientRect(rc);
//
// Preparing for pretty drawing
//
COLORREF crTextOld = dc.SetTextColor(RGB(0, 0, 0));
COLORREF crBackOld = dc.SetBkColor(COLORREF(::GetSysColor(COLOR_BTNFACE)));
CFont *pfnOld = dc.SelectObject(&m_fnFont);
//
// Drawing
//
dc.DrawFrameControl(rc, DFC_BUTTON, DFCS_BUTTONPUSH | DFCS_PUSHED);
rc.DeflateRect(5, 5);
dc.DrawText(m_strText, rc, DT_LEFT | DT_WORDBREAK);
//
// Restoring
//
dc.SetTextColor(crTextOld);
dc.SetBkColor(crBackOld);
dc.SelectObject(pfnOld);
}
void CDescriptionFrame::UpdateText(const CString &rString)
{
m_strText = rString;
Invalidate();
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here