📄 subject_16921.htm
字号:
<p>
序号:16921 发表者:TaShin 发表日期:2002-10-05 21:53:19
<br>主题:文档类和视图累是怎样通讯的?
<br>内容: 我建立了一个SingleDocument的工程,如果我的视图VIEW改变了,如何通知文档DOC去更新(之间的实现过程是怎样)<BR> 如果文档DOC被改变了,又怎样叫视图VIEW去更新?<BR><BR> <BR> 多谢了?
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:黄飚 回复日期:2002-10-08 21:41:18
<br>内容:CView::OnUpdate <BR>virtual void OnUpdate( CView* pSender, LPARAM lHint, CObject* pHint );<BR><BR>Parameters<BR><BR>pSender<BR><BR>Points to the view that modified the document, or NULL if all views are to be updated.<BR><BR>lHint<BR><BR>Contains information about the modifications.<BR><BR>pHint<BR><BR>Points to an object storing information about the modifications.<BR><BR>Remarks<BR><BR>Called by the framework after the view’s document has been modified; this function is called by CDocument::UpdateAllViews and allows the view to update its display to reflect those modifications. It is also called by the default implementation of OnInitialUpdate. The default implementation invalidates the entire client area, marking it for painting when the next WM_PAINT message is received. Override this function if you want to update only those regions that map to the modified portions of the document. To do this you must pass information about the modifications using the hint parameters. <BR><BR>To use lHint, define special hint values, typically a bitmask or an enumerated type, and have the document pass one of these values. To use pHint, derive a hint class from CObject and have the document pass a pointer to a hint object; when overriding OnUpdate, use the CObject::IsKindOf member function to determine the run-time type of the hint object.<BR><BR>Typically you should not perform any drawing directly from OnUpdate. Instead, determine the rectangle describing, in device coordinates, the area that requires updating; pass this rectangle to CWnd::InvalidateRect. This causes painting to occur the next time aWM_PAINT message is received. <BR><BR>If lHint is 0 and pHint is NULL, the document has sent a generic update notification. If a view receives a generic update notification, or if it cannot decode the hints, it should invalidate its entire client area.<BR><BR>CView Overview | Class Members | Hierarchy Chart<BR><BR>See Also CDocument::UpdateAllViews, CView::OnInitialUpdate, CWnd::Invalidate<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -