Click to See Complete Forum and Search --> : A easy question


September 13th, 1999, 04:55 AM
Hello:
I have a easy question.
I use VC++6.0 .I don't know how to get the value of View class in Doc class.

Any advice!
ThankS!

thierry Lepoutre
September 13th, 1999, 05:06 AM
Attached to a document, you have a list of views... So, you have to loop through the View list and find out your own view...
CMyDocument::XXX()
{
POSITION pos=GetFirstViewPosition;
while (pos)
{
CView* pView=GetNextView(pos);
}
}
Easy, isn't it?


Thierry.

September 13th, 1999, 07:46 PM
Thank you.
But like your advice .
I defined a int MyData in my view class *.h and it is public.
I want to change MyData's value in Doc class.but the pView->can't
do it.Why?
Any advice??

thierry Lepoutre
September 14th, 1999, 04:19 AM
POSITION pos=GetFirstViewPosition();
while (pos)
{
CView* pView=GetNextView(pos);
if (pView->IsKindOf(RUNTIME_CLASS(CMyViewClass))
((CMyViewClass*)pView)->m_nMyData=15;
}




This portion of code is only valid if you have one instance of your view class. If you have more than one instance of that view class, you need more information to differentiate between them
(other data member, for example...)

Thierry.