The first change in the code is an instance variable for the ok button. We treat the button as a window when we write code for the BN_DISABLE message. |
|
| The button disable command is found under the ok button. |
The code checks to see if each of the fields contains a non-trival string.
void ProfDlg::OkBNDisable ()
{
// INSERT>> Your code here.
int ok = _firstName->GetWindowTextLength() > 0 &&
_lastName->GetWindowTextLength() > 0 &&
_initial->GetWindowTextLength() > 0 &&
_phone->GetWindowTextLength() > 0 &&
_office->GetWindowTextLength() > 0;
okButton->EnableWindow(ok);
}
Finally to make sure this function is called whenever one of the fields is updated, for each field we add a handler for the EN_CHANGE message. This message is found under each instance variable. Each of these handlers consists of a call to OkBNDisable. |