Not destroying the window in VC++

This is a discussion on Not destroying the window in VC++ within the C++ Programming forums, part of the General Programming Boards category; I have got my code running, well enough for now, still a couple of bugs to sort out I am ...

  1. #1
    ResurgentBarbecue UnclePunker's Avatar
    Join Date
    May 2002
    Posts
    128

    Not destroying the window in VC++

    I have got my code running, well enough for now, still a couple of bugs to sort out I am sure but I haven't found them yet, the only annoying thing is when I press the ok button it runs the code fine but it destroys the window afterwards, and I am putting out some important information to it.

    I am creating an MFC application and the vent is BN_CLICKED and the function is called onOK(); I guess that the onOK(); constructor is calling destroy window but could anyone let me know how to stop it doing that.

    Cheers.

    Ben.
    Compiler == Visual C++ 6.0
    "Come Out Fighting."

  2. #2
    Master of the Universe! velius's Avatar
    Join Date
    Sep 2003
    Posts
    219
    Don't call CDialog::OnOK(). If you do it will destroy the window and return DoModal() with IDOK. I believe you could call this->ShowWindow(SW_HIDE) to hide the window. Then you would have to call (pointer_to_dlg)->ShowWindow(SW_SHOW) to display the window again.

    EDIT:
    If you call DoModal() it won't return until the dialog is dismissed correctly.
    Last edited by velius; 09-26-2003 at 08:17 AM.
    While you're breakin' down my back n'
    I been rackin' out my brain
    It don't matter how we make it
    'Cause it always ends the same
    You can push it for more mileage
    But your flaps r' wearin' thin
    And I could sleep on it 'til mornin'
    But this nightmare never ends
    Don't forget to call my lawyers
    With ridiculous demands
    An you can take the pity so far
    But it's more than I can stand
    'Cause this couchtrip's gettin' older
    Tell me how long has it been
    'Cause 5 years is forever
    An you haven't grown up yet
    -- You Could Be Mine - Guns N' Roses

  3. #3
    ResurgentBarbecue UnclePunker's Avatar
    Join Date
    May 2002
    Posts
    128
    Cheers Velius I knew I could count on you, I feel like i should be paying you or something.

    Ben.
    Compiler == Visual C++ 6.0
    "Come Out Fighting."

  4. #4
    ResurgentBarbecue UnclePunker's Avatar
    Join Date
    May 2002
    Posts
    128
    I am stuck I have tried messing with it since you replied but to no avail, I'll show you.
    Code:
    void CBoxDlg::OnOK() 
    { 
        //code
        //code
        //code
        //code
        //code
        //code
    CDialog::OnOK();
    }
    Basically I set the event to on clicked and then couble clicked the button to get the code up, was that wrong, can you tell me what I need to modify?

    Thanks again.

    Ben.
    Compiler == Visual C++ 6.0
    "Come Out Fighting."

  5. #5
    Master of the Universe! velius's Avatar
    Join Date
    Sep 2003
    Posts
    219
    You seem to need to assign variables for DDX code or just simply make member variables and assign them the values in the fields on the dialog's controls before calling CDialog::OnOK();
    While you're breakin' down my back n'
    I been rackin' out my brain
    It don't matter how we make it
    'Cause it always ends the same
    You can push it for more mileage
    But your flaps r' wearin' thin
    And I could sleep on it 'til mornin'
    But this nightmare never ends
    Don't forget to call my lawyers
    With ridiculous demands
    An you can take the pity so far
    But it's more than I can stand
    'Cause this couchtrip's gettin' older
    Tell me how long has it been
    'Cause 5 years is forever
    An you haven't grown up yet
    -- You Could Be Mine - Guns N' Roses

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WM_CAPTION causing CreateWindowEx() to fail.
    By Necrofear in forum Windows Programming
    Replies: 8
    Last Post: 04-06-2007, 08:23 AM
  2. 6 measly errors
    By beene in forum Game Programming
    Replies: 11
    Last Post: 11-14-2006, 10:06 AM
  3. Pong is completed!!!
    By Shamino in forum Game Programming
    Replies: 11
    Last Post: 05-26-2005, 10:50 AM
  4. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM
  5. opengl code not working
    By Unregistered in forum Windows Programming
    Replies: 4
    Last Post: 02-14-2002, 09:01 PM

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