// LineStatic.cpp : implementation file
//
#include "stdafx.h"
#include "MFCAppVC6.h"
#include "LineStatic.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/
// CLineStatic
CLineStatic::CLineStatic():m_strText(_T(""))
{
}
CLineStatic::~CLineStatic()
{
}
BEGIN_MESSAGE_MAP(CLineStatic, CStatic)
//{{AFX_MSG_MAP(CLineStatic)
ON_WM_PAINT()
ON_WM_TIMER()
ON_WM_CREATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/
// CLineStatic message handlers
void CLineStatic::PreSubclassWindow()
{
// TODO: Add your specialized code here and/or call the base class
CFont* pFont = GetFont();
LOGFONT logFont;
pFont->GetLogFont(&logFont);
logFont.lfUnderline = TRUE;
m_Font.CreateFontIndirect(&logFont);
CStatic::PreSubclassWindow();
}
void CLineStatic::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
dc.SetTextColor(RGB(255,0,0));
dc.SetBkMode(TRANSPARENT);
CRect rect;
GetClientRect(&rect);
TEXTMETRIC tm;
dc.GetTextMetrics(&tm);
CRect wRect;
wRect = CRect(rect.left,rect.top,rect.right,rect.top + tm.tmHeight);
dc.SelectObject(&m_Font);
dc.DrawText(m_strText,&wRect,DT_LEFT);
// Do not call CStatic::OnPaint() for painting messages
}
#if !defined(AFX_LINESTATIC_H__0478E0F1_65C7_45AD_A37F_568D6BF46BC6__INCLUDED_)
#define AFX_LINESTATIC_H__0478E0F1_65C7_45AD_A37F_568D6BF46BC6__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// LineStatic.h : header file
//
/
// CLineStatic window
class CLineStatic : public CStatic
{
// Construction
public:
CLineStatic();
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CLineStatic)
protected:
virtual void PreSubclassWindow();
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CLineStatic();
void SetText(CString& strText){m_strText = strText;}
// Generated message map functions
protected:
//{{AFX_MSG(CLineStatic)
afx_msg void OnPaint();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
CFont m_Font;
CString m_strText;
};
/
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_LINESTATIC_H__0478E0F1_65C7_45AD_A37F_568D6BF46BC6__INCLUDED_)