Accessing Dialog member Variable problem
-
Hi Friends, How can I Access CDialog Class Member Variables in CDocument Class For Some Process...i Tried a lot..but it give error..plz gve me a solution .. :)
What is the relationship between the
CDocument
andCDialog
classes in your project?«_Superman_» I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++) -
Hi Friends, How can I Access CDialog Class Member Variables in CDocument Class For Some Process...i Tried a lot..but it give error..plz gve me a solution .. :)
kamalilam wrote:
Access CDialog Class Member Variables in CDocument Class
If the member variables are declared as Public, use it directly from the object of the dialog class. For e.g ,
CDocument* pDoc;
pDoc->m_oDialog.m_nMember1 = 10; -
Hi Friends, How can I Access CDialog Class Member Variables in CDocument Class For Some Process...i Tried a lot..but it give error..plz gve me a solution .. :)
The same way you would do for any other classes. Your CDialog and CDocument classes are still classes and they follow the same rules as normal classes. So, to be able to access a variable from a CDialog object, you first need to have an instance of that class (e.g. CDialog myDialog, in which case myDialog is your instance). Then your CDocument needs to be able to access that variable (if he create the instance, then he already owns it and can use it). Finally, the members you want to access in your dialog class have to be accessible, which means either they are public or you provide a getter method for them. But this is really basic C++ knowledge, I suggest you take some time to read and understand the concept of classes, because that's exactly what it is here. It's not because those classes are document and dialog classes that they do not follow the standard rules of C++.
Cédric Moonen Software developer
Charting control [v2.0] OpenGL game tutorial in C++ -
Hi Friends, How can I Access CDialog Class Member Variables in CDocument Class For Some Process...i Tried a lot..but it give error..plz gve me a solution .. :)
Will you please include some relevant information in your post? Are the CDialog members you're talking about public? How is this CDialog object related to the CDocument object in your application?
kamalilam wrote:
Tried a lot..but it give error.
*What* did you try and *what* were the errors for Chri' sake?
“Follow your bliss.” – Joseph Campbell