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 Exporting the Modal Dialog from a Regular MFC DLL

Problem Exporting the Modal Dialog from a Regular MFC DLL

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++
9 Posts 3 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 Offline
    S Offline
    SriSubbu
    wrote on last edited by
    #1

    Hi Friends, I've Problem exporting a Modal Dialog from a Regular MFC DLL (Shared Library). But on runtime i'm getting error when i call the DoModal on the DLL side. This is happening for both MFC DLL Depended Host Application as well as the Win32 Host Application:confused:. The Code is like this //on the DLL Side extern "C" void __declspec(dllexport) TestFunction(); void TestFunction() { AFX_MANAGE_STATE(AfxGetStaticModuleState()); CMyDialog dlg; dlg.DoModal(); } //On the Caller Side extern "C" void __declspec(dllimport) TestFunction(); void CMyTestApp::OnAppAbout() { TestFunction(); } Please Help Me...:-D! Kind regards, Subbi.

    T 1 Reply Last reply
    0
    • S SriSubbu

      Hi Friends, I've Problem exporting a Modal Dialog from a Regular MFC DLL (Shared Library). But on runtime i'm getting error when i call the DoModal on the DLL side. This is happening for both MFC DLL Depended Host Application as well as the Win32 Host Application:confused:. The Code is like this //on the DLL Side extern "C" void __declspec(dllexport) TestFunction(); void TestFunction() { AFX_MANAGE_STATE(AfxGetStaticModuleState()); CMyDialog dlg; dlg.DoModal(); } //On the Caller Side extern "C" void __declspec(dllimport) TestFunction(); void CMyTestApp::OnAppAbout() { TestFunction(); } Please Help Me...:-D! Kind regards, Subbi.

      T Offline
      T Offline
      ThatsAlok
      wrote on last edited by
      #2

      Madame,With all due Respect, Basiclly i never head of exporting class from MFC Regular DLL. i think only MFC Extention DLL provide support for exporting class. in my opinion,You create a MFCExtention DLL and then try to export Model Dilg class. don't remeber to precede the DLg className with AFX_EXT_CLASS macro,then only you able to export it ----------------------------- "I Think It will Work" ----------------------------- Alok Gupta visit me at http://www.thisisalok.tk

      S 1 Reply Last reply
      0
      • T ThatsAlok

        Madame,With all due Respect, Basiclly i never head of exporting class from MFC Regular DLL. i think only MFC Extention DLL provide support for exporting class. in my opinion,You create a MFCExtention DLL and then try to export Model Dilg class. don't remeber to precede the DLg className with AFX_EXT_CLASS macro,then only you able to export it ----------------------------- "I Think It will Work" ----------------------------- Alok Gupta visit me at http://www.thisisalok.tk

        S Offline
        S Offline
        SriSubbu
        wrote on last edited by
        #3

        Hi Alok, I think you have understood the problem not clearly. I'm creating a MFC Regular dll not a MFC Extention DLL as first. Further What i'm trying to export is a C++ Function rather than the MFC Dialog Class (the TestFunction in this case). The Problem is whenever i try to call the Modal Dialog the Application breaks. Kind regards, Subramanian Iyer.

        T 1 Reply Last reply
        0
        • S SriSubbu

          Hi Alok, I think you have understood the problem not clearly. I'm creating a MFC Regular dll not a MFC Extention DLL as first. Further What i'm trying to export is a C++ Function rather than the MFC Dialog Class (the TestFunction in this case). The Problem is whenever i try to call the Modal Dialog the Application breaks. Kind regards, Subramanian Iyer.

          T Offline
          T Offline
          ThatsAlok
          wrote on last edited by
          #4

          Soory Again,Madame. previously i think you want to export Dialog in your Main Application,that why i suggest you MFC Extention DLL because i am successfull in exporting Dialog Class using MFC . but i think you want to create Regular dll that can show Dialog.,ok pls tell me is you seeing any error or assertion call,if yes pls send me the error code. ----------------------------- "I Think It will Work" ----------------------------- Alok Gupta visit me at http://www.thisisalok.tk

          S 1 Reply Last reply
          0
          • T ThatsAlok

            Soory Again,Madame. previously i think you want to export Dialog in your Main Application,that why i suggest you MFC Extention DLL because i am successfull in exporting Dialog Class using MFC . but i think you want to create Regular dll that can show Dialog.,ok pls tell me is you seeing any error or assertion call,if yes pls send me the error code. ----------------------------- "I Think It will Work" ----------------------------- Alok Gupta visit me at http://www.thisisalok.tk

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

            Hi Alok, I've my application break at the point when it tries to run the modal loop I've the call Stack goes like that Call stack: CWnd::RunModalLoop(unsigned long 4) line 3478 + 11 bytes CDialog::DoModal() line 536 + 12 bytes InvokeModalDialog(HWND__ * 0x003d0290) line 72 And it seems that line 3478 of Wincore.cpp is calling the AfxGetThread() Which is returning NULL. I thnink it will give you a clear picture... Kind Regards, Subbi.

            B 1 Reply Last reply
            0
            • S SriSubbu

              Hi Alok, I've my application break at the point when it tries to run the modal loop I've the call Stack goes like that Call stack: CWnd::RunModalLoop(unsigned long 4) line 3478 + 11 bytes CDialog::DoModal() line 536 + 12 bytes InvokeModalDialog(HWND__ * 0x003d0290) line 72 And it seems that line 3478 of Wincore.cpp is calling the AfxGetThread() Which is returning NULL. I thnink it will give you a clear picture... Kind Regards, Subbi.

              B Offline
              B Offline
              bikram singh
              wrote on last edited by
              #6

              Hi, I see no reason why your code should fail, under normal circumstances. Infact, I tried your code (dll+exe side), and it compiles and runs perfectly well. Something other than your test code could be causing the problem. It would help if you specified what else you are doing. Bikram Singh

              S 1 Reply Last reply
              0
              • B bikram singh

                Hi, I see no reason why your code should fail, under normal circumstances. Infact, I tried your code (dll+exe side), and it compiles and runs perfectly well. Something other than your test code could be causing the problem. It would help if you specified what else you are doing. Bikram Singh

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

                Hi Bikram, Is it possible for you, can you kindly send me Your Test Application to me, so that i can find out the problem in my code. Even one of my other friend tried the same, even he got the same result. Kind regards, Subbi.

                B 1 Reply Last reply
                0
                • S SriSubbu

                  Hi Bikram, Is it possible for you, can you kindly send me Your Test Application to me, so that i can find out the problem in my code. Even one of my other friend tried the same, even he got the same result. Kind regards, Subbi.

                  B Offline
                  B Offline
                  bikram singh
                  wrote on last edited by
                  #8

                  sure. i'll email it to you. Bikram Singh

                  S 1 Reply Last reply
                  0
                  • B bikram singh

                    sure. i'll email it to you. Bikram Singh

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

                    Bikram, Really Thank You so much for your code. I found the Problem with my code. Actually I've created a Win32 DLL thru' the Application wizard first and then I set the property to use MFC in Shared Dialog. So, i've no CWinApp Object Created, rather i've only the DLLMain function in the Application, which leads to the failure of the Application call by which i get a NULL pointer, of the AfxGetApp call in the RunModalLoop function. Again I thank you for your help. Kind Regards, Subbi.

                    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