CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 1999
    Posts
    12

    Dialog behaviour



    Hi,


    i want a usally frame window in an mfc application behave like a modal dialog window. I have tried SetModalState(), but it is not working. What can i do?


    Thank you in advance!

    Bjoern



  2. #2
    Join Date
    Apr 1999
    Posts
    10

    Re: Dialog behaviour

    Hi man,
    You know, you can't make child window modal, because the technique of MODAL windows is disabling parent window until modal window appears....
    so according to this do following:

    if ( <condition when should appear modal frame window > )
    {
    //
    CWinApp* pApp = AfxGetApp();
    if (pApp != NULL)
    pApp->EnableModeless(FALSE);

    if (m_hWnd != NULL && ::IsWindowEnabled(m_hWnd))
    ::EnableWindow(m_hWnd, FALSE); // here we go ... KILL PARENT

    CYourFrameWnd * pFrame = new CYourFrameWnd;
    // CYourFrameWnd should be derived from CFrameWnd or CWnd
    pFrame -> Create(NULL,"Opps, I gues so I'm modal ");
    pFrame -> RunModalLoop(MLF_SHOWONIDLE); // This is a very Imp.
    // you should overide virtual BOOL ContinueModal() function to determine when to call EndModalLoop(int nResult) function to enable parent

    }







Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured