是这样.在菜单中选择"打开",打开一个图片文件,调用CWinApp::OpenDocumentFile("...", FALSE),传递FALSE参数,是为了不打开新的子窗口,但这时已经打开了一个文档,只是将打开的图片柄保存在CDocument的一个成员变量中.并且在CView里也添加了绘制图像的代码.
问题是如何响应一个菜单命令,来打开一个子窗口来显示图片?
也不知道我说清楚没有.
问题是如何响应一个菜单命令,来打开一个子窗口来显示图片?
也不知道我说清楚没有.
解决方案 »
- 不需要手动配置数据源VC++能自动配置数据源,并能默认访问.
- 关于CMultiDocTemplate的问题???
- 怎么制作一个类似QQ或MSN的聊天窗口(界面不需要参照),关键是要独立于应用程序的主窗口,能在任务栏上有这个窗口图标的显示
- 怎样输出框的大小设置字体?
- 请问怎样在DLL程序中连接数据库的存储过程?
- 如何实现多个进程读写文件,使并行读
- 学唐朔飞计算机组成原理的疑问?
- 请问如何使顶层菜单(菜单栏上的菜单)变灰(不可用)???
- 各位大虾如何把一个自定义的祯封装在TCP/IP里发送
- 为何我的帖子被从Visual C++移动到了灌水乐园?
- 如何用winsock实现ftp客户端?
- 怎么禁用对话框上的Button
调用
CDocument::AddView
然后CDocument::UpdateAllViewsMSDN AddView的例子:SDI的,对MDI改一改应该也有用:// The following example toggles two views in an SDI (single document
// interface) frame window. A design decision must be made as to
// whether to leave the inactive view connected to the document,
// such that the inactive view continues to receive OnUpdate
// notifications from the document. It is usually desirable to
// keep the inactive view continuously in sync with the document, even
// though it is inactive. However, doing so incurs a performance cost,
// as well as the programming cost of implementing OnUpdate hints.
// It may be less expensive, in terms of performance and/or programming,
// to re-sync the inactive view with the document only with it is
// reactivated. This example illustrates this latter approach, by
// reconnecting the newly active view and disconnecting the newly
// inactive view, via calls to CDocument::AddView and RemoveView.BOOL CMainFrame::OnViewChange(UINT nCmdID)
// There is an ON_COMMAND_RANGE message map entry associated with
// OnViewChange:
// ON_COMMAND_RANGE( ID_VIEW_VIEW1, ID_VIEW_VIEW2, OnViewChange)
{
CView* pViewAdd;
CView* pViewRemove;
CDocument* pDoc = GetActiveDocument(); if((nCmdID == ID_VIEW_VIEW1) && (m_currentView == 1))
return;
if((nCmdID == ID_VIEW_VIEW2) && (m_currentView == 2))
return; if (nCmdID == ID_VIEW_VIEW2)
{
if (m_pView2 == NULL)
{
m_pView1 = GetActiveView();
m_pView2 = new CMyView2;//Note that if OnSize has been overridden in CMyView2
//and GetDocument() is used in this override it can
//cause assertions and, if the assertions are ignored,
//cause access violation.
m_pView2->Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,
rectDefault, this, AFX_IDW_PANE_FIRST + 1, NULL);
}
pViewAdd = m_pView2;
pViewRemove = m_pView1;
m_currentView= 2;
}
else
{
pViewAdd = m_pView1;
pViewRemove = m_pView2;
m_currentView= 1;
}
// Set the child i.d. of the active view to AFX_IDW_PANE_FIRST,
// so that CFrameWnd::RecalcLayout will allocate to this
// "first pane" that portion of the frame window's client area
// not allocated to control bars. Set the child i.d. of the
// other view to anything other than AFX_IDW_PANE_FIRST; this
// examples switches the child id's of the two views. int nSwitchChildID = pViewAdd->GetDlgCtrlID();
pViewAdd->SetDlgCtrlID(AFX_IDW_PANE_FIRST);
pViewRemove->SetDlgCtrlID(nSwitchChildID); // Show the newly active view and hide the inactive view. pViewAdd->ShowWindow(SW_SHOW);
pViewRemove->ShowWindow(SW_HIDE); // Connect the newly active view to the document, and
// disconnect the inactive view.
pDoc->AddView(pViewAdd);
pDoc->RemoveView(pViewRemove); SetActiveView(pViewAdd);
RecalcLayout();
}
CWinApp::OpenDocumentFilevirtual CDocument* OpenDocumentFile(
LPCTSTR lpszFileName
);
没看到你说的FALSE参数啊。