Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7766623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:28:05+00:00 2026-06-01T15:28:05+00:00

I am trying to set an edit box in a nested dialog, but the

  • 0

I am trying to set an edit box in a nested dialog, but the program crashes at runtime. I have made the folowing changes to make connection with the second dialog:

1) made a member variable in the 1st dialog of type the second class (derived from CDialog)

2) in the OnInitDialog() of the 1s class I have:

CRect rcDlg;
m_dDlgData.Create(CDialogData::IDD, this); // Create the second dialog
GetWindowRect(rcDlg);
m_dDlgData.SetWindowPos(NULL, 0, 0, rcDlg.Width(), rcDlg.Height(), SWP_NOZORDER); 

3) created a CEdit variable in the second class, which is public in order to access it from the 1st class.
4) in an event handler of a button (in the 1st dialog), I want to make the given edit box (in the second dialog) read-only, and in another event handler to disable the read-only property. Here is the code, where the error happens:

  void CZad1SemovDlg::OnBedit() 
  {
    m_dDlgData.EGNReadOnly(true);//no problems here

    ///some code///

    if(m_dDlgData.DoModal() == IDOK)// <-- the error happens here
    {
    //more code
    }
  }

  bool CDialogData::EGNReadOnly(bool check)
  {
    m_cEGN.SetReadOnly(check);//here nothing strange happens, the variable is
                              //initialised
    return true;
  }

Strange, the control and the dialog variable are initialised, but when I run the DoModal() method, the program crashes. The error is: Debug Assertion Failed! dlgcore.cpp at line 492
Please, help, i am struggling with this for a while now, searched the net, but could not find the reason. I did not include the whole code as I thought it would be too much, but if you want me to add a function that you think I have missed, tell me and I will add it to the thread. I am using MSVC2008

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T15:28:06+00:00Added an answer on June 1, 2026 at 3:28 pm

    When you call .DoModal(), it tries to create the dialog again which you already created by calling m_dDlgData.Create(). The assertion is telling you that the dialog is already created. Instead of calling DoModal(), call m_dDlgData.ShowWindow(SW_SHOW) and it should work. However, ShowWindow() will display the dialog modeless, but it should give you what you want.

    EDIT: To achieve your goal, in the class for DlgData add a var to indicate edit mode. In the constructor, pass it an initializer:

    class CDlgData
    {
      CDlgData( BOOL bEditMode );
      private BOOL m_bEditMode;
    }
    
    CDlgData::CDlgData(BOOL bEditMode)
    {
      m_bEditMode = bEditMode;
    }
    
    CDlgData::OnInitDialog(...)
    {
      ...
      if( m_bEditMode )
      {
        // Set the controls to whatever
        m_cEGN.SetReadOnly(TRUE);
      }
    }
    

    When you need to display it, just call it:

    CDataDlg dlg(TRUE); // for editing or FALSE for add
    dlg.DoModal();
    

    This stops you from knowing too much about how the dialog implements “read-only”.

    Hope this helps you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to immediately set a row to Edit mode after it is created.
I have a form I'm trying to set up ... Users can have many
I'm trying to set up a box to compile my project on windows. This
I am trying to set up Eclipse so I can profile a Java program
Im trying set the single table inheritance model type in a form. So i
I am trying set up databinding as described in the title. The problem I
Trying to set up caching on our datasets - we're using clr stored procedures
Trying to set it so if a certain condition is met then one of
Trying to set up a dependency in C++ with a parent-child relationship. The parent
Trying to set up a new project, and running into a weird issue. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.