获取当前活动视图

LZDGDX 2005-03-25 03:04:42
在单文档多视图结构中,为了对各个视图进行刷新,进行如下操作:
CView* pView=GetActiveView();
pDoc->UpdateAllViews(pView);
其中第一步为获取活动视图,第二步是刷新。
在调试过程中发现活动视图的选择具有如下规律:
当前编辑的试图——也就是当前光标所在的试图会被认为是非活动试图。CView* pView=GetActiveView();这一句并不选中他,但是现在我就需要前编辑的试图为活动试图,怎么办呢?

注:我的程序做了窗口切分,分割为左右两部分,各是一个视图。
...全文
404 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
mousefj 2005-03-25
  • 打赏
  • 举报
回复
实在不行可以遍历视图,然后设置需要的视图
下面代码提供参考
POSITION pos;

pos=theApp.pDocTemplate->GetFirstDocPosition();
CGraphBrowseDoc *pDoc=(CGraphBrowseDoc *)theApp.pDocTemplate->GetNextDoc(pos);
pos=pDoc->GetFirstViewPosition();
pView=(CGraphBrowseView *)pDoc->GetNextView(pos);
// str.Format("%s",this->pGraphEnv->GraphTypeName[dlg.m_GraphType]);

pView->OpenGraphDataFile(m_sFileName) ;
((CMainFrame *)::AfxGetMainWnd())->SetActiveView(pView);
bobob 2005-03-25
  • 打赏
  • 举报
回复
得到指针爱怎么弄就怎么弄
LZDGDX 2005-03-25
  • 打赏
  • 举报
回复
我分割是用CSplitterWnd,
但是如果我用GetActivePane还可以刷新视图不?
bobob 2005-03-25
  • 打赏
  • 举报
回复
我很奇怪,你分割不是用CSplitterWnd吗?
主框架类有一个成员m_pWndSplitter,m_pWndSplitter->GetActivePane就可以
LZDGDX 2005-03-25
  • 打赏
  • 举报
回复
这样写我正个程序都要改,用SetActiveView怎么弄呀?
bobob 2005-03-25
  • 打赏
  • 举报
回复
CSplitterWnd::GetActivePane
virtual CWnd* GetActivePane(int* pRow = NULL, int* pCol = NULL);

Return Value

Pointer to the active pane. NULL if no active pane exists.

Parameters

pRow

A pointer to an int to retrieve the row number of the active pane.

pCol

A pointer to an int to retrieve the column number of the active pane.

bobob 2005-03-25
  • 打赏
  • 举报
回复
CSplitterWnd::GetPane
CWnd* GetPane( int row, int col );

Return Value

Returns the pane at the specified row and column. The returned pane is usually a CView-derived class.

15,980

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧