Non modal Dialogs

This is a discussion on Non modal Dialogs within the Windows Programming forums, part of the Platform Specific Boards category; Ok this is somthing I can't seem to figure out. I work with VC++ . SDI and MFC. When I ...

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    591

    Non modal Dialogs

    Ok this is somthing I can't seem to figure out.
    I work with VC++ . SDI and MFC.
    When I want to use a Dialog I create a Dialog resource, associate it with a Class and assign it a member variable like this
    Code:
    CCustomDlg m_dCustomDlg
    When I want to open this dialog I just have to write
    Code:
       if(m_dCustomDlg.DoModal == IDOK)
       {
               Do fun things 
       }
    This will open a modal dialog. My question is what do I do if I want to open this dialog box as a non modal dialog? Something that I can have open but don't "block" my main window from input.

    ~Barjor

  2. #2
    Registered User
    Join Date
    Aug 2001
    Posts
    223

    non modal dialog

    then you must call its create function. Just make sure to declare within the scope that you want.... because if your declare within a function it will destroy at the end of that function...



    CCustomDlg m_dCustomDlg;


    m_dCustomDlg.Create(.....)
    m_dCustomDlg.ShowWindow( SW_SHOW ); //hide as necessary


    ///
    m_dCustomDlg.Destroy() when no longer needeed
    zMan

  3. #3
    NLIBarjor
    Guest
    Wow that easy, I feal stupid now. I been wasting to much time trying to find something like DoNonModal() heheheh
    Thanks zMan
    ~Barjor

  4. #4
    Unregistered
    Guest
    From MSDN
    Code:
    CMyDialog* pDialog;
    
    void CMyWnd::OnSomeAction()
    {
       //pDialog initialized to NULL in the constructor of CMyWnd class
       pDialog = new CMyDialog();
       //Check if new succeeded and we got a valid pointer to a dialog object
       if(pDialog != NULL)
       {
          BOOL ret = pDialog->Create(IDD_MYDIALOG,this);
          if(!ret)   //Create failed.
             AfxMessageBox("Error creating Dialog");
          pDialog->ShowWindow(SW_SHOW);
       }
       else
          AfxMessageBox("Error Creating Dialog Object");
    }
    ~Barjor

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Passing parameters to modal dialogs
    By Halloko in forum Windows Programming
    Replies: 2
    Last Post: 10-11-2005, 07:15 AM
  2. Modeless Dialogs in Multiple threads
    By MrGrieves in forum Windows Programming
    Replies: 0
    Last Post: 06-22-2004, 01:33 PM
  3. Modal Dialogs?
    By jinx in forum Windows Programming
    Replies: 1
    Last Post: 11-29-2001, 01:49 PM
  4. Getting Modal text in and SDI app.
    By jinx in forum Windows Programming
    Replies: 3
    Last Post: 11-23-2001, 11:01 AM
  5. modal average
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 11-01-2001, 12:18 PM

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