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. Modaless Dialog Box

Modaless Dialog Box

Scheduled Pinned Locked Moved C / C++ / MFC
c++debugginghelpquestion
12 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.
  • V Venkata Rama Subbarao

    While creating dialog box pass the second parameter as NULL. After successful creation of dialog you have to assign the address of the dialog to the m_pMainWnd. int nResponse = dlg.Create(IDD_DIALOG1, NULL); if(nResponse) { m_pMainWnd = &dlg; m_pMainWnd->ShowWindow(SW_SHOW); } else {} I think this will solve your problem.

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

    Thank you, I have to globally define the dlg instance, CMfc_Modaless_vc6Dlg dlg; CWnd* m_pMainWnd = &dlg; while I do this after the application instance creation it is giving the same Debug Assertion Failed problem.I cannot declare the Dlg locally,so what i can do for this? Siddharth

    D 1 Reply Last reply
    0
    • V Venkata Rama Subbarao

      While creating dialog box pass the second parameter as NULL. After successful creation of dialog you have to assign the address of the dialog to the m_pMainWnd. int nResponse = dlg.Create(IDD_DIALOG1, NULL); if(nResponse) { m_pMainWnd = &dlg; m_pMainWnd->ShowWindow(SW_SHOW); } else {} I think this will solve your problem.

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

      tvrsrao wrote:

      After successful creation of dialog you have to assign the address of the dialog to the m_pMainWnd.

      Why would you say this?


      "A good athlete is the result of a good and worthy opponent." - David Crow

      "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

      1 Reply Last reply
      0
      • S siddharthsan

        Hi, I want to display a Modaless Dialog box instead of Modal dialog box in mfc application.So,I called Create function instead of DoModal() inside the InitInstance() but I am getting Debug Assertion Failed error. CDlg dlg; m_pMainWnd = &dlg; int nResponse = dlg.Create(IDD_DIALOG1); if(nResponse) dlg.ShowWindow(SW_SHOW); else MessageBox(NULL,_T("Error"),_T("Error"),MB_OK); I dont know where made the mistake??? Siddharth

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

        siddharthsan wrote:

        ...I am getting Debug Assertion Failed error.

        What line of what file is asserting?


        "A good athlete is the result of a good and worthy opponent." - David Crow

        "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

        S 1 Reply Last reply
        0
        • S siddharthsan

          Thank you, I have to globally define the dlg instance, CMfc_Modaless_vc6Dlg dlg; CWnd* m_pMainWnd = &dlg; while I do this after the application instance creation it is giving the same Debug Assertion Failed problem.I cannot declare the Dlg locally,so what i can do for this? Siddharth

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

          siddharthsan wrote:

          I have to globally define the dlg instance,

          You should not have to do this.


          "A good athlete is the result of a good and worthy opponent." - David Crow

          "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

          1 Reply Last reply
          0
          • D David Crow

            siddharthsan wrote:

            ...I am getting Debug Assertion Failed error.

            What line of what file is asserting?


            "A good athlete is the result of a good and worthy opponent." - David Crow

            "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

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

            Thank you, I am getting Debug Assertion in afxwin1.ini file. I told that we have to create dlg instance globally because,when i create it inside the initinstance then dialog will be disappeared when the it is out of the scope,so I wanted it as a global one.

            D 1 Reply Last reply
            0
            • S siddharthsan

              Thank you, I am getting Debug Assertion in afxwin1.ini file. I told that we have to create dlg instance globally because,when i create it inside the initinstance then dialog will be disappeared when the it is out of the scope,so I wanted it as a global one.

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

              siddharthsan wrote:

              I am getting Debug Assertion in afxwin1.ini file.

              The file is over 1100 lines long. Which one?

              siddharthsan wrote:

              I told that we have to create dlg instance globally because,when i create it inside the initinstance then dialog will be disappeared when the it is out of the scope,so I wanted it as a global one.

              Make it a member of your CWinApp-derived class instead.


              "A good athlete is the result of a good and worthy opponent." - David Crow

              "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

              S 1 Reply Last reply
              0
              • D David Crow

                siddharthsan wrote:

                I am getting Debug Assertion in afxwin1.ini file.

                The file is over 1100 lines long. Which one?

                siddharthsan wrote:

                I told that we have to create dlg instance globally because,when i create it inside the initinstance then dialog will be disappeared when the it is out of the scope,so I wanted it as a global one.

                Make it a member of your CWinApp-derived class instead.


                "A good athlete is the result of a good and worthy opponent." - David Crow

                "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

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

                Error is in Line no 22

                D 1 Reply Last reply
                0
                • S siddharthsan

                  Error is in Line no 22

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

                  So are you directly or indirectly calling AfxGetResourceHandle()?


                  "A good athlete is the result of a good and worthy opponent." - David Crow

                  "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                  S 1 Reply Last reply
                  0
                  • D David Crow

                    So are you directly or indirectly calling AfxGetResourceHandle()?


                    "A good athlete is the result of a good and worthy opponent." - David Crow

                    "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

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

                    No, I am not calling that function directly. But global declaration where I am doing Is it correct? After the App instance creation,I am creating Dlg instance.

                    D 1 Reply Last reply
                    0
                    • S siddharthsan

                      No, I am not calling that function directly. But global declaration where I am doing Is it correct? After the App instance creation,I am creating Dlg instance.

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

                      siddharthsan wrote:

                      No, I am not calling that function directly.

                      I also asked about an indirect call. When the assertion fires, check the call stack.

                      siddharthsan wrote:

                      But global declaration where I am doing Is it correct?

                      Not in my opinion. Until you actually solve the problem, you'll not know for sure if it's correct or not.


                      "A good athlete is the result of a good and worthy opponent." - David Crow

                      "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                      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