DannyGan9
asked on
How to unable window Close Button at MFC???
CMenu* systemMenu = GetSystemMenu(false);
if(systemMenu)
{
systemMenu->EnableMenuItem (SC_CLOSE, MF_BYCOMMAND | MF_DISABLED);
}
Above coding, i found that cannot function at OnInitialUpdate().
Is it got any problem abouth this shot?
I would like to unable window close button when my program load...
TQ!
if(systemMenu)
{
systemMenu->EnableMenuItem
}
Above coding, i found that cannot function at OnInitialUpdate().
Is it got any problem abouth this shot?
I would like to unable window close button when my program load...
TQ!
EnableMenuItem is CView class. View doesn't have system menu, GetSystemMenu returns NULL. You need to move this code to the frame class, and use another message handler, like WM_CREATE.
ASKER
So what is the right way to enable the window close button????
TQ!
TQ!
Hi,
The codes are for dialog based view? Which class are you using?
MDI or SDI or Dialog?
The codes are for dialog based view? Which class are you using?
MDI or SDI or Dialog?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
What is "systemMenu"?
Just add the following line to OnInitDialog() and the close button will be disabled.
BOOL CDlg9Dlg::OnInitDialog()
{
...
...
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(ID
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SE
pSysMenu->AppendMenu(MF_ST
}
// Add here
pSysMenu->EnableMenuItem(S
}
...
...
}
Good Luck!