Welcome

首页 / 软件开发 / C++ / Windows资源管理器Web视图界面

Windows资源管理器Web视图界面2008-01-19祝晓斌当我们使用Windows资源管理器(Exporlor)时,看到左边的视图能够显示所选目标的相关信息,比较好用。

本例是一个简单的Web视图界面示例,不过左边不是一个Web视图,而是一个FormView。界面如下图所示:

图一 程序运行画面

本例是最简单的SDI工程,在View中创建了两个View:

int CXindowView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
/* 创建左右两个视图 */
m_pForm = (CXindowForm *) okCreateView(RUNTIME_CLASS(CXindowForm), 1001);
m_pList = (CXindowList *) okCreateView(RUNTIME_CLASS(CXindowList), 1002);
m_pForm->m_pParent = this;
return 0;
}

当窗口宽度<400时,会隐藏左边的CXindowForm视图:

void CXindowView::OnSize(UINT nType, int cx, int cy)
{
CView::OnSize(nType, cx, cy);
int nFormWidth = 200;
/* 如果窗口宽度<400, 就隐藏左视图 */
if(cx>400)
{
if(m_pForm->GetSafeHwnd()) m_pForm->ShowWindow(SW_SHOW);
if(m_pForm->GetSafeHwnd()) m_pForm->MoveWindow(0,0,nFormWidth,cy);
if(m_pList->GetSafeHwnd()) m_pList->ShowWindow(SW_SHOW);
if(m_pList->GetSafeHwnd()) m_pList->MoveWindow(nFormWidth,0,cx-nFormWidth,cy);
}
else
{
if(m_pForm->GetSafeHwnd()) m_pForm->ShowWindow(SW_HIDE);
if(m_pList->GetSafeHwnd()) m_pList->ShowWindow(SW_SHOW);
if(m_pList->GetSafeHwnd()) m_pList->MoveWindow(0,0,cx,cy);
}
}