LRESULT CXTPShellTreeCtrl::OnUpdateShell(WPARAM wParam, LPARAM lParam) { switch (wParam) { // Update selection of tree view to the case SHN_XTP_SELECTCHILD: { XTP_LVITEMDATA* lplvid = (XTP_LVITEMDATA*)lParam; ASSERT(lplvid != NULL); if (!FindTreeItem(GetSelectedItem(), lplvid, FALSE) && m_pListCtrl != NULL) { // The folder was not found so we send back a message // to the listview to execute the itemid m_pListCtrl->SendMessage(WM_XTP_SHELL_NOTIFY, (WPARAM)SHN_XTP_NOFOLDER, (LPARAM)(CObject*)lplvid); } } break; default: break; } return 0; }
BOOL CPreviewDlg::OnInitDialog() { CDialog::OnInitDialog(); m_image.Create(IDB_BITMAP_MATERIAL, 16, 1, RGB(255, 255, 255)); treeMedia.SetImageList(&m_image, TVSIL_NORMAL); if ( disablePreview ) { wndPreview.ShowWindow( SW_HIDE ); } else { wndPreview.setDrawable(&m_testDrawable); } SetMode(currentMode); BuildTree(); if ( mediaName.Length() ) { HTREEITEM root = treeMedia.GetRootItem(); HTREEITEM sel = FindTreeItem(&treeMedia, root, mediaName, NULL ); if (sel) { treeMedia.SelectItem(sel); } } mediaName = ""; return TRUE; // return TRUE unless you set the focus to a control }
/* ======================================================================================================================= ======================================================================================================================= */ HTREEITEM FindTreeItem(CTreeCtrl *tree, HTREEITEM root, const char *text, HTREEITEM forceParent) { HTREEITEM theItem = NULL; if (root) { if ((theItem = tree->GetNextSiblingItem(root)) != NULL) { theItem = FindTreeItem(tree, theItem, text, NULL); if (theItem) { if (forceParent) { if (tree->GetParentItem(theItem) == forceParent) { return theItem; } } else { return theItem; } } } } if ((theItem = tree->GetChildItem(root)) != NULL) { theItem = FindTreeItem(tree, theItem, text, NULL); if (theItem) { if (forceParent) { if (tree->GetParentItem(theItem) == forceParent) { return theItem; } } else { return theItem; } } } if (text && idStr::Icmp(tree->GetItemText(root), text) == 0 ) { return root; } if (theItem && forceParent) { if (tree->GetParentItem(theItem) != forceParent) { theItem = NULL; } } return theItem; }
void CDialogTextures::SelectCurrentItem(bool collapse, const char *name, int id) { HTREEITEM root = m_treeTextures.GetRootItem(); idStr qt; if ((id == TEXTURES) || (id == MATERIALS)) { HTREEITEM matItem = NULL; HTREEITEM *matPtr = &matItem; // FIXME: This is a hack. How should this really work? if (id == MATERIALS && !idStr::Icmpn( name, "textures/", 9 ) ) { // Texture_SetTexture calls SelectCurrentItem with id == MATERIALS id = TEXTURES; } setTexture = false; if (root) { if (collapse && !ignoreCollapse) { CollapseChildren(root); } HTREEITEM *check = NULL; qt = TypeNames[id]; qt += "/"; if (id == TEXTURES && !idStr::Icmpn( name, "textures/", 9 ) ) { // strip off "textures/" qt += name + 9; } else { qt += name; } if (quickTree.Get(qt, &check)) { matItem = *check; } if (matItem == NULL) { matItem = findItem(name, root, matPtr); } if (matItem) { m_treeTextures.SelectItem(matItem); } } setTexture = true; } else if (id == SOUNDS) { if (root) { if (collapse && !ignoreCollapse) { CollapseChildren(root); } HTREEITEM sel = FindTreeItem(&m_treeTextures, root, name, NULL); if (sel) { m_treeTextures.SelectItem(sel); } } } }
void CXTPShellTreeView::OnUpdate(CView* /*pSender*/, LPARAM lHint, CObject* pHint) { switch (lHint) { // Update selection of tree view to the case SHN_XTP_SELECTCHILD: { XTP_LVITEMDATA* lplvid = (XTP_LVITEMDATA*)pHint; ASSERT(lplvid != NULL); if (!FindTreeItem(GetTreeCtrl().GetSelectedItem(), lplvid, FALSE)) { // The folder was not found so we send back a message // to the listview to execute the itemid CDocument* pDoc = GetDocument(); pDoc->UpdateAllViews(this, SHN_XTP_NOFOLDER, (CObject*)lplvid); } } break; default: break; } }