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

Thread: CView

  1. #1
    Join Date
    Apr 1999
    Location
    Davenport, Iowa, USA
    Posts
    158

    CView

    Hello,

    How can I Invalidate the view window from another class? I'm using Visual C++ 6.0 and I have a combo box, which is at the top of the view, and when I select something in the combo box, I want to update the view.

    Thanks for any help!

    Matt


  2. #2

    Re: CView

    CView is derived from CWnd
    use base class functions (like RedrawWindow)


  3. #3
    Join Date
    May 1999
    Location
    Farnborough, Hants, England
    Posts
    710

    Re: CView

    For an SDI app:

    --- CFrameWnd *pWndMain ;
    CView *pView = NULL ;

    pWndMain = (CFrameWnd *)AfxGetMainWnd();
    if (pWndMain != NULL)
    pView = pWndMain->GetActiveView();

    if (pView != NULL)
    pView->InvalidateRect(NULL);




    ---

    For an MDI app:

    --- CFrameWnd *pWndChild = NULL ;
    CMDIFrameWnd *pWndMain ;
    CView *pView = NULL ;

    pWndMain = (CMDIFrameWnd *)AfxGetMainWnd();
    if (pWndMain != NULL)
    pWndChild = pWndMain->MDIGetActive();
    if (pWndChild != NULL)
    pView = pWndChild->GetActiveView();

    if (pView != NULL)
    pView->InvalidateRect(NULL);




    ---

    These assume that the view you want to update is the currently-active. If you want to update ALL views simultaneously, use GetActiveDocument() instead of GetActiveView() and call CDocument's UpdateAllViews() method.

    If you only want to update one view, and you can't rely on it being the active one, you will have to find some way of distinguishing between the views, and then use CDocTemplate's GetFirstDocPosition() and GetNextDoc() to iterate through the documents in your app, and then CDocument's GetFirstViewPosition() and GetNextView() to iterate through the views associated with each document. You can then test the view to see if it is the right one.

    Does this help?



    --
    Jason Teagle
    [email protected]

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