Discussion:
Sharing data between two views
(too old to reply)
baha
2006-09-14 15:15:02 UTC
Permalink
I split my view into two separate views. To do so I added the following code
to my OnCreateClient in the main frame.

BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
CRect rect;
GetClientRect(&rect);
if ( !m_mainSplitter.CreateStatic( this, 1, 2 ) )
{
TRACE( "Error setting up splitter frames!" );
return FALSE;
}

if ( !m_mainSplitter.CreateView( 0, 0,RUNTIME_CLASS(CViewOne),
CSize(rect.Width()/2, rect.Height()), pContext ) )
{
TRACE0( "Error setting up splitter frames!" );
return FALSE;
}

if ( !m_mainSplitter.CreateView( 0, 1, RUNTIME_CLASS(CViewTwo),
CSize(rect.Width()/2, rect.Height()), pContext ) )
{
TRACE0( "Error setting up splitter frames!" );
return FALSE;
}

m_bInitSplitter = TRUE;

return true;
}

My problem is that I'd like to share date between ViewOne and ViewTwo. In
particular I have a data structure in ViewOne which I use to redraw ViewOne
every time a timer fires. I'd like to display the data in my ViewOne's data
strcture in ViewTwo every time ViewOne redraws. How do I go about doing this?

Thanks
Ajay Kalra
2006-09-14 15:19:09 UTC
Permalink
Put the data in document. All views have access to the document. Call
UpdateAllViews to update the views when data has changed. This is standard
Doc/View procedure.

--
Ajay Kalra [MVP - VC++]
Post by baha
I split my view into two separate views. To do so I added the following code
to my OnCreateClient in the main frame.
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
CRect rect;
GetClientRect(&rect);
if ( !m_mainSplitter.CreateStatic( this, 1, 2 ) )
{
TRACE( "Error setting up splitter frames!" );
return FALSE;
}
if ( !m_mainSplitter.CreateView( 0, 0,RUNTIME_CLASS(CViewOne),
CSize(rect.Width()/2, rect.Height()), pContext ) )
{
TRACE0( "Error setting up splitter frames!" );
return FALSE;
}
if ( !m_mainSplitter.CreateView( 0, 1, RUNTIME_CLASS(CViewTwo),
CSize(rect.Width()/2, rect.Height()), pContext ) )
{
TRACE0( "Error setting up splitter frames!" );
return FALSE;
}
m_bInitSplitter = TRUE;
return true;
}
My problem is that I'd like to share date between ViewOne and ViewTwo. In
particular I have a data structure in ViewOne which I use to redraw ViewOne
every time a timer fires. I'd like to display the data in my ViewOne's data
strcture in ViewTwo every time ViewOne redraws. How do I go about doing this?
Thanks
Continue reading on narkive:
Loading...