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.

noname000Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.