Link to home
Start Free TrialLog in
Avatar of leigh2
leigh2

asked on

MDI Child Frame with no system exit button

I have a MDI application in which I have multiple views.  However upon loading the application a default view is displayed and I don't want the user to be able to close this view.  Is it possible to remove the "x" exit button from the frame?
ASKER CERTIFIED SOLUTION
Avatar of captainkirk
captainkirk

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of basant
basant

Yes change the Child View
Style to WM_NOCLOSE.

May be by overloading PreCreateWindow

BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
    // Create a window without min/max buttons or sizable border
    cs.style = WS_OVERLAPPED | WS_SYSMENU | WS_BORDER | WM_NOCLOSE;

    // Size the window to 1/3 screen size and center it
    cs.cy = ::GetSystemMetrics(SM_CYSCREEN) / 3;
    cs.cx = ::GetSystemMetrics(SM_CXSCREEN) / 3;
    cs.y = ((cs.cy * 3) - cs.cy) / 2;
    cs.x = ((cs.cx * 3) - cs.cx) / 2;

    // Call the base-class version
    return CFrameWnd::PreCreateWindow(cs);
}


Avatar of leigh2

ASKER

This method was a good idea but unfortunately did not work.  Thanks for your help anyways.  You cannot create a child with ~WM_CLOSE.

                    Regards, Leigh
Avatar of leigh2

ASKER

Thanks this looks like it will work fine.  Do you know how I could tell what window not to close?
thanks,leigh2....