如何设置static变量显示的颜色和字体大小???
2013-11-19 13:29
736 查看
#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_DATA(CDlgLinkDemo)
enum { IDD = IDD_DLGLINK };
CEdit m_Hello2;
CStatic m_Hello1;
//}}AFX_DATA
// 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, UINTnCtlColor);
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_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately beforethe 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_DATA_INIT(CDlgLinkDemo)
// NOTE: the ClassWizard will addmember initialization here
//}}AFX_DATA_INIT
}
void CDlgLinkDemo::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgLinkDemo)
DDX_Control(pDX, IDC_HELLO2, m_Hello2);
DDX_Control(pDX, IDC_HELLO1, m_Hello1);
//}}AFX_DATA_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 notdesired
return hbr;
}
void CDlgLinkDemo::OnUrl()
{
// TODO: Add your control notification handler codehere
HINSTANCE h = ShellExecute( NULL,"open","http://www.jurassic.com.cn", NULL, NULL,SW_SHOWNORMAL );
if ((UINT)h > 32)
{
UrlVisited = TRUE;
Invalidate(); // repaint to show visited color
}
else
{
AfxMessageBox ("Unable todisplay web page.");
}
}
void CDlgLinkDemo::OnEmail()
{
// TODO: Add your control notification handler codehere
HINSTANCE h = ShellExecute( NULL,"open","mailto:yyjmtxa@sina.com", NULL, NULL, SW_SHOWNORMAL);
if ((UINT)h > 32)
{
MailVisited = TRUE;
Invalidate(); // repaint to show visited color
}
else
{
AfxMessageBox ("Unable toopen mail client.");
}
}
BOOL CDlgLinkDemo::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
hHand = ::LoadCursor(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDC_XHAND));
UrlVisited = FALSE;
MailVisited = FALSE;
return TRUE; // return TRUE unless you setthe focus to a control
//EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CDlgLinkDemo::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
// TODO: Add your message handler code here and/or calldefault
// Sets cursor to hand
if ((pWnd->GetDlgCtrlID() == IDC_URL) ||(pWnd->GetDlgCtrlID() == IDC_EMAIL))
{
::SetCursor(hHand);
return TRUE;
}
return CDialog::OnSetCursor(pWnd, nHitTest, message);
}
void CDlgLinkDemo::OnChangeHello2()
{
// TODO: If this is a RICHEDIT control, the controlwill not
// send this notification unless you override theCDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler codehere
CString str;
m_Hello2.GetWindowText( str );
m_Hello1.SetWindowText( str );
}
#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_DATA(CDlgLinkDemo)
enum { IDD = IDD_DLGLINK };
CEdit m_Hello2;
CStatic m_Hello1;
//}}AFX_DATA
// 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, UINTnCtlColor);
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_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately beforethe 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_DATA_INIT(CDlgLinkDemo)
// NOTE: the ClassWizard will addmember initialization here
//}}AFX_DATA_INIT
}
void CDlgLinkDemo::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgLinkDemo)
DDX_Control(pDX, IDC_HELLO2, m_Hello2);
DDX_Control(pDX, IDC_HELLO1, m_Hello1);
//}}AFX_DATA_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 notdesired
return hbr;
}
void CDlgLinkDemo::OnUrl()
{
// TODO: Add your control notification handler codehere
HINSTANCE h = ShellExecute( NULL,"open","http://www.jurassic.com.cn", NULL, NULL,SW_SHOWNORMAL );
if ((UINT)h > 32)
{
UrlVisited = TRUE;
Invalidate(); // repaint to show visited color
}
else
{
AfxMessageBox ("Unable todisplay web page.");
}
}
void CDlgLinkDemo::OnEmail()
{
// TODO: Add your control notification handler codehere
HINSTANCE h = ShellExecute( NULL,"open","mailto:yyjmtxa@sina.com", NULL, NULL, SW_SHOWNORMAL);
if ((UINT)h > 32)
{
MailVisited = TRUE;
Invalidate(); // repaint to show visited color
}
else
{
AfxMessageBox ("Unable toopen mail client.");
}
}
BOOL CDlgLinkDemo::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
hHand = ::LoadCursor(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDC_XHAND));
UrlVisited = FALSE;
MailVisited = FALSE;
return TRUE; // return TRUE unless you setthe focus to a control
//EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CDlgLinkDemo::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
// TODO: Add your message handler code here and/or calldefault
// Sets cursor to hand
if ((pWnd->GetDlgCtrlID() == IDC_URL) ||(pWnd->GetDlgCtrlID() == IDC_EMAIL))
{
::SetCursor(hHand);
return TRUE;
}
return CDialog::OnSetCursor(pWnd, nHitTest, message);
}
void CDlgLinkDemo::OnChangeHello2()
{
// TODO: If this is a RICHEDIT control, the controlwill not
// send this notification unless you override theCDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler codehere
CString str;
m_Hello2.GetWindowText( str );
m_Hello1.SetWindowText( str );
}
相关文章推荐
- eclipse的设置代码字体大小、同变量或者方法被双击后显示颜色、每行显示代码字数
- 设置UIButton的文字显示位置、字体的大小、字体的颜色
- CSS如何设置字体的类型、大小、颜色
- MFC静态文本控件如何设置字体--大小和颜色及背景色
- iOS 开发~设置label上文字显示不同大小、颜色、字体类型
- intelij显示设置(背景颜色、字体大小)
- 设置label上文字显示不同大小、颜色、字体类型
- 设置UIButton的文字显示位置、字体的大小、字体的颜色
- iOS开发-- 设置UIButton的文字显示位置、字体的大小、字体的颜色
- 设置UIButton的文字显示位置、字体的大小、字体的颜色
- 同一个TextView如何显示不同颜色的文字、字体大小、字体样式
- 设置UIButton的文字显示位置、字体的大小、字体的颜色
- 设置一个label显示多种颜色,多种字体大小
- 设置UIButton的文字显示位置、字体的大小、字体的颜色 .
- 设置UIButton的文字显示位置、字体的大小、字体的颜色
- IAR中设置字体大小,设置关键字的颜色,行号显示
- 设置UIButton的文字显示位置、字体的大小、字体的颜色
- 设置UIButton的文字显示位置、字体的大小、字体的颜色
- AndroidStudio设置背景颜色,字体大小,默认显示行号
- MFC Static文字的字体、大小、颜色设置