modalessdlg.cpp

来自「列表视和树形视应用实例源码 各种通用控件综合运用实例源码」· C++ 代码 · 共 85 行

CPP
85
字号
// ModalessDlg.cpp : implementation file
//

#include "stdafx.h"
#include "Chapter08.h"
#include "ModalessDlg.h"
#include "MainFrm.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CModalessDlg dialog


CModalessDlg::CModalessDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CModalessDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CModalessDlg)
	m_strText = _T("");
	//}}AFX_DATA_INIT
}


void CModalessDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CModalessDlg)
	DDX_Text(pDX, IDC_TEXT, m_strText);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CModalessDlg, CDialog)
	//{{AFX_MSG_MAP(CModalessDlg)
	ON_WM_NCDESTROY()
	ON_BN_CLICKED(IDC_FONT, OnFont)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CModalessDlg message handlers


void CModalessDlg::OnNcDestroy() 
{
	CDialog::OnNcDestroy();
	
	// TODO: Add your message handler code here
	delete this;
}

void CModalessDlg::OnOK() 
{
	// TODO: Add extra validation here
	//获取控件值
	UpdateData(TRUE);
	CMainFrame* pMainFrm=(CMainFrame*)AfxGetMainWnd();
	//将控件值保存到主框架中,以备将来显示用
	pMainFrm->m_strText=m_strText;
	//销毁非模态对话框窗口(必需)
	DestroyWindow();
}
void CModalessDlg::OnCancel() 
{
	// TODO: Add extra cleanup here	
	//直接销毁非模态对话框窗口(必需)
	DestroyWindow();
}

void CModalessDlg::OnFont() 
{
	// TODO: Add your control notification handler code here
	CFontDialog fontDlg;
	if(fontDlg.DoModal()==IDOK)
	{
		CMainFrame* pMainFrm=(CMainFrame*)AfxGetMainWnd();
		//获取选定线条的颜色
		fontDlg.GetCurrentFont(&pMainFrm->logft);
	}
}

⌨️ 快捷键说明

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