MFC规则DLL的创建

yxq123 2006-11-24 06:22:14
手上有一本书,按照书上的要求一步一步做,
就是简单的MFC规则dll应用程序regularDll,当单击"欢迎"按钮时,将弹出"欢迎光临"的对话框.
1.用MFC AppWizard(dll)创建工程,名为regularDll,确定后选择"动态链接库使用共享MFC DLL.
2.在Resource View中的regularDll resources上右击,选择"插入-Dialog-新建",
创建一个对话框,按如下信息添加按钮.
控件 标识符 属性
[欢迎]按钮 IDC_BUTTON1 欢迎
3.按如下信息创建对话框类.
类名:CDllDialog
基类:CDialog
ID值:IDD_DIALOG1
文件:DllDialog.cpp
4.在"欢迎"按钮上双击,创建函数OnHelloButton():
void CDllDialog::OnHelloButton()
{
MessageBox("欢迎光临!");
}
我创建完后运行会出现一个对话框,让用户选择可执行文件名.
不知道怎样解决这个问题???
...全文
445 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
yxq123 2006-11-27
  • 打赏
  • 举报
回复
syy64(太平洋) :
几个函数或者类都要吗?
yxq123 2006-11-27
  • 打赏
  • 举报
回复
我要的是MFC的DLL,有没有什么文字教程????
Stefine 2006-11-24
  • 打赏
  • 举报
回复
DLL是不能单独运行的,又不是EXE,LZ这不晓得吗?

有篇DLL经典入门的文章,看后保准会..

VC++动态链接库(DLL)编程深入浅出
http://www.pconline.com.cn/pcedu/empolder/gj/vc/0509/698632.html
LiChenYue 2006-11-24
  • 打赏
  • 举报
回复
哇!学习一下!

蹭分大侠前来拜访!
syy64 2006-11-24
  • 打赏
  • 举报
回复
// TestDll.cpp : Defines the initialization routines for the DLL.
//

#include "stdafx.h"
#include "TestDll.h"
#include "DlgDBConnect.h"
#include "DlgRecordset.h"
#include "DlgTableDesign.h"
#include "DlgTest.h"


#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
HWND hMainWnd;
//
// Note!
//
// If this DLL is dynamically linked against the MFC
// DLLs, any functions exported from this DLL which
// call into MFC must have the AFX_MANAGE_STATE macro
// added at the very beginning of the function.
//
// For example:
//
// extern "C" BOOL PASCAL EXPORT ExportedFunction()
// {
// AFX_MANAGE_STATE(AfxGetStaticModuleState());
// // normal function body here
// }
//
// It is very important that this macro appear in each
// function, prior to any calls into MFC. This means that
// it must appear as the first statement within the
// function, even before any object variable declarations
// as their constructors may generate calls into the MFC
// DLL.
//
// Please see MFC Technical Notes 33 and 58 for additional
// details.
//

/////////////////////////////////////////////////////////////////////////////
// CTestDllApp

BEGIN_MESSAGE_MAP(CTestDllApp, CWinApp)
//{{AFX_MSG_MAP(CTestDllApp)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTestDllApp construction

CTestDllApp::CTestDllApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}

/////////////////////////////////////////////////////////////////////////////
// The one and only CTestDllApp object

CTestDllApp theApp;
BOOL bIsOpenDB(FALSE);

BOOL CTestDllApp::InitInstance()
{
// TODO: Add your specialized code here and/or call the base class
/* if (!AfxOleInit())
{
AfxMessageBox("ole ³õʼ»¯´íÎó");
return FALSE;
}*/

AfxEnableControlContainer();//
return CWinApp::InitInstance();
}

extern "C" __declspec(dllexport) void showDBConndlg(HWND hWndParent)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CDlgDBConnect dlg(CWnd::FromHandle(hWndParent));
hMainWnd = hWndParent;
dlg.DoModal();
bIsOpenDB=TRUE;
}
extern "C" __declspec(dllexport) void showRecorddlg()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CDlgRecordset dlg(CWnd::FromHandle(hMainWnd));
//hMainWnd=hWndParent;
if(bIsOpenDB)
dlg.DoModal();
else
::MessageBox(NULL,"Êý¾Ý¿âδ´ò¿ª£¬ÇëÏÈÁ¬½ÓÊý¾Ý¿â£¡","Ìáʾ",MB_OK);
}
extern "C" __declspec(dllexport) void closeconn()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
// CDlgTest dlg(CWnd::FromHandle(hMainWnd));
//dlg.DoModal();
if(theApp.m_pConnection)
{
theApp.m_pConnection->Close();
theApp.m_pConnection.Release();
bIsOpenDB=FALSE;
}

}
extern "C" __declspec(dllexport) void showTableDesigndlg()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CDlgTableDesign dlg(CWnd::FromHandle(hMainWnd));
//hMainWnd=hWndParent;
if(bIsOpenDB)
dlg.DoModal();
else
::MessageBox(NULL,"Êý¾Ý¿âδ´ò¿ª£¬ÇëÏÈÁ¬½ÓÊý¾Ý¿â£¡","Ìáʾ",MB_OK);

}

extern "C" __declspec(dllexport) void showTestdlg()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());

CDlgTest dlg(AfxGetApp()->GetMainWnd());
//hMainWnd=hWndParent;
if(bIsOpenDB)
dlg.DoModal();
else
::MessageBox(NULL,"Êý¾Ý¿âδ´ò¿ª£¬ÇëÏÈÁ¬½ÓÊý¾Ý¿â£¡","Ìáʾ",MB_OK);

}

16,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧