CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2005
    Posts
    336

    Able to Update Without AddView ??

    Hi

    1-) I opened a SDI project:
    Code:
    pDocTemplate = new CSingleDocTemplate(
    		IDR_MAINFRAME,
    		RUNTIME_CLASS(CTRYDoc),
    		RUNTIME_CLASS(CMainFrame),       // main SDI frame window
    		RUNTIME_CLASS(CTRYView));
    2-) Added a view (CLeft) and a Static Splitter:
    Code:
    m_wndSpliiter.CreateStatic(this, 2, 1);
    	m_wndSpliiter.CreateView(0, 0, RUNTIME_CLASS(CLeft), CSize(100, 100), pContext);
    	m_wndSpliiter.CreateView(1, 0, RUNTIME_CLASS(CTRYView), CSize(100, 100), pContext);
    3-) In CTRYView LBUTTONDOWN handler:
    [code]
    GetDocument()->m_Point = point;
    GetDocument()->UpdateAllViews(NULL);
    [code]
    4-)In CLeft.h
    Code:
    #ifndef _DEBUG  // debug version in TRYView.cpp
    inline CTRYDoc* CTRYView::GetDocument() const
       { return reinterpret_cast<CTRYDoc*>(m_pDocument); }
    #endif
    and:
    Code:
    void CLeft::OnDraw(CDC* pDC)
    {
    	CDocument* pDoc = this->GetDocument();
    	// TODO: add draw code here
    	pDC->Ellipse( GetDocument()->m_Point.x - 10, GetDocument()->m_Point.y - 10, GetDocument()->m_Point.x + 10,
    		GetDocument()->m_Point.y + 10);
    }
    I didn't call AddView for CLeft, but when i clicked on CTRYView and as seemed, it calls UpdateAllView(NULL) and it updates CLeftView too. But there is no connection.

    How is that possible? How does doc knows another view is exist?

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Able to Update Without AddView ??

    Have a look at CCreateContext structure in MSDN.
    Note that you are passing CCreateContext pointer in while creating your Views inside a splitter.
    Victor Nijegorodov

  3. #3
    Join Date
    Sep 2005
    Posts
    336

    Re: Able to Update Without AddView ??

    OK. Thank you.
    Understood.

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