Hi All
i am creating an application in VS2005 using MFC. My problem is that i want to call dialog through
Dlls.Here i am attaching zip file.Please check it and tell me why i am not getting it.
thanks
Please, describe what problem do you have and what exactly you were "not getting".
Thanks sir
we have two project here one is MYDll and next is Test Dll. In MyDll i have created a modal dialog
derived with CDialog and take a method DoModal here like this
everything is fine but when i debug this i found m_pMainWnd
and debug point reach Winmain.cpp
in thse lines
// Perform specific initializations
if (!pThread->InitInstance())
{
if (pThread->m_pMainWnd != NULL)
{
TRACE(traceAppMsg, 0, "Warning: Destroying non-NULL m_pMainWnd\n");
pThread->m_pMainWnd->DestroyWindow();
}
nReturnCode = pThread->ExitInstance();
goto InitFailure;
}
So. How i can call this dialog in my second project with Dlls
thanks a lot
My problem is that i want to call dialog through
Dlls. . .
No, that is not your problem.
What you are trying to do is to call dialog in a dll. and that has nothing to do with your problem that can be described as follow:
Originally Posted by anandji05
i am creating an application in VS2005 using MFC.
I am nor able to start application and I am getting:
Unhandled exception at 0x557562f9 (mfc90d.dll) in TestDLL.exe: 0xC0000005: Access violation reading location 0xfefeff66.
As you can see, your problem is in TestDLL.exe, not in MyDLL.dll.
Did you write this application?
If you did, you must have followed ill advice to use CEXTDLLState before calling DoModal in CTestDLLDlg. This small class swithces resource handle from executable to a dll after loading it, therefore creation of a dialog for CTestDLLDlg object fails in FindResource looking for templare, since template does not exist in a dll.
That is only one problem you have stumble on. Once you remove line that instatiate CEXTDLLState before calling DoModal, main dialog will come up.
Dialog you reques from dll will not. That is a place to instantiate CEXTDLLState. You need to switch resource handle, since without switching FindResource in DoModal for CAnand dialog fails; there is no template for it in TestDLL.exe.
Another thing is inserting dialog after return. This code like that will never be executed.
There are only 10 types of people in the world: Those who understand binary and those who do not.
No, that is not your problem.
What you are trying to do is to call dialog in a dll. and that has nothing to do with your problem that can be described as follow:
I am nor able to start application and I am getting:
Unhandled exception at 0x557562f9 (mfc90d.dll) in TestDLL.exe: 0xC0000005: Access violation reading location 0xfefeff66.
As you can see, your problem is in TestDLL.exe, not in MyDLL.dll.
Did you write this application?
If you did, you must have followed ill advice to use CEXTDLLState before calling DoModal in CTestDLLDlg. This small class swithces resource handle from executable to a dll after loading it, therefore creation of a dialog for CTestDLLDlg object fails in FindResource looking for templare, since template does not exist in a dll.
That is only one problem you have stumble on. Once you remove line that instatiate CEXTDLLState before calling DoModal, main dialog will come up.
Dialog you reques from dll will not. That is a place to instantiate CEXTDLLState. You need to switch resource handle, since without switching FindResource in DoModal for CAnand dialog fails; there is no template for it in TestDLL.exe.
Another thing is inserting dialog after return. This code like that will never be executed.
Thanks Sir
Acutally i have not more idea about MFC. Just i am trying to do this
and i have taken help form this link http://www.********.net/Visual_C_MFC...ension-dll.htm can you please send me a sample application.
so that i can do this and can get my mistake.
thanks
In fact, John kindly gave you a complete explanation. If it's too difficult for you to follow it, I would suggest you to simplify your sample a bit, get it working, and only after that go with something more complex. While you fight with your code you can upload current state of your project to the forum to let other people just fix it here and there. This will be much more effective than asking people to provide you a sample for your very specific case.
In fact, John kindly gave you a complete explanation. If it's too difficult for you to follow it, I would suggest you to simplify your sample a bit, get it working, and only after that go with something more complex. While you fight with your code you can upload current state of your project to the forum to let other people just fix it here and there. This will be much more effective than asking people to provide you a sample for your very specific case.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.