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. dll problem

dll problem

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++debuggingquestion
8 Posts 5 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.
  • P Offline
    P Offline
    prithaa
    wrote on last edited by
    #1

    Hello, I have an application which works fine . I have now made DLL of the classes which I use.In one of the classes it has a statement which calls the ParentFrame and sets the menu. GetParentFrame()->SetMenu(&FrameMenu); But when I use DLL in my application I get an unhandled error where it seems that the Parent Frame is not found What must be the problem? When I debug he application with DLL the debug cursor does not enter inside the DLL's .cpp file .I want to enter the DLL code .What should be done for that? Pritha

    R S M 3 Replies Last reply
    0
    • P prithaa

      Hello, I have an application which works fine . I have now made DLL of the classes which I use.In one of the classes it has a statement which calls the ParentFrame and sets the menu. GetParentFrame()->SetMenu(&FrameMenu); But when I use DLL in my application I get an unhandled error where it seems that the Parent Frame is not found What must be the problem? When I debug he application with DLL the debug cursor does not enter inside the DLL's .cpp file .I want to enter the DLL code .What should be done for that? Pritha

      R Offline
      R Offline
      ramana g
      wrote on last edited by
      #2

      To debug your DLL, Set DLL project as active and under Project->Settings->Executable for Debug session browse the exe which is using your DLL.

      P 1 Reply Last reply
      0
      • R ramana g

        To debug your DLL, Set DLL project as active and under Project->Settings->Executable for Debug session browse the exe which is using your DLL.

        P Offline
        P Offline
        prithaa
        wrote on last edited by
        #3

        Hello, Thanks But I aam using 2 DLLs and How should I debug starting from my client project? Pritha

        N 1 Reply Last reply
        0
        • P prithaa

          Hello, I have an application which works fine . I have now made DLL of the classes which I use.In one of the classes it has a statement which calls the ParentFrame and sets the menu. GetParentFrame()->SetMenu(&FrameMenu); But when I use DLL in my application I get an unhandled error where it seems that the Parent Frame is not found What must be the problem? When I debug he application with DLL the debug cursor does not enter inside the DLL's .cpp file .I want to enter the DLL code .What should be done for that? Pritha

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

          MFC has issues with multiple threads and possibly also with dlls. In this case GetParentFrame() is the culprit as it makes an internal call to CWnd::FromHandle which looks like this:

          CWnd* PASCAL CWnd::FromHandle(HWND hWnd)
          {
          CHandleMap* pMap = afxMapHWND(TRUE); //create map if not exist
          ASSERT(pMap != NULL);
          CWnd* pWnd = (CWnd*)pMap->FromHandle(hWnd);

          #ifndef _AFX_NO_OCC_SUPPORT
          pWnd->AttachControlSite(pMap);
          #endif

          ASSERT(pWnd == NULL || pWnd->m\_hWnd == hWnd);
          return pWnd;
          

          }

          The afxMapHWND func is probably trying to use global structures that aren't visible from the dll.

          There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition. Blaise Pascal

          P 1 Reply Last reply
          0
          • S sashoalm

            MFC has issues with multiple threads and possibly also with dlls. In this case GetParentFrame() is the culprit as it makes an internal call to CWnd::FromHandle which looks like this:

            CWnd* PASCAL CWnd::FromHandle(HWND hWnd)
            {
            CHandleMap* pMap = afxMapHWND(TRUE); //create map if not exist
            ASSERT(pMap != NULL);
            CWnd* pWnd = (CWnd*)pMap->FromHandle(hWnd);

            #ifndef _AFX_NO_OCC_SUPPORT
            pWnd->AttachControlSite(pMap);
            #endif

            ASSERT(pWnd == NULL || pWnd->m\_hWnd == hWnd);
            return pWnd;
            

            }

            The afxMapHWND func is probably trying to use global structures that aren't visible from the dll.

            There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition. Blaise Pascal

            P Offline
            P Offline
            prithaa
            wrote on last edited by
            #5

            hello, thanks for the reply. So I should not use the GetParentFrame() function.And what care should be taken regarding functions that go into the DLLs Pritha

            S 1 Reply Last reply
            0
            • P prithaa

              Hello, Thanks But I aam using 2 DLLs and How should I debug starting from my client project? Pritha

              N Offline
              N Offline
              Nibu babu thomas
              wrote on last edited by
              #6

              prithaa wrote:

              But I aam using 2 DLLs and How should I debug starting from my client project?

              Set your dll project as the startup/active project. So when you press F5 you get a dialog prompting you to enter an exe name which will be hosting or using this dll, here browse and select the main exe which runs using this dll.

              Nibu babu thomas Microsoft MVP for VC++ Code must be written to be read, not by the compiler, but by another human being. Programming Blog: http://nibuthomas.wordpress.com

              1 Reply Last reply
              0
              • P prithaa

                hello, thanks for the reply. So I should not use the GetParentFrame() function.And what care should be taken regarding functions that go into the DLLs Pritha

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

                Can you avoid using MFC functions from the dll? Here you could use ::GetParent(m_hWnd) instead of GetParentFrame(), but it would give you a HWND, not CFrameWnd. If you can use only raw winapi calls it should be OK.

                There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition. Blaise Pascal

                1 Reply Last reply
                0
                • P prithaa

                  Hello, I have an application which works fine . I have now made DLL of the classes which I use.In one of the classes it has a statement which calls the ParentFrame and sets the menu. GetParentFrame()->SetMenu(&FrameMenu); But when I use DLL in my application I get an unhandled error where it seems that the Parent Frame is not found What must be the problem? When I debug he application with DLL the debug cursor does not enter inside the DLL's .cpp file .I want to enter the DLL code .What should be done for that? Pritha

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

                  If you use MFC with DLLs properly, you won't have a problem. Everything you need to know can be found here: Kinds of DLLs[^] Read carefully :) 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