如何设置static变量显示的颜色和字体大小
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
如何设置static变量显示的颜色和字体大小???
#if !defined(AFX_DLGLINKDEMO_H__9E74FFA5_8167_429E_8CC2_59CC0D97B764__INCLUDED_) #define AFX_DLGLINKDEMO_H__9E74FFA5_8167_429E_8CC2_59CC0D97B764__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// DlgLinkDemo.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CDlgLinkDemo dialog
class CDlgLinkDemo : public CDialog
{
// Construction
public:
CFont m_font;
BOOL UrlVisited;
BOOL MailVisited;
HCURSOR hHand;
CDlgLinkDemo(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DA TA(CDlgLinkDemo)
enum { IDD = IDD_DLGLINK };
CEdit m_Hello2;
CStatic m_Hello1;
//}}AFX_DA TA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CDlgLinkDemo)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CDlgLinkDemo)
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
afx_msg void OnUrl();
afx_msg void OnEmail();
virtual BOOL OnInitDialog();
afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
afx_msg void OnChangeHello2();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCA TION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_DLGLINKDEMO_H__9E74FFA5_8167_429E_8CC2_59CC0D97B764__INCLUDED_)
// DlgLinkDemo.cpp : implementation file
//
#include "stdafx.h"
#include "xExam.h"
#include "DlgLinkDemo.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDlgLinkDemo dialog
CDlgLinkDemo::CDlgLinkDemo(CWnd* pParent /*=NULL*/)
: CDialog(CDlgLinkDemo::IDD, pParent)
{
//{{AFX_DA TA_INIT(CDlgLinkDemo)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DA TA_INIT
}
void CDlgLinkDemo::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DA TA_MAP(CDlgLinkDemo)
DDX_Control(pDX, IDC_HELLO2, m_Hello2);
DDX_Control(pDX, IDC_HELLO1, m_Hello1);
//}}AFX_DA TA_MAP
}
BEGIN_MESSAGE_MAP(CDlgLinkDemo, CDialog)
//{{AFX_MSG_MAP(CDlgLinkDemo)
ON_WM_CTLCOLOR()
ON_BN_CLICKED(IDC_URL, OnUrl)
ON_BN_CLICKED(IDC_EMAIL, OnEmail)
ON_WM_SETCURSOR()
ON_EN_CHANGE(IDC_HELLO2, OnChangeHello2)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlgLinkDemo message handlers
HBRUSH CDlgLinkDemo::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
if ((pWnd->GetDlgCtrlID() == IDC_URL) || (pWnd->GetDlgCtrlID() == IDC_EMAIL))
{
LOGFONT lf;
GetFont()->GetObject(sizeof(lf), &lf);
lf.lfUnderline = TRUE;
m_font.CreateFontIndirect(&lf);
pDC->SelectObject(&m_font);
if (((pWnd->GetDlgCtrlID() == IDC_URL) && (!UrlVisited)) || ((pWnd->GetDlgCtrlID() == IDC_EMAIL) && (!MailVisited)))
pDC->SetTextColor (RGB(0,0,255)); // blue
else
pDC->SetTextColor (RGB(128,0,128)); // purple
m_font.DeleteObject();
}
// TODO: Return a different brush if the default is not desired
return hbr;