如何动态创建显示跟隐藏clistview
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
// TODO: Add your specialized code here and/or call the base class
BOOL bRet;
if(!m_split.CreateStatic(this,2,1)) return FALSE; bRet = m_split.CreateView(0,0,RUNTIME_CLASS(CFrameWnd),CSize(50,250),pContext);
if(!bRet) return FALSE;
//再创建一个视图以静态的观看结果
bRet = m_split.CreateView(1,0,RUNTIME_CLASS(MyListView),CSize(50,30),pContext);
if(!bRet) return FALSE;
return TRUE;
}
上面这是跟着窗口一起创建的,现在想打算要动态创建出来,类似点下菜单出来一个clistview,再点一下就隐藏了
帮帮忙啊,先谢谢了
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
// TODO: Add your specialized code here and/or call the base class
BOOL bRet;
if(!m_split.CreateStatic(this,2,1)) return FALSE; bRet = m_split.CreateView(0,0,RUNTIME_CLASS(CFrameWnd),CSize(50,250),pContext);
if(!bRet) return FALSE;
//再创建一个视图以静态的观看结果
bRet = m_split.CreateView(1,0,RUNTIME_CLASS(MyListView),CSize(50,30),pContext);
if(!bRet) return FALSE;
return TRUE;
}
上面这是跟着窗口一起创建的,现在想打算要动态创建出来,类似点下菜单出来一个clistview,再点一下就隐藏了
帮帮忙啊,先谢谢了
也就是说listview在那里显示,如果隐藏了,界面显示什么呢?
然后在其点击响应中
if(m_split){
//就是已经创建了,隐藏,可以用SetWindowPos
//::SetWindowPos(m_split.m_hWnd, NULL, 0, 0, 0 ,0, SWP_HIDEWINDOW);
//m_split.EnableWindow(FALSE);
}else{
//创建一个
}
true 显示
false 隐藏
基础框架应该是CFrameWnd 吧
CListCtrl m_split;
bool m_flags;//m_flags初始化是truevoid CScrollView::OnMenunew()
{
if(m_split){
if(m_flags){
::SetWindowPos(m_split.m_hWnd, NULL, 0, 0, 0 ,0, SWP_HIDEWINDOW);
m_split.EnableWindow(FALSE);
m_flags = false;
}else{
::SetWindowPos(m_split.m_hWnd, NULL, 0, 0, 100 ,100, SWP_SHOWWINDOW);
m_split.EnableWindow(TRUE);
m_flags = true;
}
}else{
m_split.Create(WS_CHILD | WS_VISIBLE | WS_TABSTOP, CRect(0,0,100,100), this, IDC_LISTVIEW);
}
}ListView具体风格你自己设置