📄 ex_dlgdlg.cpp
字号:
// Ex_dlgDlg.cpp : implementation file
//
#include "stdafx.h"
#include "Ex_dlg.h"
#include "Ex_dlgDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CEx_dlgDlg dialog
CEx_dlgDlg::CEx_dlgDlg(CWnd* pParent /*=NULL*/)
: CDialog(CEx_dlgDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CEx_dlgDlg)
m_Chk1 = FALSE;
m_Chk2 = FALSE;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
color = RGB(0,0,0);
}
void CEx_dlgDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CEx_dlgDlg)
DDX_Control(pDX, IDC_RADIO1, m_Rdi);
DDX_Check(pDX, IDC_CHECK1, m_Chk1);
DDX_Check(pDX, IDC_CHECK2, m_Chk2);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CEx_dlgDlg, CDialog)
//{{AFX_MSG_MAP(CEx_dlgDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_CHECK1, OnCheck1)
ON_BN_CLICKED(IDC_CHECK2, OnCheck2)
ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_BN_CLICKED(IDC_RADIO3, OnRadio3)
ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CEx_dlgDlg message handlers
BOOL CEx_dlgDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CEx_dlgDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CEx_dlgDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CEx_dlgDlg::OnCheck1()
{
// TODO: Add your control notification handler code here
m_Chk1 = !m_Chk1;
Draw();
}
void CEx_dlgDlg::OnCheck2()
{
// TODO: Add your control notification handler code here
m_Chk2 = !m_Chk2;
Draw();
}
void CEx_dlgDlg::OnRadio1()
{
// TODO: Add your control notification handler code here
color = RGB(255,10,248);
Draw();
}
void CEx_dlgDlg::OnRadio3()
{
// TODO: Add your control notification handler code here
color = RGB(0,0,255);
Draw();
}
void CEx_dlgDlg::OnRadio2()
{
// TODO: Add your control notification handler code here
color = RGB(255,255,0);
Draw();
}
void CEx_dlgDlg::Draw()
{
CClientDC dc(this);
int height;
CFont font;
if(m_Chk2)
{
height = 95;
if(m_Chk1)
font.CreateFont(45, 16, 0, 0, FW_NORMAL, false, false, false,
DEFAULT_CHARSET, OUT_DEVICE_PRECIS,
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
DEFAULT_PITCH, "楷体_GB2312");
else
font.CreateFont(45, 16, 0, 0, FW_NORMAL, false, false, false,
DEFAULT_CHARSET, OUT_DEVICE_PRECIS,
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
DEFAULT_PITCH, "宋体");
}
else
{
height = 75;
if(m_Chk1)
font.CreateFont(20, 10, 0, 0, FW_NORMAL, false, false, false,
DEFAULT_CHARSET, OUT_DEVICE_PRECIS,
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
DEFAULT_PITCH, "隶书");
else
font.CreateFont(20, 10, 0, 0, FW_NORMAL, false, false, false,
DEFAULT_CHARSET, OUT_DEVICE_PRECIS,
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
DEFAULT_PITCH, "宋体");
}
CRect rect(186,28,380,258);
dc.FillSolidRect(&rect, RGB(215,210,206));
dc.SelectObject(&font);
dc.SetTextColor(color);
dc.SetBkMode(TRANSPARENT);
dc.TextOut(200,45,"美人卷竹帘,");
dc.TextOut(200,height,"深坐颦蛾眉。");
dc.TextOut(200,height+height/2,"但见泪痕湿,");
dc.TextOut(200,height+height,"不知心恨谁?");
}
void CEx_dlgDlg::OnButton1()
{
// TODO: Add your control notification handler code here
Invalidate();
}
void CEx_dlgDlg::OnButton2()
{
// TODO: Add your control notification handler code here
OnOK();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -