CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1
  1. #1
    Join Date
    Mar 2002
    Location
    Philadelphia
    Posts
    150

    MFC Dialog: How to enable/disable the 'Close' button of your dialog at run-time?

    Q: How to enable/disable the 'Close' button of your dialog at run-time?

    A:

    Code:
    BOOL bEnable = TRUE;     // To enable
    BOOL bEnable = FALSE;    // To disable
    
    UINT menuf = bEnable ? (MF_BYCOMMAND) : (MF_BYCOMMAND | MF_GRAYED | MF_DISABLED);
    
    CMenu* pSM = GetSystemMenu(FALSE);
    if(pSM)
    {
      pSM->EnableMenuItem(SC_CLOSE, menuf);
    }

    Last edited by Andreas Masur; July 24th, 2005 at 04:18 PM.

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