Thread: When my modeless dialog has been closed it doesn't open again

  1. #1
    Registered User
    Join Date
    Aug 2004
    Posts
    37

    Unhappy When my modeless dialog has been closed it doesn't open again

    Hi !

    The title bar of my modeless dialog ends with the wellknown square red button I hit to close the dialog.
    Unfortunately, the dialog can't be open again after closing it.
    I guess I should modify or add some code to solve the problem.

    Any suggestion ?

    Thanks a lot for your help.

    Best regards.

    Frandy

  2. #2
    Registered User Bajanine's Avatar
    Join Date
    Dec 2001
    Location
    The most peaks over 10,000 feet!
    Posts
    396
    How about posting some code!
    Favorite Quote:

    >For that reason someone invented C++.
    BLASPHEMY! Begone from my C board, you foul lover of objects, before the gods of C cast you into the void as punishment for your weakness! There is no penance for saying such things in my presence. You are henceforth excommunicated. Never return to this house, filthy heretic!



  3. #3
    Registered User
    Join Date
    Aug 2004
    Posts
    37
    Sorry, but I don't see what you mean. Do you need an e-mail ?

  4. #4
    Registered User
    Join Date
    Feb 2002
    Posts
    329
    What he means, is that you have to post some code examples by replying to the messages, not by email.
    Are you using the correct function to terminate the dialog? I think it's called EndDialog() for modal dialogs..

  5. #5
    Registered User
    Join Date
    Aug 2004
    Posts
    37
    OK.

    Dialog's name : First , its ID: IDD_FIRST_DIALOG, its Class : CFirst.

    First.h
    Code:
        BOOL bCreate;
    MainFrame.cpp
    Code:
        CFirst oneDlg;
    
        void CMainFrame::OnCurrents()
        {
              if (oneDlg.bCreate)
                        oneDlg.SetFocus();
              else
                    {
                          if (oneDlg.create( IDD_FIRST_DIALOG, this));
                                    oneDlg.bCreate = TRUE;
                    }
        }
    First.cpp
    Code:
        void CFirst::OnOK()
        {
              UpdateData(TRUE);
              if (DestroyWindow())
                        oneDlg.bCreate = FALSE;
        }
    I repeat that when I press the OK button I have no problem to open the dialog again.

    Anyway thanks again for your help.

    Frandy
    Last edited by Frandy; 11-20-2004 at 08:39 AM.

  6. #6
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    try

    Only modless dialogs can be destroyed. Replace the destroywindow with a call to

    CDialog EndDialog()


    also I would replace the flag oneDlg.bCreate with say

    if ( oneDlg.GetSafeHwnd() )
    "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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Two quick questions about open file dialog boxes
    By PJYelton in forum Windows Programming
    Replies: 5
    Last Post: 04-05-2005, 08:49 AM
  2. edit control in dialog box problems
    By Bajanine in forum Windows Programming
    Replies: 11
    Last Post: 11-11-2002, 06:55 PM
  3. dialog box: open folder : how to?
    By toby1909 in forum C++ Programming
    Replies: 2
    Last Post: 01-16-2002, 05:18 AM
  4. SDI Menu App - MSVC 6
    By Unregistered in forum Windows Programming
    Replies: 7
    Last Post: 10-16-2001, 09:59 PM
  5. Ghost in the CD Drive
    By Natase in forum A Brief History of Cprogramming.com
    Replies: 17
    Last Post: 10-12-2001, 05:38 PM