我想写了一个DLL用来做USB摄像头图像捕获,然后在VFP里面调用,
现在我不知道怎么在DLL里面安全的弹出一个窗口
我写的代码:DLLExport void CaptrueToFile()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CCaptureWindow *capWnd = new CCaptureWindow() ;
capWnd->DoModal() ;}
其中CCaptureWindow是预先从标准Dailog上派生出来的。现在我编译好了这个DLL(编译没有问题),做了一个单文档程序来调用这个CaptrueToFile函数,测试程序就出错了。:(请大家帮忙看看,拜托了!
现在我不知道怎么在DLL里面安全的弹出一个窗口
我写的代码:DLLExport void CaptrueToFile()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CCaptureWindow *capWnd = new CCaptureWindow() ;
capWnd->DoModal() ;}
其中CCaptureWindow是预先从标准Dailog上派生出来的。现在我编译好了这个DLL(编译没有问题),做了一个单文档程序来调用这个CaptrueToFile函数,测试程序就出错了。:(请大家帮忙看看,拜托了!
解决方案 »
- 关于自定义控件中的一小段代码,大家帮忙解读下~~
- VC 6.0加载ADO库提示错误, 求助
- 关于对话框中有大量控件进行操作的问题(是个经验问题,希望大家都进来看看,很有益处)
- 还是关于对话框的背景
- connection reset by peer?
- 在我的VC环境编译例程,提示如下错误,主要是'icrsint.h'的问题,问?
- Interlocked 的问题,分虽不多,足表诚意
- 100分求在VC中结构体成员地址的取得方法!
- 如何在vc中设置access数据库的容量,谢谢大虾了!!!
- 如何开发基于多cpu的多线程程序?
- ??多文挡程序中如何让窗口和MDI窗口一启动就最大化?
- 帮忙翻译一下msdn内有关于CArray<>数组的两个模板参数的说明
=====================
DoModal() 可能有点问题,因为它回阻塞在这儿,导致dialog关闭前函数一直不能返回。试一试改成 Create, Show.
BUG: Modal Dialogs in MFC Regular DLL Cause ASSERT in AfxWndProc
ID: Q177101
When AfxGetThread() is called in an MFC regular DLL from a secondary thread that was not created inside the DLL, it returns the CWinApp object for the DLL because a CWinThread object was not created for the thread in the context of the DLL. When a modal dialog box is displayed, CWnd::RunModalLoop() pumps messages by calling AfxGetThread()->PumpMessage(). If two modal dialog boxes both call the CWinApp object's PumpMessage at the same time, synchronization problems cause the wrong message to get processed on the wrong thread. RESOLUTION
One possible work around is to spawn secondary threads, which in turn display the modal dialog boxes. Each new thread created inside the MFC regular DLL will have a new CWinThread object and a separate message pump
模式对话框。
如果,重新编译,或者启动,会突然正常!
这个花了我一个星期时间,访问了无数e文网站才搞好!
所以比较记得!
AFX_MANAGE_STATE(AfxGetStaticModuleState());
在Extend 情况,好像是无法起到交换资源的!
用
AfxSetResourceHandle()吧!
http://www.vckbase.com/code/winsys/dll/vcDlgDLL.zip
------------------〉why not try the modeless dialog?
model dialog isn't work well!