Click to See Complete Forum and Search --> : Dialog behaviour


Bjoern Engelke
March 8th, 1999, 03:52 AM
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

Lavrent
November 3rd, 1999, 03:00 AM
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

}