我想写了一个DLL用来做USB摄像头图像捕获,然后在VFP里面调用,
现在我不知道怎么在DLL里面安全的弹出一个窗口
我写的代码:DLLExport void CaptrueToFile()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());

CCaptureWindow *capWnd = new CCaptureWindow() ;
capWnd->DoModal() ;}
其中CCaptureWindow是预先从标准Dailog上派生出来的。现在我编译好了这个DLL(编译没有问题),做了一个单文档程序来调用这个CaptrueToFile函数,测试程序就出错了。:(请大家帮忙看看,拜托了!

解决方案 »

  1.   

    察看一下对话框的窗口类型 是 popup 还是 child.
      

  2.   

    你的DLL是什么类型的?Regular/Extend
      

  3.   

    whoo(谁):我试试了,不关是popup 还是 child,都会出错,如果忽略错误,倒是可以出来,不过窗口大小、按钮上的汉字都乱了。Cline(营营):Regular/Extend 是什么?我不知道怎么查看我用的什么类型?请大家继续帮忙,先谢谢了!!
      

  4.   

    那估计是资源ID的问题了。照理说,AFX_MANAGE_STATE(AfxGetStaticModuleState()) 能够维护这个问题的。
    =====================
    DoModal()  可能有点问题,因为它回阻塞在这儿,导致dialog关闭前函数一直不能返回。试一试改成 Create, Show.
      

  5.   

    CCaptureWindow *capWnd = new CCaptureWindow() ;不要 括号试试看 CCaptureWindow *capWnd = new CCaptureWindow;
      

  6.   

    是不是Extension dll???把出的是什么错??
      

  7.   

    //if model dialog ,maybe error
    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
      

  8.   

    http://expert.csdn.net/Expert/topic/2113/2113335.xml?temp=.6343805
      

  9.   

    DoModal()  可能有点问题,因为它回阻塞在这儿,导致dialog关闭前函数一直不能返回。试一试改成 Create, Show.  我也同意这个观点,就是模式对话框的问题,应将其改为非
    模式对话框。
      

  10.   

    Dialog资源交换的问题,这个问题最奇怪的地方是,可能会突然发生,
    如果,重新编译,或者启动,会突然正常!
    这个花了我一个星期时间,访问了无数e文网站才搞好!
    所以比较记得!
    AFX_MANAGE_STATE(AfxGetStaticModuleState());
    在Extend 情况,好像是无法起到交换资源的!

    AfxSetResourceHandle()吧!
      

  11.   

    http://expert.csdn.net/Expert/topic/2113/2113335.xml?temp=.9610559
      

  12.   

    给你一个例子
    http://www.vckbase.com/code/winsys/dll/vcDlgDLL.zip
      

  13.   

    //if model dialog ,maybe error
    ------------------〉why not try the modeless dialog?
    model dialog isn't work well!