Click to See Complete Forum and Search --> : Re: Disable Main Frame Close and resize


Christian Busch
March 31st, 1999, 01:05 AM
To prevent resize, move etc:

BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)

{

// Create a window without min/max buttons or sizable border

cs.style = WS_POPUPWINDOW;

return CFrameWnd::PreCreateWindow(cs);

}

to handle closing:

Add an handler for WM_CLOSE (ClassWizard -> CMainFrame -> Close).

There you can handle a close request.

At last:

Preventing shutdown:

BOOL CMainFrame::OnQueryEndSession()

{

if (!CFrameWnd::OnQueryEndSession())

return FALSE;

if (AfxMessageBox(GetResText(IDS_END_ABFRAGE),MB_OKCANCEL) == IDCANCEL)

return FALSE;

return TRUE;

}

But if you wait too long in the messagebox the shutdown will continue because windows assumes your applikcation is

dead. So maybe use a non-modal box with a timer for a time limit.