Archived

This topic is now archived and is closed to further replies.

Simple MSVC6 Question (I think)

This topic is 5775 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

OK, I know this is probably a simple, noddy question, but it has been bugging me for a few hours now, and it might be easier to ask rather then struggle any longer. I have an MDI application (MSVC6) that I am trying to create an editor with. Effectively I want a central database of rules and objects that can be worked on, but some of the items can be accessed by different documents so I assumed that the Application object is where to place them. It is easy enough to create my objects at the application level, but when I try to access them using the syntax below I get an error. theApp->myObject->myfunction I assume that I either need to pass a pointer to the doc of the application, but that seems strange to me as I am sure I could be ending up with a circular reference, or I am doing something basically wrong in trying to access the variables from here. Anyone got any helpful suggestions as to how I can achieve what I am trying to do ? Regards, Bp.

Share this post


Link to post
Share on other sites
Get into the habit of providing the errors you come across when asking a question of this nature. You''ll get a better response. "I get an error" isn''t very helpful.

Anyway, I assume you are using MFC. If you are, theApp is a global instance of your CWinApp derived class... so you will access members within that like thus:

theApp.myObject

I cant really help you anymore without some actual error descriptions / codes.

Share this post


Link to post
Share on other sites
I cant really help you anymore without some actual error descriptions / codes.

OK, Fair comment

Thanks for the reply so far, I posted this at work, and the project in question is at home so next time I can compile it I will post error messages. I just wondered if I was doing something fundamental that I could get an immedaite answer on !

Watch this space

Bp.

Share this post


Link to post
Share on other sites
OK, Told you I''d be back. I get 3 errors, all pointing to the line in my view class that is attempting to access the app class.

Error 2065: ''theApp'' : undeclared Identifier

The other 2 errors are due to the object I am accessing from theApp.

The correct header files are #included, which is why I am stumped and needed to post.

Thanks for any further help.

Bp.

Share this post


Link to post
Share on other sites
1) Make sure the file you''re getting the error in is really including the correct header (usually named after your project). I''m going to assume your project is named "MyApp"

2) Look in myapp.h and make sure you have:
extern CMyApp theApp; // obviously a different class name

3) Look in myapp.cpp and make sure you have:
CMyApp theApp; // if this isn''t there, the app won''t run

If that still doesn''t work, and you''re willing, zip up the project directory and send it to me (siebharinn@yahoo.com) and I''ll take a look at it.

Take care,
Bill

Share this post


Link to post
Share on other sites
Ok, thanks for the continued Help.

I currently have a cruddy Laptop with VC on it, with no Floppy Drive so I cannot copy the code off and zip it or paste it
(The machine I am on the net with is a different PC before anyone suggests cut n paste)

I added the extern keyword to the CMyApp theApp;
No Joy here.

I have added and removed the #include (and it is the correct one) from various combinations of files and still no joy. This is such a silly fault, but I cannot figure out what is wrong.

Any more pointers / ideas ?

Bp

Share this post


Link to post
Share on other sites