zai单文档 多视图 的问题

w100 2005-09-26 07:48:14
创建了一个工程
SDI 的 包含多个View。(CListView、CEditView)
查找了codeguru、和codeproject。
试了几个例子。效果一般。
1、谁有好的例子 发给我看看 谢谢。
2、工程是基于CListView建立的,CListView 预览、打印正常。
可是在自己建的CEditView 类中如何加入预览、打印功能?
谢谢

king_public@163.com
...全文
302 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
j805 2005-11-29
  • 打赏
  • 举报
回复
void CMainFrame::OnViewChange(UINT nCmdID)
{
if (nCmdID == m_nCurrentView)
return; // already selected
// m_nCurrentView = nCmdID;

// Set the child window ID of the active view to AFX_IDW_PANE_FIRST.
// This is necessary so that CFrameWnd::RecalcLayout will allocate
// this "first pane" to that portion of the frame window's client
// area not allocated to control bars. Set the child ID of
// the previously active view to some other ID; we will use the
// command ID as the child ID.
CView* pOldActiveView = GetActiveView();
::SetWindowLong(pOldActiveView->m_hWnd, GWL_ID, m_nCurrentView);

CView* pNewView = NULL;
CDocument* pDoc = GetActiveDocument();
CRuntimeClass* pNewViewClass;
switch (nCmdID)
{
case ID_VIEW_MAIN:
pNewView = m_pViewMain;
pNewViewClass = RUNTIME_CLASS(CMainView);
break;
case ID_VIEW_AUTO:
pNewView = m_pViewAuto;
pNewViewClass = RUNTIME_CLASS(CAutoView);
break;
case ID_VIEW_MAKE:
pNewView = m_pViewMake;
pNewViewClass = RUNTIME_CLASS(CMakeView);
break;
default:
ASSERT(0);
return;
}

if (pNewView == NULL)
{
// create the new view
CCreateContext context;
context.m_pNewViewClass = pNewViewClass;
context.m_pCurrentDoc = pDoc;
pNewView = STATIC_DOWNCAST(CView, CreateView(&context));
if (pNewView != NULL)
{
pNewView->ShowWindow(SW_SHOW);
pOldActiveView->ShowWindow(SW_HIDE);

pNewView->OnInitialUpdate();
SetActiveView(pNewView);
RecalcLayout();
}
}
else// if (pNewView != NULL)
{
pNewView->ShowWindow(SW_SHOW);
pOldActiveView->ShowWindow(SW_HIDE);
}

SetActiveView(pNewView);
m_nCurrentView = nCmdID;
// finally destroy the old view...
// pOldActiveView->DestroyWindow();
}

单文档多视图切换,的一个函数,相信你可以看懂.
j805 2005-11-29
  • 打赏
  • 举报
回复
加入打印预览:
//BEGIN_MESSAGE_MAP(CtestView, CListView)
// 标准打印命令
ON_COMMAND(ID_FILE_PRINT, CListView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CListView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CListView::OnFilePrintPreview)
//END_MESSAGE_MAP()

加入这三个命令映射,另外在菜单里添加相应菜单.
bobi1128 2005-11-29
  • 打赏
  • 举报
回复
在http://www.yesky.com/97/1779597.shtml有一个帖子"用VC++在单文档界面中创建多视图",可以建立多视图,也可以切换。
我顺便在此问一个问题:但是视图在切换后鼠标事件不响应了,不知到什么原因?
TIking 2005-10-12
  • 打赏
  • 举报
回复
帮你顶下,我也想知道
菜牛 2005-09-26
  • 打赏
  • 举报
回复
你要什么效果?
w100 2005-09-26
  • 打赏
  • 举报
回复
-_-!
w100 2005-09-26
  • 打赏
  • 举报
回复
UP myself
w100 2005-09-26
  • 打赏
  • 举报
回复
在线等待。

15,979

社区成员

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

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