2013 vc 字体 静态文本框_[VC6 MFC]静态文本框显示带下划线、彩色字体

// 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_)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值