Modify a Modal window?

This is a discussion on Modify a Modal window? within the Windows Programming forums, part of the Platform Specific Boards category; Hey, Say I created a second dialog in a Visual C++ MFC project. I then give it a class named ...

  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,859
    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 06: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, 07:57 PM
  2. WM_CAPTION causing CreateWindowEx() to fail.
    By Necrofear in forum Windows Programming
    Replies: 8
    Last Post: 04-06-2007, 09: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, 01:34 PM
  5. OpenGL and Windows
    By sean345 in forum Game Programming
    Replies: 5
    Last Post: 06-24-2002, 11:14 PM

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