Reputation: 330
I am trying find a way to disable functionality of a Close button where I want. By using a MFC Library, firstly I defined a dialog window and a button considered to close the dialog with the following code:
void CMyDlg::OnBnClickedOk()
{
// TODO: Add your control notification handler code here
CDialog::OnOK();
}
I tried to define a bool flag with two stats of TRUE and FALSE as follows:
void CMyDlg::OnBnClickedOk(bool Flag)
{
If(Flage == TRUE){
// TODO: Add your control notification handler code here
CDialog::OnOK();
}
}
where after a Flage= TRUE call, that button works and when this Flage= FALSE that button be disabled till a certain value of time. Compiler gives a syntax error because of incompatible arguments;
ON_BN_CLICKED(IDOK, &MyDlg::OnBnClickedOk(bool Flag))
For Enabling and Disabling this button,firstly this code included:
GetDlgItem(IDOK)->EnableWindow(TRUE);
It works well but the problem of this method is the drawn bitmap image over the button which disappears
Edit:
In the .rc file there exist these line of codes for the button:
PUSHBUTTON "",IDOK,634,1,25,22,BS_BITMAP | BS_CENTER | BS_VCENTER
IDB_BITMAP1 BITMAP "D:\\Project\\Close.bmp"
Upvotes: 0
Views: 211
Reputation: 10425
You are not allowed to change the signature of the OnBnClickedOK function. The MFC library code that calls it has no provision for adding an extra parameter.
You should also review the difference between = and == in an if statement.
Upvotes: 3