问题描述
- 急!MFC单文档多视图的CTreeView不能正常使用
-
class TreeView : public CTreeView
是我自建的树形结构C++类void TreeView::OnInitialUpdate()
{
CTreeView::OnInitialUpdate();
TVINSERTSTRUCT ti = { 0 };
HTREEITEM hParent, Parent;//TreeView* m_pMyView = (TreeView*)m_wndSplitter.GetPane(0, 0); HIMAGELIST himl; //加入图标 himl = ImageList_Create(16, 16, ILC_COLOR24, 1, 12); ImageList_Add(himl, LoadBitmap(AfxGetApp()->m_hInstance, MAKEINTRESOURCE(IDB_BITMAP1)), NULL); SendMessage(TVM_SETIMAGELIST, TVSIL_NORMAL, (LPARAM)himl); ti.item.mask = TVIF_TEXT | TCIF_IMAGE | TVIF_SELECTEDIMAGE; ti.item.iImage = 0; ti.item.iSelectedImage = 0; ti.item.pszText = _T("127.0.0.1: C0400"); ti.hParent = NULL; ti.hInsertAfter = TVI_ROOT; Parent = hParent = (HTREEITEM)SendMessage(TVM_INSERTITEM, 0, (LPARAM)&ti); ti.hParent = hParent; ti.hInsertAfter = TVI_LAST;//TVI_LAST表示节点添加在最后 ti.item.iImage = 0; ti.item.iSelectedImage = 0; ti.item.pszText = _T("Slot0"); hParent = (HTREEITEM)SendMessage(TVM_INSERTITEM, 0, (LPARAM)&ti); // TODO: 在此添加专用代码和/或调用基类
}
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
// TODO: 在此添加专用代码和/或调用基类
if (!m_wndSplitter.CreateStatic(this, 1, 2))
{
return FALSE;
}
CRect rect;
GetClientRect(&rect);m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(TreeView), CSize(rect.Width() / 3 - 170, rect.Height()), pContext); if (!m_wndSplitter2.CreateStatic(&m_wndSplitter, 1, 2, WS_CHILD | WS_VISIBLE, m_wndSplitter.IdFromRowCol(0, 1)) || !m_wndSplitter2.CreateView(0, 0, RUNTIME_CLASS(RichEditView), CSize(rect.Width() / 3 - 50, rect.Height()), pContext) || !m_wndSplitter2.CreateView(0, 1, RUNTIME_CLASS(RichEditView), CSize(rect.Width() / 3, rect.Height()), pContext)) { return FALSE; } return TRUE; //return CFrameWnd::OnCreateClient(lpcs, pContext);
}
用的是单文档,代码如上。但是创建的树形结构不能正常打开,鼠标双击也不打开,而且选中时的高亮只出现一下就恢复了。一直不知道咋解决,求帮助啊
而且相同代码在新建的单文档能正常实现
但是我这个只是把非客户区重绘了,边框去掉了,其他也没变什么,然后就不能正常使用了。。万分不解。。
解决方案
解决方案三:
yexu fghrefdhdfsdfgfhgfh
时间: 2024-09-30 08:07:21