[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 263
  • Last Modified:

dl problems

(*) I have a MFC DLL with XApp as the only App object
(*) This dll contains a class Cy which is exported as a whole using __declspec(dllexport) .
(*) Another class Cz is also defined whose base class is CDialog.
(*) Cz's dialog box has some buttons and an Active X control.
(*) Cy contains a function Function1 that instanciates Cz and calls the DoModal funtcion of it.

Now I have a exe file which statically links the dll file, instantiates the Cy class and calls Function1.

The trouble starts here. The DoModal calls return -1 (Error), whenever the dialog box contains Active X controls. When the Active X Controls are removed, the DoModal works fine. I have used the "AfxEnableControlContainer()" in the InitInstance() function of XApp.

0
noname000
Asked:
noname000
  • 2
1 Solution
 
PIGCommented:
Check the system whether your ActiveX is registred corectly and whether your DLL seing him. For register ActiveX use regsvr32.exe. C function DllRegister... work not properly.
0
 
noname000Author Commented:
Yeah The active X is registered correctly and I can use it from a normal EXE application. Just that when The dll tries to call this in a dialog box this fails
0
 
Malek103197Commented:
I managed to do what you are trying to do by using the following:

CSampleApp theApp;

extern "C" __declspec(dllexport) int Calc(int x)
{
 //must include this to allow MFC to be exported,
 AFX_MANAGE_STATE(AfxGetStaticModuleState());
 CMyDialog dlg;
 dlg.DoModal();
 return 2*x;
}

 //add this function through class wizard
BOOL CSampleApp::InitInstance()
{
 //include these to enable the use of an ActiveX control in DLL
 AfxOleInitModule();
 AfxEnableControlContainer();
 return CWinApp::InitInstance();
}

Good luck!
0
 
PIGCommented:
And if you link dinamicly have someproblem?
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now