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);
}
用的是單文檔,代碼如上。但是創建的樹形結構不能正常打開,鼠標雙擊也不打開,而且選中時的高亮只出現一下就恢復了。一直不知道咋解決,求幫助啊
而且相同代碼在新建的單文檔能正常實現
但是我這個只是把非客戶區重繪了,邊框去掉了,其他也沒變什麼,然後就不能正常使用了。。萬分不解。。
這是實際圖。