📄 index113.htm
字号:
<html>
<style type="text/css"><!--
.p9 { font-family: "宋体"; font-size: 9pt}a {text-transform: none; text-decoration: none;}
a:hover {text-decoration: underline; color: #FF0000;}
--></style>
<body background="../di2001.jpg">
<h3 align="center"><font COLOR="#AOAO99"></font></h3>
<table width="100%" border="1" cellspacing="1">
<tr><td><p align="center"><font color="#FF0000">如何切换视口而不破坏它们?</font></td></tr>
<tr><td><p>
</Br>
我创建了一个带有静态分隔区的sdi应用程序,左边显示工作区,右过显示左边选取的东西.我想达到的是如果在分隔区之间进行切换,而不覆盖或破坏原来的CView对象.<Br>
</Br>
以下代码是你所想要的:<Br>
</Br>
class CExSplitterWnd : public CSplitterWnd<Br>
{<Br>
// Construction<Br>
public:<Br>
CExSplitterWnd();<Br>
// Overrides<Br>
// ClassWizard generated virtual function overrides<Br>
//{{AFX_VIRTUAL(CExSplitterWnd)<Br>
//}}AFX_VIRTUAL<Br>
// Implementation<Br>
virtual ~CExSplitterWnd();<Br>
BOOL AttachView(CWnd* pView, int row, int col);<Br>
BOOL DetachView(int row, int col);<Br>
// Generated message map functions<Br>
//{{AFX_MSG(CExSplitterWnd)<Br>
// NOTE - the ClassWizard will add and remove member functions here.<Br>
//}}AFX_MSG<Br>
DECLARE_MESSAGE_MAP()<Br>
};<Br>
</Br>
CExSplitterWnd::CExSplitterWnd()<Br>
{<Br>
}<Br>
</Br>
CExSplitterWnd::~CExSplitterWnd()<Br>
{<Br>
}<Br>
</Br>
BOOL CExSplitterWnd::AttachView(CWnd* pView, int row, int col)<Br>
{<Br>
//Make sure the splitter window was created<Br>
if (!IsWindow(m_hWnd))<Br>
{<Br>
ASSERT(0);<Br>
TRACE(_T("Create the splitter window before attaching windows to panes"));<Br>
return (FALSE);<Br>
}<Br>
</Br>
//Make sure the row and col indices are within bounds<Br>
if (row >= GetRowCount() || col >= GetColumnCount())<Br>
{<Br>
ASSERT(0);<Br>
return FALSE;<Br>
}<Br>
</Br>
//Is the window to be attached a valid one<Br>
if (pView == NULL || (!IsWindow(pView->m_hWnd)))<Br>
{<Br>
ASSERT(0);<Br>
return FALSE;<Br>
}<Br>
</Br>
pView->SetDlgCtrlID(IdFromRowCol(row, col));<Br>
pView->SetParent(this);<Br>
pView->ShowWindow(SW_SHOW);<Br>
pView->UpdateWindow();<Br>
return (TRUE);<Br>
}<Br>
</Br>
BOOL CExSplitterWnd::DetachView(int row, int col)<Br>
{<Br>
//Make sure the splitter window was created<Br>
if (!IsWindow(m_hWnd))<Br>
{<Br>
ASSERT(0);<Br>
TRACE(_T("Create the splitter window before attaching windows to panes"));<Br>
return (FALSE);<Br>
}<Br>
</Br>
//Make sure the row and col indices are<Br>
//within bounds<Br>
if (row >= GetRowCount() || col >= GetColumnCount())<Br>
{<Br>
ASSERT(0);<Br>
return FALSE;<Br>
}<Br>
</Br>
CWnd* pWnd = GetPane(row, col);<Br>
if (pWnd == NULL || (!IsWindow(pWnd->m_hWnd)))<Br>
{<Br>
ASSERT(0);<Br>
return FALSE;<Br>
}<Br>
</Br>
pWnd->ShowWindow(SW_HIDE);<Br>
pWnd->UpdateWindow();<Br>
</Br>
//Set the parent window handle to NULL so that this child window is not<Br>
//destroyed when the parent (splitter) is destroyed<Br>
pWnd->SetParent(NULL);<Br>
return (TRUE);<Br>
}<Br>
</Br>
</p></td></tr>
</table>
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -