Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Problem occur to access dll dialog box

Problem occur to access dll dialog box

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestionc++learning
14 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S ShilpiP

    I am creating one project in which my client is "MFC dialog based"( "exe" ) and dll is "MFC dll". In MFC dll there is one dialog box that is access by Client application. This is done with the help of exported function but when in this exported function i use domodal than it crashes and an error message occur "Unhandled exception". I dont understand what is the issue ?? :( Is the problem occur because i am using resource of dll?? Thanks in advance.

    Yes U Can ...If U Can ,Dream it , U can do it ...ICAN

    C Offline
    C Offline
    CPallini
    wrote on last edited by
    #3

    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]

    S 1 Reply Last reply
    0
    • C CPallini

      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]

      S Offline
      S Offline
      ShilpiP
      wrote on last edited by
      #4

      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

      M 1 Reply Last reply
      0
      • S SandipG

        Does AFX_MANAGE_STATE[^] help?

        Regards, Sandip.

        S Offline
        S Offline
        ShilpiP
        wrote on last edited by
        #5

        Thanks for your reply Sandip but i am using AFX_MANAGE_STATE.

        Yes U Can ...If U Can ,Dream it , U can do it ...ICAN

        1 Reply Last reply
        0
        • S ShilpiP

          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

          M Offline
          M Offline
          Mark Salsbery
          wrote on last edited by
          #6

          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:

          S 1 Reply Last reply
          0
          • M Mark Salsbery

            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:

            S Offline
            S Offline
            ShilpiP
            wrote on last edited by
            #7

            Didnt get your point??? :confused:

            Yes U Can ...If U Can ,Dream it , U can do it ...ICAN

            M 1 Reply Last reply
            0
            • S ShilpiP

              Didnt get your point??? :confused:

              Yes U Can ...If U Can ,Dream it , U can do it ...ICAN

              M Offline
              M Offline
              Mark Salsbery
              wrote on last edited by
              #8

              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:

              S 1 Reply Last reply
              0
              • M Mark Salsbery

                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:

                S Offline
                S Offline
                ShilpiP
                wrote on last edited by
                #9

                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

                M 1 Reply Last reply
                0
                • S ShilpiP

                  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

                  M Offline
                  M Offline
                  Mark Salsbery
                  wrote on last edited by
                  #10

                  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:

                  S 1 Reply Last reply
                  0
                  • M Mark Salsbery

                    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:

                    S Offline
                    S Offline
                    ShilpiP
                    wrote on last edited by
                    #11

                    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

                    M 1 Reply Last reply
                    0
                    • S ShilpiP

                      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

                      M Offline
                      M Offline
                      Mark Salsbery
                      wrote on last edited by
                      #12

                      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:

                      S 1 Reply Last reply
                      0
                      • M Mark Salsbery

                        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:

                        S Offline
                        S Offline
                        ShilpiP
                        wrote on last edited by
                        #13

                        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

                        M 1 Reply Last reply
                        0
                        • S ShilpiP

                          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

                          M Offline
                          M Offline
                          Mark Salsbery
                          wrote on last edited by
                          #14

                          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:

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups