📄 modelessdlg.cpp
字号:
// ModelessDlg.cpp : implementation file
//
#include "stdafx.h"
#include "Exam6_1.h"
#include "ModelessDlg.h"
#include "Exam6_1View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CModelessDlg dialog
CModelessDlg::CModelessDlg(CWnd* pParent /*=NULL*/)
: CDialog(CModelessDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CModelessDlg)
m_x = 0;
m_y = 0;
m_radius = 0;
//}}AFX_DATA_INIT
m_color=RGB(255,255,255);
}
void CModelessDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CModelessDlg)
DDX_Text(pDX, IDC_EDIT1, m_x);
DDX_Text(pDX, IDC_EDIT2, m_y);
DDX_Text(pDX, IDC_EDIT3, m_radius);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CModelessDlg, CDialog)
//{{AFX_MSG_MAP(CModelessDlg)
ON_BN_CLICKED(ID_COLOR, OnColor)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CModelessDlg message handlers
void CModelessDlg::OnOK()
{
// TODO: Add extra validation here
UpdateData(true);// 获取输入值
CClientDC dc(m_parent);//创建指向主窗口视图的CClientDC对象。
CBrush bs;
bs. CreateSolidBrush(m_color);
dc.SelectObject(&bs);
//根据输入的位置和半径画圆
dc.Ellipse(m_x-m_radius,m_y-m_radius,m_x+m_radius,m_y+m_radius);
//CDialog::OnOK();
}
void CModelessDlg::OnCancel()
{
// TODO: Add extra cleanup here
//删除对话框窗口
m_parent->m_pDlg =NULL;
DestroyWindow();
//CDialog::OnCancel();
}
void CModelessDlg::PostNcDestroy()
{
// TODO: Add your specialized code here and/or call the base class
delete this;//删除对话框对象
CDialog::PostNcDestroy();
}
void CModelessDlg::OnColor()
{
// TODO: Add your control notification handler code here
CColorDialog dlg;//定义颜色对话框类的对象
if(dlg.DoModal()==IDOK )//调用颜色对话框
m_color=dlg.GetColor();//GetColor方法返回选中的颜色值
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -