关于DLL中导出MFC继承类的问题

rabbitweng 2006-04-27 12:04:48
以前写过几个只导出函数的DLL,现在需要导出MFC继承类(具体的说是CView的继承类,用的是AFX_EXT_CLASS宏定义)
试过以后发现用debug版本编出的dll放在主程序中运行时会出问题,但用release版本的dll运行就不会有问题,不知,在CMyView中仅仅实现了一个对鼠标的左键点击的消息处理函数,且这个消息处理函数就是弹出一个MessageBox,各位分析一下是什么原因?
...全文
233 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
rabbitweng 2006-04-28
  • 打赏
  • 举报
回复
懂了,十分感谢jiangsheng(蒋晟.Net[MVP]),结帖
蒋晟 2006-04-28
  • 打赏
  • 举报
回复
no, using multiple versions of MFC (yes, this includes the debug and release version of MFC with the same version number) in different DLL's and passing MFC data between them is not supported. int's, handles, and other non-MFC stuff should work.
rabbitweng 2006-04-27
  • 打赏
  • 举报
回复
回复就有分,散分!
rabbitweng 2006-04-27
  • 打赏
  • 举报
回复
好像找到原因了,貌似Dll是Release版本的,但主程序是debug版本就会出现这个问题,如果两个都是debug版本的,就没有问题了,奇怪的是,为甚会在ASSERT(pViewClass->IsDerivedFrom(RUNTIME_CLASS(CWnd)))这个地方提示错误,奇怪也哉
rabbitweng 2006-04-27
  • 打赏
  • 举报
回复
代码不是偶写的,在MDI程序中重载CChildFrame::OnCreateClient()函数
在CChildFrame定义:
CSplitterWnd m_SplitWnd;

BOOL CChildFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
// TODO: Add your specialized code here and/or call the base class
if (!m_SplitWnd.CreateStatic(this,1,2))
{
TRACE0("Failed to CreateStaticSplitter\n");
return FALSE;
}
if (!m_SplitWnd.CreateView(0,0,
pContext->m_pNewViewClass,CSize(100,100),pContext))
{
TRACE0("Failed to CreateStaticSplitter\n");
return FALSE;
}
// add the second splitter pane - an input view in column 1
//这句出的问题!!
if (!m_SplitWnd.CreateView(0, 1,
RUNTIME_CLASS(CMyView1), CSize(100, 100), pContext))
{
TRACE0("Failed to create second pane\n");
return FALSE;
}
AfxMessageBox(TEXT("444"));

// activate the input view
SetActiveView((CView*)m_SplitWnd.GetPane(0,1));
AfxMessageBox(TEXT("777"));
return TRUE;
//return CMDIChildWnd::OnCreateClient(lpcs, pContext);
}

貌似是这个m_SplitWnd使用的问题,各位看看?
跟踪了一下,到了CSplitterWnd::CreateView()中的这句话:
ASSERT(pViewClass->IsDerivedFrom(RUNTIME_CLASS(CWnd)));
出先错误,难道我的CMyView1不是CWnd的继承类么?

ps:我的CMyView定义:
class AFX_EXT_CLASS CMyView1 : public CView
{
...
}
各位看看?
moloto2004 2006-04-27
  • 打赏
  • 举报
回复
错误信息呢
会思考的草 2006-04-27
  • 打赏
  • 举报
回复
具体症状?有关代码?

15,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 进程/线程/DLL
社区管理员
  • 进程/线程/DLL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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