紧急!!!vc制作的动态库为什么对话框不能被其他程序调用呢?
紧急!!!vc制作的动态库为什么对话框不能被其他程序调用呢?下面是动态库代码,可以编译通过。但是在被调用时候出现下列提示错误:
debug assertion failed!
program:
myvc.exe
file:
afxwin1.ini
line 22
下面是动态库代码,可以编译通过。
1。对话框类定义
class CCapture : public CDialog
{
// Construction
public:
CCapture(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CCapture)
enum { IDD = IDD_DIALOG1 };
// NOTE: the ClassWizard will add data members here
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CCapture)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CCapture)
// NOTE: the ClassWizard will add member functions here
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
2。在导出的函数中使用对话框类
#include "stdafx.h"
#include "picforusb1.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CPicforusb1App construction
CPicforusb1App::CPicforusb1App()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CPicforusb1App object
CPicforusb1App theApp;
_declspec(dllexport) int CardCreate(void)
{
int nResponse = theApp.dlg.DoModal();//在导出的函数中使用对话框类
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
}