Thread: Modify a Modal window?

  1. #1
    Registered User
    Join Date
    Mar 2006
    Location
    USA::Colorado
    Posts
    155

    Modify a Modal window?

    Hey,

    Say I created a second dialog in a Visual C++ MFC project. I then give it a class named CSecondDialog.

    The way to make it show up is
    Code:
    CSecondDialog dlg;
    dlg.DoModal();
    However, lets say I've got a textbox on the dialog. How could I fill it with text before the window shows up? I didn't see a CSecondDialog::OnInitDialog() function anywhere.

    I tried doing this
    Code:
    CSecondDialog dlg;
    
    dlg.m_editBox.ShowWindowText ( _T("TEXT") );
    
    dlg.DoModal();
    But when that ran it gave me a debug error =[.

    How can I put text into that exit box (variable: m_editBox)?

    Thanks in advance :-)

    -Guitarist809
    ~guitarist809~

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    Which version of MSVC?

    Is in the properties of the dialogs class (right click on class in the 'Class View') look under 'Overrides' for 'OnInitDialog'.

    In V6 you can add a variable usign the class wizard and set a default value.

    Look also at UpdateData().

    EDIT You can not set the text of a window / control until it has been created. DoModal() calls create on the dialog.
    Last edited by novacain; 07-25-2008 at 05:06 AM.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  3. #3
    Registered User
    Join Date
    Mar 2006
    Location
    USA::Colorado
    Posts
    155
    Quote Originally Posted by novacain View Post
    Which version of MSVC?

    Is in the properties of the dialogs class (right click on class in the 'Class View') look under 'Overrides' for 'OnInitDialog'.

    In V6 you can add a variable usign the class wizard and set a default value.

    Look also at UpdateData().

    EDIT You can not set the text of a window / control until it has been created. DoModal() calls create on the dialog.
    Worked! Thanks
    ~guitarist809~

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C or C++
    By AcerN30 in forum Game Programming
    Replies: 41
    Last Post: 05-30-2008, 06:57 PM
  2. WM_CAPTION causing CreateWindowEx() to fail.
    By Necrofear in forum Windows Programming
    Replies: 8
    Last Post: 04-06-2007, 08:23 AM
  3. 6 measly errors
    By beene in forum Game Programming
    Replies: 11
    Last Post: 11-14-2006, 11:06 AM
  4. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM
  5. OpenGL and Windows
    By sean345 in forum Game Programming
    Replies: 5
    Last Post: 06-24-2002, 10:14 PM