|
-
September 27th, 1999, 07:24 AM
#1
How to update the view?
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
…
}
-
September 28th, 1999, 07:14 AM
#2
Re: How to update the view?
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!
-
September 28th, 1999, 11:46 PM
#3
Re: How to update the view?
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
-
September 29th, 1999, 09:29 AM
#4
Re: How to update the view?
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 [email protected] (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);
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|