CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: A easy question

  1. #1
    Guest

    A easy question

    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!


  2. #2
    Join Date
    Sep 1999
    Posts
    6

    Re: A easy question

    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.

  3. #3
    Guest

    Re: A easy question

    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??


  4. #4
    Join Date
    Sep 1999
    Posts
    6

    Re: A easy question


    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured