I'm using MFC for writing a windows program. I have used these settings when creating the project.
File -> New Project -> MFC applicatioin
and in the MFC application wizard I have choosed:
Application type: Dialog based
Resource language: English (United States)
Use Unicode libraries
Project style: MFC standard
Use of MFC: Use MFC in a static library
Main frame styles: Thick frame, System menu and About box are ticked
Advanced features: ActiveX controls, Common Control Manifest and Support Restart Manager are ticked
Dialog title: P2
Generated classes: Cp2App and Cp2Dlg
I haven't add any codes to the project yet. And I have just been adding the controls in the form:
but when I try to run the project, I get the errors:
1-error LNK2001: unresolved external symbol "public: void __thiscall CP2Dlg::OnBnClickedButton2(void)" (?OnBnClickedButton2@CP2Dlg@@QAEXXZ)
2-error LNK1120: 1 unresolved externals
I know that I can start a new project to avoid the error. But I want to know what causes this problem and solve it?
Note: the first error occurs in the P2Dlg.obj and the second occurs in the P2.exe file.
Edited section: In fact I think this error is because I carelessly double-clicked Button2 and created the eventhandler BnClickedButton2 and deleted it. Now I try to create this eventhandler again but I can't, Because when I right-click button2 and choose add eventhandler in the event handler wizard the option BN_CLICKED
is inactive.
I want to know how to generally fix this kind of problems.Please help me?
Edited section 2: I have added this function in the P2.cpp file using Add EventHandler
but this did not solve the problem:
void CP2App::OnBnClickedButton2()
{
// TODO: Add your control notification handler code here
}
the function CP2Dlg::OnBnClickedButton2
should be added but I can't add it. It is inactive?????