class 点击右健
new class
派生自cview
此时会有两个view
系统会弹出选择框
你要注释调其中(Cmainframe)的一个
然后用下面的代码切换
void CMainFrame::SwitchToView(eView nView)
{
CView* pOldActiveView = GetActiveView();
CView* pNewActiveView = (CView*) GetDlgItem(nView);
if (pNewActiveView == NULL) {
switch (nView) {
case STRING:
pNewActiveView = (CView*) new CStringView;
break;
case HEX:
pNewActiveView = (CView*) new CHexView;
break;
}
CCreateContext context;
context.m_pCurrentDoc = pOldActiveView->GetDocument();
pNewActiveView->Create(NULL, NULL, WS_BORDER,
CFrameWnd::rectDefault, this, nView, &context);
pNewActiveView->OnInitialUpdate();
}
SetActiveView(pNewActiveView);
pNewActiveView->ShowWindow(SW_SHOW);
pOldActiveView->ShowWindow(SW_HIDE);
pOldActiveView->SetDlgCtrlID(
pOldActiveView->GetRuntimeClass() ==
RUNTIME_CLASS(CStringView) ? STRING : HEX);
pNewActiveView->SetDlgCtrlID(AFX_IDW_PANE_FIRST);
RecalcLayout();
}:
new class
派生自cview
此时会有两个view
系统会弹出选择框
你要注释调其中(Cmainframe)的一个
然后用下面的代码切换
void CMainFrame::SwitchToView(eView nView)
{
CView* pOldActiveView = GetActiveView();
CView* pNewActiveView = (CView*) GetDlgItem(nView);
if (pNewActiveView == NULL) {
switch (nView) {
case STRING:
pNewActiveView = (CView*) new CStringView;
break;
case HEX:
pNewActiveView = (CView*) new CHexView;
break;
}
CCreateContext context;
context.m_pCurrentDoc = pOldActiveView->GetDocument();
pNewActiveView->Create(NULL, NULL, WS_BORDER,
CFrameWnd::rectDefault, this, nView, &context);
pNewActiveView->OnInitialUpdate();
}
SetActiveView(pNewActiveView);
pNewActiveView->ShowWindow(SW_SHOW);
pOldActiveView->ShowWindow(SW_HIDE);
pOldActiveView->SetDlgCtrlID(
pOldActiveView->GetRuntimeClass() ==
RUNTIME_CLASS(CStringView) ? STRING : HEX);
pNewActiveView->SetDlgCtrlID(AFX_IDW_PANE_FIRST);
RecalcLayout();
}:
解决方案 »
- 程序运行时在DataList中显示的记录选择一项操作,但在对话框关闭时出断言错,想了好久好久了,请问大家 谢谢了
- 提供《VC++实效编程百例》和《VC++技术内幕》下载地址: 刚才下载有问题。不好意思!!
- 在调试模式下调用DoModal过程中被中断
- 来帮我看看这个错啊。。谢谢啦
- 自学的艰难
- 200分求助,怎样与红外线端口通信?应该怎样办?(详细点)最好有源码
- 再问一次toolbar如何显示TEXT,
- VC6写的OCX 控件 在 VFP下使用时接收不到事件???求救
- 多线程如何安全访问同一个MFC控件
- DebugTrace 使用说明
- 怪问题!有人给我解释一下吗?
- 各位大侠,快来帮帮我吧!在线等待!
BOOL CEx20dApp::InitInstance()
{
AfxEnableControlContainer(); // Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif // Change the registry key under which our settings are stored.
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization.
SetRegistryKey(_T("Local AppWizard-Generated Applications")); LoadStdProfileSettings(); // Load standard INI file options (including MRU) // Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views. CMultiDocTemplate* pDocTemplate;
pDocTemplate = new CMultiDocTemplate(
IDR_EX20DTYPE,
RUNTIME_CLASS(CPoemDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CStringView));
AddDocTemplate(pDocTemplate); m_pTemplateHex = new CMultiDocTemplate(
IDR_EX20DTYPE,
RUNTIME_CLASS(CPoemDoc),
RUNTIME_CLASS(CChildFrame),
RUNTIME_CLASS(CHexView)); // create main MDI Frame window
CMainFrame* pMainFrame = new CMainFrame;
if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
return FALSE;
m_pMainWnd = pMainFrame; // Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo); // Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE; // The main window has been initialized, so show and update it.
pMainFrame->ShowWindow(m_nCmdShow);
pMainFrame->UpdateWindow(); return TRUE;
}
void CMainFrame::OnWindowNewHex()
{
CMDIChildWnd* pActiveChild = MDIGetActive();
CDocument* pDocument;
if (pActiveChild == NULL ||
(pDocument = pActiveChild->GetActiveDocument()) == NULL) {
TRACE("Warning: No active document for WindowNew command\n");
AfxMessageBox(AFX_IDP_COMMAND_FAILURE);
return; // Command failed
} // Otherwise, we have a new frame!
CDocTemplate* pTemplate =
((CEx20dApp*) AfxGetApp())->m_pTemplateHex;
ASSERT_VALID(pTemplate);
CFrameWnd* pFrame =
pTemplate->CreateNewFrame(pDocument, pActiveChild);
if (pFrame == NULL) {
TRACE("Warning: failed to create new frame\n");
AfxMessageBox(AFX_IDP_COMMAND_FAILURE);
return; // Command failed
} pTemplate->InitialUpdateFrame(pFrame, pDocument);
}
{
if (m_wndSplitter.CreateStatic(this,1,2))
{
CRect rect;
GetClientRect(&rect);
CSize sizeTree = rect.Size(); sizeTree.cx = rect.Width()/4; if (m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(CView1), sizeTree,pContext))
{
if (m_wndSplitter.CreateView(0,1,RUNTIME_CLASS(CView2),
CSize(0,0),pContext))
{
return TRUE;
}
}
} return FALSE;
}
之后你的两个View都会有效
可以相应菜单或者窗口消息
切分窗口也能达到你的要求!!而且可以使用多个切分类,实现任意切分