⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 modelessdlg.cpp

📁 接上面那个
💻 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()函数
	//CDialog::OnOK();
}

void CModelessDlg::OnCancel() 
{
	// TODO: Add extra cleanup here
	//删除对话框窗口
	m_parent->m_pDlg=NULL;
	DestroyWindow();
	//无模式对话框中不调用CDialog::OnCancel()函数
	//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();         //GerColor()方法返回选中的颜色值
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -