Click to See Complete Forum and Search --> : How to update the view?


zhiwen
September 27th, 1999, 07:24 AM
Hi,
I use MDI App. I input data by a dialog of mainframe, then, open a new file to show the graph. It does work. However, when
I changed the input data, it still showed the previous graph, even I closed the view and reopened it. What's wrong?

Please give me some tips.
Thanks.

zhiwen
Following is the excerpt:

BOOL CMainFrame::inputParameters()
{
// input data dialog
...
}

void CMainFrame::ShowGraph()
{
AfxGetMainWnd()->PostMessage(WM_COMMAND,ID_FILE_NEW);
}

void CVpsView::OnDraw(CDC* pDC)
{
CVpsDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// get data from member of mainFrame
CMainFrame* pf = (CMainFrame*)AfxGetMainWnd();
CPoint pCP = pf->m_drawingData();

// Draw the curve

}

Alexandra
September 28th, 1999, 07:14 AM
Try Invalidate()( pView = pointer to current CVpsView) .
May be you can move inputParameters() to CVpsView?

BOOL CMainFrame::inputParameters()
{
// input data dialog
pView->Invalidate();
}



Good Luck!

zhiwen
September 28th, 1999, 11:46 PM
It still doesn't work. This project was created by Appwizard. The data input and drawing never involve in the Document. is this the reason?
Before I finish the data input, I don't want to open the view. This is why I put inputparameters() under MainFrame.

I'm not really understand the mechanism of updating view. under what conditions it will refresh? could you give me some more explains?

regards

zhiwen

Alexandra
September 29th, 1999, 09:29 AM
Hi, zhiwen!
I think MSDN will explain this more better than me , becouse I have very baaad english.
I don't now what reason, becouse may be something wrong in the other code.

But my small test with your code works.
I use OnPaint() instead OnDraw(), but think, it does not matter
If you want , you can send me more code details to sash_ka@email.com (attach code)
Good luck!

void CTtestView::OnPaint()
{
CPaintDC dc(this);
OnPrepareDC(&dc);

CMainFrame* pf = (CMainFrame*)AfxGetMainWnd();
CString str = pf->m_drawingData();
int sv = dc.SaveDC();

CRect rect;

dc.SetTextColor(RGB(255,0,0));
dc.SetBkColor(::GetSysColor(COLOR_WINDOW));
GetClientRect(rect);
dc.DrawText(str, -1, rect,
DT_SINGLELINE | DT_CENTER | DT_VCENTER);

dc.RestoreDC(sv);

}