Pregunta

I am working with a VC6 MFC project. I tried to add a command button in the existing project. When I double click on the newly added button to fire click event I am getting the below error "cannot add new member".

When i tried this with an existing command buttons in the project, it maps to the corresponding function correctly.

I tried adding the message mapping (manually) for the newly added function. But it doesn't gets called, when the event is fired.

When I tried to add class wizard for the dialog, even though the project contains all the files, VC6 can't able to find the project files and existing classes and hence it throws errors.

I tried the steps mentioned in the below links, but it doesn't work.

How to recover from MFC error "Cannot add new member"?

http://msdn.microsoft.com/en-us/library/aa295101(v=vs.60).aspx

http://social.msdn.microsoft.com/Forums/en-us/vclanguage/thread/1d4cb1f6-f471-46f9-abf3-fa9bb09d1e40

Kindly suggest me solution on how to add a command button to an existing project and also how to link the function call, corresponding to the added command button.

Thank you.

¿Fue útil?

Solución

Found the solution: resource .h contains some default values

#define _APS_NEXT_CONTROL_VALUE 1025

The next control which we place in the form should the _APS_NEXT_CONTROL_VALUE defined in resource.h.

Otros consejos

The version of MFC that ships with Visual C++ 6 (which is ancient by the way) does not support Command Buttons, which were not added until much later. You can still use command buttons if you are careful (i.e. detect if the platform your app is running on supports command buttons) and by adding message handlers for the specific command button messages directly.

Long story short: get a new version of Visual C++.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top