CDialog - Assertion Falied!

This is a discussion on CDialog - Assertion Falied! within the Windows Programming forums, part of the Platform Specific Boards category; I have created a Dialog Application with a main menu bar The menu bar has an option that opens a ...

  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    35

    Angry CDialog - Assertion Falied!

    I have created a Dialog Application with a main menu bar
    The menu bar has an option that opens a new Dialog (new Class)which contians serveral controls, in particular a CIPAdressCtrl.

    I cannot pass data to the CIPAdressCtrl using DDX, as I can only map a variable as a control.

    I want to pass information to the control, then show the dialog.

    This is the code I am using, which is contained in the main Dialog application class.

    Code:
    void CNetworkAccessDlg::OnMenuChangeip() 
    {
    	CIPSettings dlg;
    	dlg.m_ipAddress.SetWindowText("0.0.0.0");
    	dlg.DoModal();
    }

    However, when executing and selecting the menu option to show the dialog I get a Debug Asserion Error.

    Why is this and what do I do to avoid this?

    Thanks

    Magic

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    You cant set the text of a window (or control in this case) before it's created - common sense.

    First of all, I'd use CIPAddressCtrl::SetAddress to set the IP

    Change the contructor of the dialog (or add a function to be called before DoModal) to accept the bytes of the IP, and pass in the info you want to set. Store this info as a class member, then set the control using CIPAddressCtrl::SetAddress in the InitDialog function of the dialog class

  3. #3
    Registered User
    Join Date
    Sep 2004
    Posts
    35
    I have tried adding a function before the doModal call to set the values, but I get the same error message.

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    Quote Originally Posted by magic.mike
    I have tried adding a function before the doModal call to set the values, but I get the same error message.
    You'r not following what I said.

    See the attached class files.
    Attached Files Attached Files

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File I/O Assertion Failure in VS2008
    By clegs in forum C Programming
    Replies: 5
    Last Post: 12-25-2008, 03:47 AM
  2. Assertion Error with DoModal(), activated from a thread
    By hanhao in forum Windows Programming
    Replies: 10
    Last Post: 07-12-2005, 08:57 PM
  3. Assertion Error with DoModal(), activated from a thread
    By hanhao in forum Windows Programming
    Replies: 1
    Last Post: 07-08-2005, 12:39 AM
  4. Assertion error when looking for window handle
    By axr0284 in forum Windows Programming
    Replies: 3
    Last Post: 02-03-2005, 03:11 PM
  5. Assertion Failure
    By drdroid in forum Game Programming
    Replies: 9
    Last Post: 01-04-2003, 06:02 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21