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

📄 dlldlg2.cpp

📁 这是书上的代码
💻 CPP
字号:
// DLLDlg2.cpp : implementation file
//

#include "stdafx.h"
#include "TestDLL.h"
#include "DLLDlg2.h"

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

/////////////////////////////////////////////////////////////////////////////
// CDLLDlg2 dialog


CDLLDlg2::CDLLDlg2(CWnd* pParent /*=NULL*/)
	: CDialog(CDLLDlg2::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDLLDlg2)
	m_Str1 = _T("");
	m_Str2 = _T("");
	m_Str3 = _T("");
	//}}AFX_DATA_INIT	
	pUI = NULL;               //初始化指针
}


void CDLLDlg2::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDLLDlg2)
	DDX_Text(pDX, IDC_EDIT1, m_Str1);
	DDX_Text(pDX, IDC_EDIT2, m_Str2);
	DDX_Text(pDX, IDC_EDIT3, m_Str3);
	//}}AFX_DATA_MAP	
}


BEGIN_MESSAGE_MAP(CDLLDlg2, CDialog)
	//{{AFX_MSG_MAP(CDLLDlg2)
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
	ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
	ON_WM_DESTROY()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDLLDlg2 message handlers

BOOL CDLLDlg2::OnInitDialog() 
{
	CDialog::OnInitDialog();
	pUI = new CMyInterface;	  //申请内存空间

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
//--------------通过接口类导出CMyClass类中的FunctionA函数------------------
void CDLLDlg2::OnButton1() 
{	
	m_Str1 = pUI->FunctionA();
	UpdateData(false);
}
//---------------通过接口类导出CMyClass类中的FunctionB函数------------------
void CDLLDlg2::OnButton2() 
{
	//CMyInterface* pUI = new CMyInterface;
	m_Str2 = pUI->FunctionB();
	UpdateData(false);
}
//---------------通过接口类导出CMyClass类中的FunctionB函数------------------
void CDLLDlg2::OnButton3() 
{
	//CMyInterface* pUI = new CMyInterface;
	m_Str3 = pUI->GetString();
	UpdateData(false);
}
//-----------------------------释放动态内存空间---------------------------
void CDLLDlg2::OnDestroy() 
{
	CDialog::OnDestroy();
	
	if(pUI != NULL)
	{
		delete pUI;
		pUI = NULL;
	}	
}
//------------------------The End------------------------------------------

⌨️ 快捷键说明

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