dialogc.cpp

来自「MFC DLL的编写和调用示例」· C++ 代码 · 共 95 行

CPP
95
字号
// DialogC.cpp : implementation file
//

#include "stdafx.h"
#include "DllC.h"
#include "DialogC.h"

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

#include "../DllA/Export.h"
//#include "../DllA/DialogA.h"
#include "../DllB/Export.h"

/////////////////////////////////////////////////////////////////////////////
// CDialogC dialog


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


void CDialogC::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDialogC)
	DDX_Text(pDX, IDC_EDIT1, m_sText);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDialogC, CDialog)
	//{{AFX_MSG_MAP(CDialogC)
	ON_BN_CLICKED(IDC_BUTTONA, OnButtona)
	ON_BN_CLICKED(IDC_BUTTON_B, OnButtonb)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDialogC message handlers

int CDialogC::DoModal() 
{
	// TODO: Add your specialized code here and/or call the base class
	
	return CDialog::DoModal();
}

BOOL CDialogC::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CDialogC::OnOK() 
{
	UpdateData();
	CDialog::OnOK();
}

void CDialogC::OnButtona() 
{
	// if I tried to do this I get an Assert in the CWnd::AssertValid()
	// Function.
/*	CDialogC	dlg;
	dlg.DoModal();

 */
	// and this method does not crash, but there is a first chance exception
	// error but the program does not halt.
	UpdateData();
	if ( ShowDialogA( m_sText ) == IDOK )
		UpdateData(FALSE);
}

void CDialogC::OnButtonb() 
{
	UpdateData();
	if ( ShowDialogB( m_sText ) == IDOK )
		UpdateData(FALSE);

}

⌨️ 快捷键说明

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