我写了一个Dialog,想将它包起来给别人使用,如何做?我建立一个 MFC DLL 动态链接库。
首先在动态链接库中加入一个对话框,就这个对话框,我想将它export出去,如何做呢?(不是在一个函数里调用对话框,再将 结果返回!)
(使用者要能够使用如下代码:MyDllDlg dlg;dlg.DoModal();......)
首先在动态链接库中加入一个对话框,就这个对话框,我想将它export出去,如何做呢?(不是在一个函数里调用对话框,再将 结果返回!)
(使用者要能够使用如下代码:MyDllDlg dlg;dlg.DoModal();......)
解决方案 »
- 重画对话框标题栏
- zhoujianhei 来接分(一)!
- 哪里可以下到BCG7.0? 正式版本的哦,不是体验版的。
- 郁闷死了,谁有隐藏进程的程序(可以运行的),麻烦给我发一份,立刻给分,谢谢!
- 招聘vc人材
- 如何才能够知道文件下载了多少呢/(关于制作下载程序)
- ____您说说,vc bc 哪个好?_____
- 请教一个关于消息的问题:
- 写了一个ocx控件,编译时使用Release模式则没问题,但是使用Debug模式,则问题一大堆,好像是找不到什么东西。其中用到了很多C语言的代码
- 离职,散分
- 我在win32程序里使用socket()函数,包含了winsock2.h头文件,为什么会出错呢?
- 两个菜问题(welcone up!)
{
CXXXDlg dlg;
dlg.DoModal();
}
class AFX_EXT_CLASS myDlg:public CDialog
{}
导出myDlg类。
我用这种方法导出过普通类,CDialog派生类不一定能用。
HINSTANCE gThisDLLInstance=NULL;extern "C" int APIENTRY
DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
// Remove this if you use lpReserved
UNREFERENCED_PARAMETER(lpReserved); if (dwReason == DLL_PROCESS_ATTACH)
{
TRACE0("ZH2DZ.DLL Initializing!\n");
// Extension DLL one-time initialization
if (!AfxInitExtensionModule(ZH2DZDLL, hInstance))
return 0; // Insert this DLL into the resource chain
// NOTE: If this Extension DLL is being implicitly linked to by
// an MFC Regular DLL (such as an ActiveX Control)
// instead of an MFC application, then you will want to
// remove this line from DllMain and put it in a separate
// function exported from this Extension DLL. The Regular DLL
// that uses this Extension DLL should then explicitly call that
// function to initialize this Extension DLL. Otherwise,
// the CDynLinkLibrary object will not be attached to the
// Regular DLL's resource chain, and serious problems will
// result. new CDynLinkLibrary(ZH2DZDLL);
gThisDLLInstance=hInstance;///此处保留DLL的句柄
}
else if (dwReason == DLL_PROCESS_DETACH)
{
TRACE0("ZH2DZ.DLL Terminating!\n");
// Terminate the library before destructors are called
AfxTermExtensionModule(ZH2DZDLL);
}
return 1; // ok
}
//该类切换当前的资源句柄
class CLoadDllResource
{
public:
CLoadDllResource()
{
::AfxSetResourceHandle(gThisDLLInstance);
}
~CLoadDllResource()
{
::AfxSetResourceHandle(::AfxGetInstanceHandle());
}
};extern "C" __declspec(dllexport) void XXXdlg()
{
CLoadDllResource r;
CXXXDlg dlg;
dlg.DoModal();
}
AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
then export the dialog class,try it!!