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 showing MFC dialog from extern DLL

Problem showing MFC dialog from extern DLL

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++
12 Posts 5 Posters 1 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 StjepanVukadin

    Hy there.:) I have problem showing a dialog from dinamicaly loaded .dll. I use MFC both for my application and for it's plug-ins (dll). And when i try to display dialog from my dll using function ShowDialogFromDll i don't get anithing. Pls help. Thanks in advance.

    A Offline
    A Offline
    AnTri
    wrote on last edited by
    #2

    Do you have a RichTextCtrl on your Dialog. If so, you must call AfxInitRichEdit() or AfxInitRichEdit2() before calling your function.

    S 1 Reply Last reply
    0
    • S StjepanVukadin

      Hy there.:) I have problem showing a dialog from dinamicaly loaded .dll. I use MFC both for my application and for it's plug-ins (dll). And when i try to display dialog from my dll using function ShowDialogFromDll i don't get anithing. Pls help. Thanks in advance.

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #3

      If the dialog resource is actually in the DLL, have you included the following in your ShowDialogFromDll() function:

      AFX_MANAGE_STATE(AfxGetStaticModuleState());


      "Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.

      "Judge not by the eye but by the heart." - Native American Proverb

      S 1 Reply Last reply
      0
      • D David Crow

        If the dialog resource is actually in the DLL, have you included the following in your ShowDialogFromDll() function:

        AFX_MANAGE_STATE(AfxGetStaticModuleState());


        "Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.

        "Judge not by the eye but by the heart." - Native American Proverb

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

        But when i put AFX_MANAGE_STATE(AfxGetStaticModuleState()) before my dialog showing code it crashes my program. I get an assetion in WINCORE.CPP line: 884. It crashes because my DLL app does not have a main window. Damn :D

        D 1 Reply Last reply
        0
        • A AnTri

          Do you have a RichTextCtrl on your Dialog. If so, you must call AfxInitRichEdit() or AfxInitRichEdit2() before calling your function.

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

          I'm not using rich text. It's blank dialog.

          1 Reply Last reply
          0
          • S StjepanVukadin

            Hy there.:) I have problem showing a dialog from dinamicaly loaded .dll. I use MFC both for my application and for it's plug-ins (dll). And when i try to display dialog from my dll using function ShowDialogFromDll i don't get anithing. Pls help. Thanks in advance.

            R Offline
            R Offline
            Renjith Ramachandran
            wrote on last edited by
            #6

            call MFC macro AFX_MANAGE_STATE, before calling any of the MFC functions

            May all beings be happy and free...

            1 Reply Last reply
            0
            • S StjepanVukadin

              Hy there.:) I have problem showing a dialog from dinamicaly loaded .dll. I use MFC both for my application and for it's plug-ins (dll). And when i try to display dialog from my dll using function ShowDialogFromDll i don't get anithing. Pls help. Thanks in advance.

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

              I tried now creating a modeles dialog and it went fine but i need modal dialog :( Darn :) Any ideas now?

              P 1 Reply Last reply
              0
              • S StjepanVukadin

                But when i put AFX_MANAGE_STATE(AfxGetStaticModuleState()) before my dialog showing code it crashes my program. I get an assetion in WINCORE.CPP line: 884. It crashes because my DLL app does not have a main window. Damn :D

                D Offline
                D Offline
                David Crow
                wrote on last edited by
                #8

                Show your ShowDialogFromDll() code.


                "Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.

                "Judge not by the eye but by the heart." - Native American Proverb

                1 Reply Last reply
                0
                • S StjepanVukadin

                  I tried now creating a modeles dialog and it went fine but i need modal dialog :( Darn :) Any ideas now?

                  P Offline
                  P Offline
                  prasad_som
                  wrote on last edited by
                  #9

                  Show the code, how you are invoking the dialog?

                  Prasad Notifier using ATL

                  S 1 Reply Last reply
                  0
                  • P prasad_som

                    Show the code, how you are invoking the dialog?

                    Prasad Notifier using ATL

                    S Offline
                    S Offline
                    StjepanVukadin
                    wrote on last edited by
                    #10

                    First i am using function PlugInProc for exporting PlugIn class. In that class i have a function called ImportFile: BOOL CPlugIn::ImportFile(CString sFile) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); CImpOpts dlg; dlg.DoModal(); return TRUE; } And when i call this class function from my main application it crashes. And i know why but i don't know how to fix it. Windows figures that CImpOpts is a part of my main application and tries to load dialog resource (IDD_IMPOPTS) from my main app, but resource is found in my dll. Once again, i am exporting whole class from my dll using this function: CMy3dsImpApp theApp; CPlugIn plg; // CPlugIn is of type MPlugIn extern "C" MPlugIn* PASCAL EXPORT PlugInProc() { AFX_MANAGE_STATE(AfxGetStaticModuleState()); return &plg; } I can show modeles dialogs, but i need modal dialog (because i need to stop execution of main application code 'till i do specific code in my plugin).

                    P 1 Reply Last reply
                    0
                    • S StjepanVukadin

                      First i am using function PlugInProc for exporting PlugIn class. In that class i have a function called ImportFile: BOOL CPlugIn::ImportFile(CString sFile) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); CImpOpts dlg; dlg.DoModal(); return TRUE; } And when i call this class function from my main application it crashes. And i know why but i don't know how to fix it. Windows figures that CImpOpts is a part of my main application and tries to load dialog resource (IDD_IMPOPTS) from my main app, but resource is found in my dll. Once again, i am exporting whole class from my dll using this function: CMy3dsImpApp theApp; CPlugIn plg; // CPlugIn is of type MPlugIn extern "C" MPlugIn* PASCAL EXPORT PlugInProc() { AFX_MANAGE_STATE(AfxGetStaticModuleState()); return &plg; } I can show modeles dialogs, but i need modal dialog (because i need to stop execution of main application code 'till i do specific code in my plugin).

                      P Offline
                      P Offline
                      prasad_som
                      wrote on last edited by
                      #11

                      I'm not sure, but problem may be resource handle. Can you try this, Use this code before invoking ImportFile function.

                      HINSTANCE hResInstCurrApp=AfxGetResourceHandle();
                      HINSTANCE m_hInstResDLL = LoadLibrary("dllHavingDialog.dll"));
                      if (hInstResDLL )
                      {
                      //set resource handle to this dll
                      AfxSetResourceHandle( hInstResDLL );
                      //call you function
                      AfxSetResourceHandle( hResInstCurrApp);

                      //call freelibaray

                      }
                      else
                      {
                      //failed to load dll.
                      }

                      Prasad Notifier using ATL

                      S 1 Reply Last reply
                      0
                      • P prasad_som

                        I'm not sure, but problem may be resource handle. Can you try this, Use this code before invoking ImportFile function.

                        HINSTANCE hResInstCurrApp=AfxGetResourceHandle();
                        HINSTANCE m_hInstResDLL = LoadLibrary("dllHavingDialog.dll"));
                        if (hInstResDLL )
                        {
                        //set resource handle to this dll
                        AfxSetResourceHandle( hInstResDLL );
                        //call you function
                        AfxSetResourceHandle( hResInstCurrApp);

                        //call freelibaray

                        }
                        else
                        {
                        //failed to load dll.
                        }

                        Prasad Notifier using ATL

                        S Offline
                        S Offline
                        StjepanVukadin
                        wrote on last edited by
                        #12

                        It doesn't work but thx.

                        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