CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Guest

    Disabling 'CLOSE' button

    I've a SDI application which I wonder how can I disable the 'CLOSE' button located at the top right hand corner of the application during run-time.
    Thanks for any suggestion.


  2. #2
    Join Date
    Apr 1999
    Location
    Bruton, Somerset, England
    Posts
    47

    Re: Disabling 'CLOSE' button

    Add a return statement to OnClose() function of CMainFrame (or whatever) so that the default CMainFrame::OnClose() does not get called.

    If you don't have an OnClose() function use class wizard to add a handler for WM_CLOSE.


  3. #3
    Join Date
    Apr 1999
    Location
    Bruton, Somerset, England
    Posts
    47

    Re: Disabling 'CLOSE' button

    Alternatively, you may be able to modify the
    CREATESTRUCT structure in PreCreateWindow().


  4. #4
    Join Date
    Apr 1999
    Posts
    16

    Re: Disabling 'CLOSE' button

    Place this code at any place (but window must be already created)
    It will disable ur close button.

    CMenu *pSysMenu = (CMenu*)AfxGetMainWnd()->GetSystemMenu(FALSE);
    pSysMenu->DeleteMenu(SC_CLOSE, MF_BYCOMMAND);
    AfxGetMainWnd()->PostMessage(WM_NCACTIVATE);



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