Problem occur to access dll dialog box
-
The debugger is your best friend. Find the offending line and post the relevant code. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]Thanks For your reply Pallini After debugging the dll i knew that the crash occur when i domodal the dialog of dll. Here is my code. ConfigurationCapture is exported function. CConfigDlg is class having base class CDialog.
BOOL CCaptureScreen::ConfigureCapture(HWND hWndParent, CaptureData* lpData)
{
ASSERT(lpData);
if (!lpData)
return(FALSE);
lpData->bCaptureFullScreen = FALSE;
strcpy_s(lpData->szCaptureFilename,strlen(lpData->szCaptureFilename),"");
strcpy_s(lpData->szCapturePath,strlen(lpData->szCapturePath),"");AFX\_MANAGE\_STATE(AfxGetStaticModuleState()); dlg = new CConfigDlg(lpData->bCaptureFullScreen, CA2T(lpData->szCapturePath)); //CConfigDlg dlg(lpData->bCaptureFullScreen, CA2T(lpData->szCapturePath)); //CConfigDlg dlg; BOOL bStat = FALSE; if (dlg->DoModal() == IDOK) {**\--->Crash (UNHANDLED EXCEPTION)** bStat = TRUE; lpData->bCaptureFullScreen = dlg->m\_nFullScreen > 0; strncpy\_s(lpData->szCapturePath, MAX\_PATH, CT2A(dlg->m\_strPath), \_TRUNCATE); \*lpData->szCaptureFilename = '\\0'; } return(bStat);
}
Yes U Can ...If U Can ,Dream it , U can do it ...ICAN
-
Does AFX_MANAGE_STATE[^] help?
Regards, Sandip.
-
Thanks For your reply Pallini After debugging the dll i knew that the crash occur when i domodal the dialog of dll. Here is my code. ConfigurationCapture is exported function. CConfigDlg is class having base class CDialog.
BOOL CCaptureScreen::ConfigureCapture(HWND hWndParent, CaptureData* lpData)
{
ASSERT(lpData);
if (!lpData)
return(FALSE);
lpData->bCaptureFullScreen = FALSE;
strcpy_s(lpData->szCaptureFilename,strlen(lpData->szCaptureFilename),"");
strcpy_s(lpData->szCapturePath,strlen(lpData->szCapturePath),"");AFX\_MANAGE\_STATE(AfxGetStaticModuleState()); dlg = new CConfigDlg(lpData->bCaptureFullScreen, CA2T(lpData->szCapturePath)); //CConfigDlg dlg(lpData->bCaptureFullScreen, CA2T(lpData->szCapturePath)); //CConfigDlg dlg; BOOL bStat = FALSE; if (dlg->DoModal() == IDOK) {**\--->Crash (UNHANDLED EXCEPTION)** bStat = TRUE; lpData->bCaptureFullScreen = dlg->m\_nFullScreen > 0; strncpy\_s(lpData->szCapturePath, MAX\_PATH, CT2A(dlg->m\_strPath), \_TRUNCATE); \*lpData->szCaptureFilename = '\\0'; } return(bStat);
}
Yes U Can ...If U Can ,Dream it , U can do it ...ICAN
Shilpi Boosar wrote:
if (dlg->DoModal() == IDOK) {--->Crash (UNHANDLED EXCEPTION)
Unless dlg is NULL, that's not where the exception occurs. It's in the MFC code somewhere....where? Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
Shilpi Boosar wrote:
if (dlg->DoModal() == IDOK) {--->Crash (UNHANDLED EXCEPTION)
Unless dlg is NULL, that's not where the exception occurs. It's in the MFC code somewhere....where? Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
I re-asked the question - where is the exception occurring? It's not on the line you indicated unless your variable "dlg" is NULL. You can step further in to find a more specific cause of the exception. Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
I re-asked the question - where is the exception occurring? It's not on the line you indicated unless your variable "dlg" is NULL. You can step further in to find a more specific cause of the exception. Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
Yes the crash occur in when i domodal the dlg. suppose i take this example http://www.codeproject.com/KB/DLL/beginnerdll.aspx[^] now i add one more class CDlg in it and add dialog box having id IDD_DLG. dlg.h is like this
#pragma once
#include "afxwin.h"
#include "resource.h"
class CDlg :
public CDialog
{
public:
CDlg(void);
~CDlg(void);enum { IDD = IDD\_DLG };
};
and dlg.cpp is like this
#include "StdAfx.h"
#include "Dlg.h"CDlg::CDlg(void)
{
}CDlg::~CDlg(void)
{
}IN myClass.h i #include the dlg class and create object of m_dlg. in function say hello i add line m_dlg.DoModal(); Please check when i domodal the function than crash occur. It anything wrong here. Same problem is in my project also. :(
Yes U Can ...If U Can ,Dream it , U can do it ...ICAN
-
Yes the crash occur in when i domodal the dlg. suppose i take this example http://www.codeproject.com/KB/DLL/beginnerdll.aspx[^] now i add one more class CDlg in it and add dialog box having id IDD_DLG. dlg.h is like this
#pragma once
#include "afxwin.h"
#include "resource.h"
class CDlg :
public CDialog
{
public:
CDlg(void);
~CDlg(void);enum { IDD = IDD\_DLG };
};
and dlg.cpp is like this
#include "StdAfx.h"
#include "Dlg.h"CDlg::CDlg(void)
{
}CDlg::~CDlg(void)
{
}IN myClass.h i #include the dlg class and create object of m_dlg. in function say hello i add line m_dlg.DoModal(); Please check when i domodal the function than crash occur. It anything wrong here. Same problem is in my project also. :(
Yes U Can ...If U Can ,Dream it , U can do it ...ICAN
It's hard to tell without the exact exception message and the exact code where the error occurs. Can you put a breakpoint on the DoModal() call and step into the MFC code with the F11 key? You should be able to step to where the actual exception occurs. The DoModal() call is too high in the call stack for anything meaningful :) Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
It's hard to tell without the exact exception message and the exact code where the error occurs. Can you put a breakpoint on the DoModal() call and step into the MFC code with the F11 key? You should be able to step to where the actual exception occurs. The DoModal() call is too high in the call stack for anything meaningful :) Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
Ok you mean to say that in standard MFC files. The function where the crash occur is AfxCallWndProcFile name is wincore.cpp // delegate to object's WindowProc lResult = pWnd->WindowProc(nMsg, wParam, lParam); And the crash occur here :( Please now tell me where i am wrong :(
Yes U Can ...If U Can ,Dream it , U can do it ...ICAN
-
Ok you mean to say that in standard MFC files. The function where the crash occur is AfxCallWndProcFile name is wincore.cpp // delegate to object's WindowProc lResult = pWnd->WindowProc(nMsg, wParam, lParam); And the crash occur here :( Please now tell me where i am wrong :(
Yes U Can ...If U Can ,Dream it , U can do it ...ICAN
Did you use a parent window for the dialog created in the EXE? If so, that won't work. You have to use an MFC extension DLL to share MFC objects between an EXE and a DLL. Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
Did you use a parent window for the dialog created in the EXE? If so, that won't work. You have to use an MFC extension DLL to share MFC objects between an EXE and a DLL. Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
I am creating dll using MFC extension dll but linking error occur
mfcs90ud.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in dllmain.obj
1> Creating library C:\Documents and Settings\shilpi.boosar\Desktop\WdCaptureScreen\Debug\WdCaptureScreen.lib and object C:\Documents and Settings\shilpi.boosar\Desktop\WdCaptureScreen\Debug\WdCaptureScreen.exp
1>C:\Documents and Settings\shilpi.boosar\Desktop\WdCaptureScreen\Debug\WdCaptureScreen.dll : fatal error LNK1169: one or more multiply defined symbols found
1>Build log was saved at "file://c:\Documents and Settings\shilpi.boosar\Desktop\WdCaptureScreen\Debug\BuildLog.htm"
1>WdCaptureScreen - 2 error(s), 0 warning(s)Yes U Can ...If U Can ,Dream it , U can do it ...ICAN
-
I am creating dll using MFC extension dll but linking error occur
mfcs90ud.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in dllmain.obj
1> Creating library C:\Documents and Settings\shilpi.boosar\Desktop\WdCaptureScreen\Debug\WdCaptureScreen.lib and object C:\Documents and Settings\shilpi.boosar\Desktop\WdCaptureScreen\Debug\WdCaptureScreen.exp
1>C:\Documents and Settings\shilpi.boosar\Desktop\WdCaptureScreen\Debug\WdCaptureScreen.dll : fatal error LNK1169: one or more multiply defined symbols found
1>Build log was saved at "file://c:\Documents and Settings\shilpi.boosar\Desktop\WdCaptureScreen\Debug\BuildLog.htm"
1>WdCaptureScreen - 2 error(s), 0 warning(s)Yes U Can ...If U Can ,Dream it , U can do it ...ICAN
You'll need to setup your DLL project correctly to use MFC. You don't have to use an extension DLL, but you need to understand the ramifications and choose the type of DLL you need. What you need to know: Kinds of DLLs[^] Mark
Mark Salsbery Microsoft MVP - Visual C++ :java: