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. modeless dialog error

modeless dialog error

Scheduled Pinned Locked Moved C / C++ / MFC
debugginghelp
10 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.
  • N Offline
    N Offline
    NoName II
    wrote on last edited by
    #1

    tryin to create modeless dialog... m_dlg->Create(CMyDlg::IDD, &m_tabctrl/*CTabCtrl*/);// ASSERT(pWnd->m_hWnd == NULL); // debug error constructor: CMyDlg::CMyDlg(CWnd* pParent /*=NULL*/) //: CDialog(CMyDlg::IDD, pParent) { this->Create(CMyDlg::IDD, pParent); this->ShowWindow(SW_NORMAL); }

    N S H 3 Replies Last reply
    0
    • N NoName II

      tryin to create modeless dialog... m_dlg->Create(CMyDlg::IDD, &m_tabctrl/*CTabCtrl*/);// ASSERT(pWnd->m_hWnd == NULL); // debug error constructor: CMyDlg::CMyDlg(CWnd* pParent /*=NULL*/) //: CDialog(CMyDlg::IDD, pParent) { this->Create(CMyDlg::IDD, pParent); this->ShowWindow(SW_NORMAL); }

      N Offline
      N Offline
      Naveen
      wrote on last edited by
      #2

      NoName II wrote:

      m_dlg->Create(CMyDlg::IDD, &m_tabctrl/*CTabCtrl*/);// ASSERT(pWnd->m_hWnd == NULL); // debug error

      in the constructor it self the window is created. So why u gonne call Create again...? And if u stick to the above code then code like this if( m_dlg->m_hWnd ) { m_dlg->DestroyWindow(); } m_dlg->Create(CMyDlg::IDD, &m_tabctrl/*CTabCtrl*/);// ASSERT(pWnd->m_hWnd == NULL);

      nave

      1 Reply Last reply
      0
      • N NoName II

        tryin to create modeless dialog... m_dlg->Create(CMyDlg::IDD, &m_tabctrl/*CTabCtrl*/);// ASSERT(pWnd->m_hWnd == NULL); // debug error constructor: CMyDlg::CMyDlg(CWnd* pParent /*=NULL*/) //: CDialog(CMyDlg::IDD, pParent) { this->Create(CMyDlg::IDD, pParent); this->ShowWindow(SW_NORMAL); }

        S Offline
        S Offline
        Sarath C
        wrote on last edited by
        #3

        NoName II wrote:

        //: CDialog(CMyDlg::IDD, pParent)

        You should remove this code from your constructor. because it will create a dialog with the IDD (resource ID) you are passing. that is why it failed. see MSDN to know how to create modeless dialog?[^] You can see the following in the documentation... that For a modeless dialog box, you must provide your own public constructor in your dialog class.

        SaRath.
        _"Where I am from, there is no plan B. So, take advantage of today becuase tomorrow is not promised. - 50 Cent"


        My Blog | Understanding State Pattern_

        N D 2 Replies Last reply
        0
        • S Sarath C

          NoName II wrote:

          //: CDialog(CMyDlg::IDD, pParent)

          You should remove this code from your constructor. because it will create a dialog with the IDD (resource ID) you are passing. that is why it failed. see MSDN to know how to create modeless dialog?[^] You can see the following in the documentation... that For a modeless dialog box, you must provide your own public constructor in your dialog class.

          SaRath.
          _"Where I am from, there is no plan B. So, take advantage of today becuase tomorrow is not promised. - 50 Cent"


          My Blog | Understanding State Pattern_

          N Offline
          N Offline
          Naveen
          wrote on last edited by
          #4

          Sarath. wrote:

          because it will create a dialog with the IDD (resource ID) you are passing

          i don't agree see the code inside the constructor. CDialog::CDialog(UINT nIDTemplate, CWnd* pParentWnd) { AFX_ZERO_INIT_OBJECT(CWnd); m_pParentWnd = pParentWnd; m_lpszTemplateName = MAKEINTRESOURCE(nIDTemplate); m_nIDHelp = nIDTemplate; } is only sets the member varaiable.Wont create the dialog

          nave

          S 1 Reply Last reply
          0
          • N Naveen

            Sarath. wrote:

            because it will create a dialog with the IDD (resource ID) you are passing

            i don't agree see the code inside the constructor. CDialog::CDialog(UINT nIDTemplate, CWnd* pParentWnd) { AFX_ZERO_INIT_OBJECT(CWnd); m_pParentWnd = pParentWnd; m_lpszTemplateName = MAKEINTRESOURCE(nIDTemplate); m_nIDHelp = nIDTemplate; } is only sets the member varaiable.Wont create the dialog

            nave

            S Offline
            S Offline
            Sarath C
            wrote on last edited by
            #5

            yes once I had went through the code... for the ease of undestanding I explained it that manner. when creating a modal dialog, the error occurs at module state handling. The function get called twice. first on the ctor and Create function Anyway I dont know more about the same. It would nice informative if you share how a modal dialog asserts on the above scenario -- modified at 6:48 Monday 31st July, 2006

            SaRath.
            _"Where I am from, there is no plan B. So, take advantage of today becuase tomorrow is not promised. - 50 Cent"


            My Blog | Understanding State Pattern_

            N 1 Reply Last reply
            0
            • N NoName II

              tryin to create modeless dialog... m_dlg->Create(CMyDlg::IDD, &m_tabctrl/*CTabCtrl*/);// ASSERT(pWnd->m_hWnd == NULL); // debug error constructor: CMyDlg::CMyDlg(CWnd* pParent /*=NULL*/) //: CDialog(CMyDlg::IDD, pParent) { this->Create(CMyDlg::IDD, pParent); this->ShowWindow(SW_NORMAL); }

              H Offline
              H Offline
              Hamid Taebi
              wrote on last edited by
              #6

              Hope I understood your question CMyDlg *mydialog; mydialog=new CMyDlg(this); CMyDlg::CMyDlg(CWnd* pParent) : CDialog(CMyDlg::IDD, pParent) { Create(pParent); ShowWindow(SW_NORMAL); }

              _**


              **_

              WhiteSky


              1 Reply Last reply
              0
              • S Sarath C

                yes once I had went through the code... for the ease of undestanding I explained it that manner. when creating a modal dialog, the error occurs at module state handling. The function get called twice. first on the ctor and Create function Anyway I dont know more about the same. It would nice informative if you share how a modal dialog asserts on the above scenario -- modified at 6:48 Monday 31st July, 2006

                SaRath.
                _"Where I am from, there is no plan B. So, take advantage of today becuase tomorrow is not promised. - 50 Cent"


                My Blog | Understanding State Pattern_

                N Offline
                N Offline
                Naveen
                wrote on last edited by
                #7

                check the code he posted. in the constructor itself he creates the dialog. I.e CMyDlg dlg; // Dialog is created in this line itself. then he calls dlg.Create(...) the dialog is already created, hence Assertion fails will come and most probably from the function void AFXAPI AfxHookWindowCreate(CWnd* pWnd) { .......... ASSERT(pWnd->m_hWnd == NULL); // only do once ........... }

                nave

                S 1 Reply Last reply
                0
                • N Naveen

                  check the code he posted. in the constructor itself he creates the dialog. I.e CMyDlg dlg; // Dialog is created in this line itself. then he calls dlg.Create(...) the dialog is already created, hence Assertion fails will come and most probably from the function void AFXAPI AfxHookWindowCreate(CWnd* pWnd) { .......... ASSERT(pWnd->m_hWnd == NULL); // only do once ........... }

                  nave

                  S Offline
                  S Offline
                  Sarath C
                  wrote on last edited by
                  #8

                  So it's not part of CDialog. it's part of CWnd right? then how the creation with template name specified occurs?

                  SaRath.
                  _"Where I am from, there is no plan B. So, take advantage of today becuase tomorrow is not promised. - 50 Cent"


                  My Blog | Understanding State Pattern_

                  N 1 Reply Last reply
                  0
                  • S Sarath C

                    So it's not part of CDialog. it's part of CWnd right? then how the creation with template name specified occurs?

                    SaRath.
                    _"Where I am from, there is no plan B. So, take advantage of today becuase tomorrow is not promised. - 50 Cent"


                    My Blog | Understanding State Pattern_

                    N Offline
                    N Offline
                    Naveen
                    wrote on last edited by
                    #9

                    Sarath. wrote:

                    then how the creation with template name specified occurs?

                    i dont understand what u mean. In what ever way create the dialog, atlast ::CreateDialogIndirect(..) funtion is called.

                    nave

                    1 Reply Last reply
                    0
                    • S Sarath C

                      NoName II wrote:

                      //: CDialog(CMyDlg::IDD, pParent)

                      You should remove this code from your constructor. because it will create a dialog with the IDD (resource ID) you are passing. that is why it failed. see MSDN to know how to create modeless dialog?[^] You can see the following in the documentation... that For a modeless dialog box, you must provide your own public constructor in your dialog class.

                      SaRath.
                      _"Where I am from, there is no plan B. So, take advantage of today becuase tomorrow is not promised. - 50 Cent"


                      My Blog | Understanding State Pattern_

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

                      Sarath. wrote:

                      You should remove this code from your constructor.

                      That code is fine. It was the extra Create() call that was the problem. Note the assertion indicated exactly what the problem was (i.e., the window handle was non-NULL).


                      "Money talks. When my money starts to talk, I get a bill to shut it up." - Frank

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

                      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