如何在DLL中显示一个对话框呢?

解决方案 »

  1.   

    http://www.csdn.net/Develop/Read_Article.asp?Id=13678
      

  2.   

    用以下语句无法显示呀?      如:  extern "C"
                void LoadDialog()
                {
        CTestDlg   dlg;
                    if (dlg.DoModal == IODK)
                    {
                        //......
                    }
                }
      

  3.   

    1.AfxMessageBox("对话框");//这就是一个对话框
    2。楼上说了
      

  4.   

    DLL中需要对话框模板,方法有两个:1, 用程序创建模板,2, 调用DLL的程序传一个对话框ID给DLL,让DLL可以使用.
      

  5.   

    extern "C" __declspec(dllexport) void LoadDialog()
    {
    CDialog_Connect dlg;

    dlg.DoModal();}
    我以上方法定义了一个显示对话框的函数,可什么不能显示呢(DLL中)?
      

  6.   

    你去VCKbase上看看,有一个完整的例子带源代码,能够完美的解决你的问题,很清楚
      

  7.   

    在调用对话框的函数开始加入
    AFX_MANAGE_STATE(AfxGetStaticModuleState( ));Call this macro to protect an exported function in a DLL. When this macro is invoked, pModuleState is the effective module state for the remainder of the immediate containing scope. Upon leaving the scope, the previous effective module state will be automatically restored.The AFX_MODULE_STATE structure contains global data for the module, that is, the portion of the module state that is pushed or popped. By default, MFC uses the resource handle of the main application to load the resource template. If you have an exported function in a DLL, such as one that launches a dialog box in the DLL, this template is actually stored in the DLL module. You need to switch the module state for the correct handle to be used. You can do this by adding the following code to the beginning of the function:AFX_MANAGE_STATE(AfxGetStaticModuleState( ));This swaps the current module state with the state returned from AfxGetStaticModuleState until the end of the current scope.For more information on module states and MFC, see "Managing the State Data of MFC Modules" inCreating New Documents, Windows, and Views in Visual C++ Programmer’s Guide and Technical Note 58.
      

  8.   

    主应用程序会自动加载资源模板,但由于dll中的资源存储在dll模块中,所以调用dll的资源时必须改正一下,通过AFX_MANAGE_STATE(AfxGetStaticModuleState( ))来指定当前对话框是使用的dll资源中的资源句柄,这样就不会有问题了
      

  9.   

    楼上讲的很正确,给你一个不错的关于Dll的连接
    http://passmatlab.myetang.com/vc/DLL/DLL.HTM