I haven't had to modify them much for VS2010 so far. Right now, (I think) I have created the dialog box, and the menu as a class and a resource, respectively. However, when I call
I get an error 'DoModal' : is not a member of 'NewDialog'
I suppose somehow I need to link the menu to the dialog box?
I believe I've added the references, included the libraries and essentially followed the instructions. Apparently I'm not very clear on how to make resources interact with new classes. Can anyone point me in the right direction?
Thanks very much!
Step 7:
Now click on Menu --> View --> Class Wizard or press Ctrl + W. You will be presented with a dialog asking you, if you want to create a new class. Say Yes. The wizard will create a new dialog class and related files( Newdialog.h & newdialog.cpp) for you.
I get an error 'DoModal' : is not a member of 'NewDialog'
I suppose somehow I need to link the menu to the dialog box?
Your error is a general C++ error, and really has nothing to do with dialog boxes. Instead of thinking of dialog boxes and MFC, look at what the error is telling you in terms of the C++ language.
When you call a member function, that function must be available within the public interface of the class. There is no such function as "DoModal" that is in the NewDialog class that is publicly accessible, and it isn't publicly accessible from any parent class of NewDialog. In other words, either DoModal() doesn't exist within the NewDialog (or parent classes), or the function does exist and it is not publicly accessible (it is protected or private).
You get the same error if you did this:
Code:
class bar
{
public:
void b();
};
class foo : public bar
{
public:
void x();
};
int main()
{
foo f;
f.y(); // there is no function "y" defined in class foo or in its parent class "bar".
}
I believe I've added the references, included the libraries and essentially followed the instructions. Apparently I'm not very clear on how to make resources interact with new classes. Can anyone point me in the right direction?
Thanks very much!
Your problem has absolutely nothing to do with references, libraries, or resources. The problem is not understanding the rules of the C++ language in terms of how to define member functions, deriving from classes that contain those functions, making the functions publicly available, or a combination of all of these concepts.
Regards,
Paul McKenzie
Last edited by Paul McKenzie; March 11th, 2013 at 07:39 PM.
When you call a member function, that function must be available within the public interface of the class. There is no such function as "DoModal" that is in the NewDialog class that is publicly accessible, and it isn't publicly accessible from any parent class of NewDialog. In other words, either DoModal() doesn't exist within the NewDialog (or parent classes), or the function does exist and it is not publicly accessible (it is protected or private).
I believe the compiler error will reflect that you're making an illegal call to a protected or private member if that's the case, rather than telling you the function doesn't exist.
Arjay and GCDEF:
The instructions for adding the new class "NewDialog" didn't quite match with my version. I did create a new class (Project -> Class Wizard -> Add Class). I left the base class "CWnd" - should it perhaps be CFrameWnd? Would this make the class/function available? (I guess #include isn't sufficient.)
Paul and GCDEF:
Thank you for that extremely detailed look at structure - it was very helpful. As I said, I have very little background in programming and this is all very new to me so I appreciate the information. I thought DoModal was a system command that would open/create the dialog box I created - so you're saying I haven't made the dialog box available in the public interface? How might I define that?
I hope my questions don't sound too stupid, it's a bit overwhelming to know where to start building a foundation!
Thank you all again for your help!
...and, in each situation of this kind (and every time it's necessary), have a look in the documentation: http://msdn.microsoft.com/en-us/libr...(v=vs.80).aspx.
Or, hit F12 key for jumping to whatever class definition to see if it has or not whatever method.
Looking in the documentation isn't so hard and prevents a lot of headaches.
Bookmarks