I have scoured this FAQ and all documentation that I could find on this subject, tried several suggested changes, and I still cannot disable a selected menu item! I am working on an MFC AppWizard executable program using Visual Studio 6.0. Here is the code that I currently have:
In my App .h file:
afx_msg void SkipQuestion(CCmdUI* pCmdUI);
In my App .cpp file:
ON_UPDATE_COMMAND_UI(ID_SKIPQUESTION_SKIPQUESTION, SkipQuestion)
I have no ON_COMMAND message mapped to this ID.
In my App .cpp file:
void CQuestionApp::SkipQuestion(CCmdUI* pCmdUI)
{
int result;
//the following statement is on one line in my program
result = AfxMessageBox("Do you really want to skip
this question?", MB_YESNO);
if(result == IDYES)
{
pCmdUI->Enable(FALSE);
//Once again, the following is on one line
AfxMessageBox("You cannot skip any more questions
during this round.", MB_OK);
}
else //if(result == IDNO)
{
//One line
AfxMessageBox("The current question will not be
skipped.", MB_OK);
}
}
This code does display the AfxMessageBox following the 'result == IDYES' statement.
What I want is to do is disable the 'Skip Question' menu item if the user selects the 'Yes' button on the AfxMessageBox. I'm sure there is something obvious that I am overlooking here, so please let me know what the problem is! Thank you in advance.
Carrie
In my App .h file:
afx_msg void SkipQuestion(CCmdUI* pCmdUI);
In my App .cpp file:
ON_UPDATE_COMMAND_UI(ID_SKIPQUESTION_SKIPQUESTION, SkipQuestion)
I have no ON_COMMAND message mapped to this ID.
In my App .cpp file:
void CQuestionApp::SkipQuestion(CCmdUI* pCmdUI)
{
int result;
//the following statement is on one line in my program
result = AfxMessageBox("Do you really want to skip
this question?", MB_YESNO);
if(result == IDYES)
{
pCmdUI->Enable(FALSE);
//Once again, the following is on one line
AfxMessageBox("You cannot skip any more questions
during this round.", MB_OK);
}
else //if(result == IDNO)
{
//One line
AfxMessageBox("The current question will not be
skipped.", MB_OK);
}
}
This code does display the AfxMessageBox following the 'result == IDYES' statement.
What I want is to do is disable the 'Skip Question' menu item if the user selects the 'Yes' button on the AfxMessageBox. I'm sure there is something obvious that I am overlooking here, so please let me know what the problem is! Thank you in advance.
Carrie