/* * TreeView_GetPath - ツリービューアイテムのパスを取得する */ static void treeview_get_path(const HWND hTreeView, const HTREEITEM root, const HTREEITEM hItem, TCHAR *ret) { HTREEITEM pItem; TCHAR buf[BUF_SIZE]; TCHAR name[BUF_SIZE]; TCHAR work[BUF_SIZE]; // ルートアイテムの場合はそのままパスを返す if (hItem == root) { lstrcpy(ret, TEXT("\\")); return; } if (treeview_get_text(hTreeView, hItem, buf) == -1) { *ret = TEXT('\0'); return; } pItem = TreeView_GetParent(hTreeView, hItem); while (pItem != root) { treeview_get_text(hTreeView, pItem, name); wsprintf(work, TEXT("%s\\%s"), name, buf); lstrcpy(buf, work); pItem = TreeView_GetParent(hTreeView, pItem); } // 指定の文字列と結合 wsprintf(ret, TEXT("\\%s"), buf); }
static void saveCollapseState( HWND hwndTree ) { HTREEITEM hti; TVITEM tvi; hti = TreeView_GetRoot( hwndTree ); while( hti != NULL ) { HTREEITEM ht; tvi.mask = TVIF_STATE | TVIF_HANDLE | TVIF_CHILDREN | TVIF_PARAM; tvi.hItem = hti; tvi.stateMask = (DWORD)-1; TreeView_GetItem( hwndTree, &tvi ); if( tvi.cChildren > 0 ) { TreeItem *treeItem = (TreeItem *)tvi.lParam; if ( tvi.state & TVIS_EXPANDED ) DBWriteContactSettingByte(NULL, "KeyBindingsUI", treeItem->paramName, TVIS_EXPANDED ); else DBWriteContactSettingByte(NULL, "KeyBindingsUI", treeItem->paramName, 0 ); } ht = TreeView_GetChild( hwndTree, hti ); if( ht == NULL ) { ht = TreeView_GetNextSibling( hwndTree, hti ); while( ht == NULL ) { hti = TreeView_GetParent( hwndTree, hti ); if( hti == NULL ) break; ht = TreeView_GetNextSibling( hwndTree, hti ); } } hti = ht; } }
TreeView::Item TreeView::parent ( const Item& item ) const { const ::HTREEITEM parent( TreeView_GetParent(handle(),item.handle()) ); return (Item(parent)); }
int ShellBrowserChild::Command(int id, int code) { switch(id) { case ID_BROWSE_BACK: break;//@todo case ID_BROWSE_FORWARD: break;//@todo case ID_BROWSE_UP: if (_left_hwnd) { //@@ not necessary in this simply case: jump_to(_cur_dir->_up); //@@ -> move into jump_to() HTREEITEM hitem = TreeView_GetParent(_left_hwnd, _last_sel); if (hitem) TreeView_SelectItem(_left_hwnd, hitem); // sends TVN_SELCHANGED notification } else { if (_cur_dir->_up) jump_to(_cur_dir->_up); } break; default: return 1; } return 0; }
LRESULT FilterOnInfoTip( IN HWND hWnd, IN HWND hWndTree, IN LPNMTVGETINFOTIP lp ) { HTREEITEM Parent; PBTR_FILTER Filter; PFILTER_NODE Node; RPC_WSTR Uuid = NULL; Parent = TreeView_GetParent(hWndTree, lp->hItem); if (!Parent) { Node = (PFILTER_NODE)lp->lParam; Filter = Node->Filter; UuidToString(&Filter->FilterGuid, &Uuid); StringCchPrintf(lp->pszText, lp->cchTextMax, FILTER_INFOTIP_FORMAT, Filter->FilterName, Filter->Description, Uuid, Filter->MajorVersion, Filter->MinorVersion, Filter->Author ); RpcStringFree(&Uuid); } return 0; }
void Explorerplusplus::OnTreeViewFileDelete(BOOL bPermanent) { HTREEITEM hItem, hParentItem; LPITEMIDLIST pidl = NULL; DWORD fMask = 0; HRESULT hr; hItem = TreeView_GetSelection(m_hTreeView); hParentItem = TreeView_GetParent(m_hTreeView,hItem); // Select the parent item to release the lock and allow deletion TreeView_Select(m_hTreeView,hParentItem,TVGN_CARET); if(hItem != NULL) { pidl = m_pMyTreeView->BuildPath(hItem); if(bPermanent) { fMask = CMIC_MASK_SHIFT_DOWN; } hr = ExecuteActionFromContextMenu(pidl,NULL,0,_T("delete"),fMask); CoTaskMemFree(pidl); } }
HTREEITEM wbAddTreeViewItemSibling(PWBOBJ pwbo, HTREEITEM hItem, LPTSTR lpszItem, int lParam, BOOL bSetlParam, int nImageIndex, int nSelectedImageIndex) { TV_ITEM tvi; TV_INSERTSTRUCT tvins; PTREEDATA ptrdt = (PTREEDATA)pwbo->lparam; if(!pwbo || !pwbo->hwnd || !IsWindow(pwbo->hwnd)) return FALSE; if((!lpszItem || !*lpszItem)) return NULL; // Add the item tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | (bSetlParam ? TVIF_PARAM : 0); tvi.pszText = lpszItem; tvi.cchTextMax = wcslen(lpszItem); tvi.lParam = lParam; tvi.iImage = (nImageIndex >= 0 ? nImageIndex : 4); // Default image indices: 4, 5 tvi.iSelectedImage = (nSelectedImageIndex >= 0 ? nSelectedImageIndex : 5); if(!hItem) tvins.hParent = TVI_ROOT; else tvins.hParent = TreeView_GetParent(pwbo->hwnd, hItem); tvins.hInsertAfter = hItem; tvins.item = tvi; // Insert the item ptrdt->hLast = TreeView_InsertItem(pwbo->hwnd, &tvins); return ptrdt->hLast; }
void OptTree_Translate(HWND hwndTree) { HTREEITEM hItem = TreeView_GetRoot(hwndTree); while (hItem) { HTREEITEM hItemTmp = 0; OptTree_TranslateItem(hwndTree, hItem); if (hItemTmp = TreeView_GetChild(hwndTree, hItem)) { hItem = hItemTmp; } else if (hItemTmp = TreeView_GetNextSibling(hwndTree, hItem)) { hItem = hItemTmp; } else { while (1) { if (!(hItem = TreeView_GetParent(hwndTree, hItem))) break; if (hItemTmp = TreeView_GetNextSibling(hwndTree, hItem)) { hItem = hItemTmp; break; } } } } }
// @pathprefix: 如果该值为NULL/pathprefix[0]=='\0', 在形成的路径前前加这一串 char* TreeView_FormPath(HWND hctl, HTREEITEM htvi, char *pathprefix) { static char path[_MAX_PATH]; char text[_MAX_PATH]; HTREEITEM htvip; TVITEMEX tvi; path[0] = '\0'; TreeView_GetItem1(hctl, htvi, &tvi, TVIF_TEXT, path); while ((htvip = TreeView_GetParent(hctl, htvi)) && (htvip != TVI_ROOT)) { TreeView_GetItem1(hctl, htvip, &tvi, TVIF_TEXT, text); if (path[0]) { strcpy(path, formatstr("%s\\%s", text, path)); } else { strcpy(path, text); } htvi = htvip; } if (!is_empty_str(pathprefix)) { if (path[0]) { strcpy(path, formatstr("%s\\%s", pathprefix, path)); } else { strcpy(path, pathprefix); } } return path; }
void CWindowTreeDlg::SelectTreeItem(HWND windowHwnd) { HWND _windowTreeHwnd = GetDlgItem(*this, IDC_WINDOWTREE); HTREEITEM actualItem = TreeView_GetFirstVisible(_windowTreeHwnd); // Search by the item into the list while (actualItem != NULL) { TVITEM tvi = {0}; tvi.hItem = actualItem; tvi.mask = TVIF_PARAM; TreeView_GetItem(_windowTreeHwnd, &tvi); // If it is the item, select it and break the search if ((HWND)tvi.lParam == windowHwnd) { TreeView_SelectItem(_windowTreeHwnd, actualItem); break; } // Find the next item in the TreeView HTREEITEM nextItem = TreeView_GetChild(_windowTreeHwnd, actualItem); if (nextItem == NULL) nextItem = TreeView_GetNextSibling(_windowTreeHwnd, actualItem); HTREEITEM parentItem = actualItem; while ((nextItem == NULL) && (parentItem != NULL)) { parentItem = TreeView_GetParent(_windowTreeHwnd, parentItem); nextItem = TreeView_GetNextSibling(_windowTreeHwnd, parentItem); } actualItem = nextItem; } }
static BOOL CALLCONV RebuildPath(HWND hTreeCtrl, HTREEITEM hItem, LPWSTR szPath) { WCHAR name[MAX_PATH]; TVITEMW item; HTREEITEM hParent; name[0]=0; item.hItem = hItem; item.cchTextMax = MAX_PATH-1; item.pszText = name; item.mask = TVIF_TEXT|TVIF_PARAM; TreeView_GetItem(hTreeCtrl,&item); hParent = TreeView_GetParent(hTreeCtrl,hItem); if(hParent) { RebuildPath(hTreeCtrl, hParent, szPath); lstrcatW(szPath,L"\\"); } if(item.lParam == TVNT_DIR) { lstrcatW(szPath,item.pszText+1); szPath[lstrlenW(szPath)-1]=0; return TRUE; } else if(item.lParam == TVNT_EMPTY) { szPath[0] = 0; return TRUE; } else { lstrcatW(szPath,item.pszText); return TRUE; } }
void ExtractAll() { TVITEM t; int i, nl; char *s; HTREEITEM hn, hm; FILE *log; //log = fopen("exalltest.txt", "w"); if(!file) return; nl = TreeView_GetCount(htree); t.mask = TVIF_PARAM; t.hItem = TreeView_GetChild(htree, TVI_ROOT); // First item for(i = 0; i < nl; i++) { TreeView_GetItem(htree, &t); s = GetItemPath(t.hItem); if(!s) {MessageBox(hwnd, "GetItemPath pathbuf overflow!", title, 16); break;} if(t.lParam != -1) { EnsureDirectoriesArePresent(s); ExtractFile(t.lParam, s); //fprintf(log, "FILE "); }//else fprintf(log, " DIR "); //fprintf(log, "%i: %s\n", i, s); hn = TreeView_GetChild(htree, t.hItem); if(!hn) hn = TreeView_GetNextSibling(htree, t.hItem); if(!hn) { hn = t.hItem; gns: hn = TreeView_GetParent(htree, hn); if(!hn) break; hm = TreeView_GetNextSibling(htree, hn); if(!hm) goto gns; hn = hm; } t.hItem = hn; } //fclose(log); }
HTREEITEM IGetNextTreeItem( HWND tree, HTREEITEM item ) { // First try child items of this one HTREEITEM next = TreeView_GetChild( tree, item ); if( next == nil ) // If no child items, try next sibling next = TreeView_GetNextSibling( tree, item ); if( next == nil ) { // If no siblings, go up to the parent and keep searching until we find a parent with a sibling next = item; while( true ) { next = TreeView_GetParent( tree, next ); if( next == nil ) { // No parent; not found, so stop break; } else if( TreeView_GetNextSibling( tree, next ) != nil ) { next = TreeView_GetNextSibling( tree, next ); break; } } } return next; }
BOOL AP_Win32Dialog_Stylist::_styleClicked(void) { UT_sint32 row, col; TVITEM tvi; HWND hTree = GetDlgItem(m_hWnd, AP_RID_DIALOG_STYLIST_TREE_STYLIST); // Selected item tvi.hItem = TreeView_GetSelection(hTree); if (!tvi.hItem) return 0; // Associated data tvi.mask = TVIF_HANDLE | TVIF_CHILDREN; TreeView_GetItem(hTree, &tvi); // Retrieve the row/column information from the treeview // This maps back to the pStyleList's row&column identifiers if (TreeView_GetParent(hTree, tvi.hItem) == NULL) { if (tvi.cChildren == 1) return 0; // we've clicked on a style category, not a style row = tvi.lParam; col = 0; } else { col = tvi.lParam; // Get parent node for row information tvi.mask = TVIF_HANDLE; tvi.hItem = TreeView_GetParent(hTree, tvi.hItem); TreeView_GetItem(hTree, &tvi); row = tvi.lParam; } UT_UTF8String sStyle; getStyleTree()->getStyleAtRowCol(sStyle,row,col); UT_DEBUGMSG(("StyleClicked row %d col %d style %s \n",row,col,sStyle.utf8_str())); setCurStyle(sStyle); return 1; }
VOID FreeDeviceStrings(HWND hTreeView) { HTREEITEM hItem; hItem = TreeView_GetRoot(hTreeView); if (hItem) { hItem = TreeView_GetChild(hTreeView, hItem); /* loop the parent items */ while (hItem) { hItem = TreeView_GetChild(hTreeView, hItem); if (hItem == NULL) break; /* loop the child items and free the DeviceID */ while (TRUE) { HTREEITEM hOldItem; TV_ITEM tvItem; //TCHAR Buf[100]; tvItem.hItem = hItem; tvItem.mask = TVIF_PARAM;// | TVIF_TEXT; //tvItem.pszText = Buf; //tvItem.cchTextMax = 99; (void)TreeView_GetItem(hTreeView, &tvItem); //MessageBox(NULL, Buf, NULL, 0); HeapFree(GetProcessHeap(), 0, (LPTSTR)tvItem.lParam); hOldItem = hItem; hItem = TreeView_GetNextSibling(hTreeView, hItem); if (hItem == NULL) { hItem = hOldItem; break; } } hItem = TreeView_GetParent(hTreeView, hItem); hItem = TreeView_GetNextSibling(hTreeView, hItem); } } }
HTREEITEM wbGetTreeViewItemParent(PWBOBJ pwbo, HTREEITEM hItem) { if(!pwbo || !pwbo->hwnd || !IsWindow(pwbo->hwnd)) return FALSE; if(!hItem) return FALSE; return TreeView_GetParent(pwbo->hwnd, hItem); }
LRESULT FilterOnWmUncheckItem( IN HWND hWnd, IN UINT uMsg, IN WPARAM wp, IN LPARAM lp ) { HWND hWndTree; TVITEMEX Item = {0}; HTREEITEM hItem; ULONG NewState; ULONG OldState; hWndTree = GetDlgItem(hWnd, IDC_TREE_FILTER); // // Get the current state of treeview item // hItem = (HTREEITEM)wp; Item.mask = TVIF_STATE; Item.stateMask = TVIS_STATEIMAGEMASK ; Item.hItem = hItem; TreeView_GetItem(hWndTree, &Item); OldState = Item.state; // // Clear check state and get new state // TreeView_SetCheckState(hWndTree, hItem, FALSE); Item.mask = TVIF_STATE; Item.stateMask = TVIS_STATEIMAGEMASK ; Item.hItem = hItem; TreeView_GetItem(hWndTree, &Item); NewState = Item.state; // // N.B. This message can only be triggered to child item, NULL lParam // FilterOnItemChanged(hWnd, hWndTree, hItem, NewState, OldState, 0); // // Always clear check state of its parent // TreeView_SetCheckState(hWndTree, TreeView_GetParent(hWndTree, hItem), FALSE); return 0L; }
// Function to get the path the selected item in a Treeview // wyBool FavoriteBase::SelItemPath(HWND htree, HTREEITEM item, wyString &fullpath, wyBool bFileFlag) { wyWChar data[MAX_PATH + 1] = {0}; wyWChar foldpath[MAX_PATH + 1] = {0}; TVITEM tvitem; wyString path, temp, temp2, datastr, foldpathstr; // application data path // if(!pGlobals->m_configdirpath.GetLength()) { if(!SUCCEEDED(::SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, foldpath))) return OnError(_("Error in favorites")); wcscat(foldpath ,L"\\SQLyog"); } else { //wcscpy(foldpath, pGlobals->m_configdirpath.GetAsWideChar()); wcsncpy(foldpath, pGlobals->m_configdirpath.GetAsWideChar(), MAX_PATH); foldpath[MAX_PATH] = '\0'; } while(item) { tvitem.mask = TVIF_TEXT | TVIF_IMAGE; tvitem.hItem = item; tvitem.cchTextMax = MAX_PATH; tvitem.pszText = data ; TreeView_GetItem(htree, &tvitem); datastr.SetAs(data); if(tvitem.iImage != NFILE || !bFileFlag) { temp.Sprintf("\\%s", datastr.GetString()); if(path.GetLength() > 0) { temp2.SetAs(path); path.Sprintf("\\%s%s", datastr.GetString(), temp2.GetString()); } else path.Sprintf("\\%s", datastr.GetString()); } item = TreeView_GetParent(htree, item); } foldpathstr.SetAs(foldpath); fullpath.SetAs(foldpathstr.GetString()); fullpath.Add(path.GetString()); return wyTrue; }
mxTreeViewItem * mxTreeView::getParent (mxTreeViewItem *item) const { if (!d_this) return 0; if (item) return (mxTreeViewItem *) TreeView_GetParent (d_this->d_hwnd, (HTREEITEM) item); return 0; }
PTVDATA GetParentNode(_Ty Key) { PTVDATA r = NULL; HTREEITEM hItem = KeyToHandle(Key); if (NULL != hItem) { r = HandleToData(TreeView_GetParent(m_hWnd, hItem)); } return r; }
void CPpcFolderDlg::OnBtnDown(HWND hDlg, WPARAM wParam) { TV_ITEM tvi; HWND hWnd = GetDlgItem(hDlg, IDC_TREE_FOLDER); HTREEITEM hItem = TreeView_GetSelection(hWnd); if (!hItem) return; memset(&tvi, 0, sizeof(tvi)); tvi.mask = TVIF_CHILDREN | TVIF_STATE; tvi.hItem = hItem; TreeView_GetItem(hWnd, &tvi); if (tvi.cChildren) { if (wParam == VK_RIGHT) { if (!(tvi.state & TVIS_EXPANDED)) TreeView_Expand(hWnd, hItem, TVE_EXPAND); else { hItem = TreeView_GetChild(hWnd, hItem); TreeView_SelectItem(hWnd, hItem); } } else { if (tvi.state & TVIS_EXPANDED) TreeView_Expand(hWnd, hItem, TVE_COLLAPSE); else { hItem = TreeView_GetParent(hWnd, hItem); TreeView_SelectItem(hWnd, hItem); } } } else { if (wParam == VK_LEFT) { hItem = TreeView_GetParent(hWnd, hItem); TreeView_SelectItem(hWnd, hItem); } } }
void TreeView_FormVector(HWND hctl, HTREEITEM htvi, std::vector<std::pair<LPARAM, std::string> >& vec) { char text[_MAX_PATH]; HTREEITEM htvip; TVITEMEX tvi; TreeView_GetItem1(hctl, htvi, &tvi, TVIF_TEXT | TVIF_PARAM, text); vec.push_back(std::make_pair<LPARAM, std::string>(tvi.lParam, text)); while ((htvip = TreeView_GetParent(hctl, htvi)) && (htvip != TVI_ROOT)) { TreeView_GetItem1(hctl, htvip, &tvi, TVIF_TEXT | TVIF_PARAM, text); vec.push_back(std::make_pair<LPARAM, std::string>(tvi.lParam, text)); htvi = htvip; } }
// TreeView 全開・全閉 void TreeView_ExpandAll(HWND hwndTree, bool bExpand, int nMaxDepth) { HTREEITEM htiCur; HTREEITEM htiItem; HTREEITEM htiNext; ::SendMessageAny(hwndTree, WM_SETREDRAW, (WPARAM)FALSE, 0); htiCur = htiItem = TreeView_GetSelection( hwndTree ); if (!bExpand && htiCur != NULL) { // 閉じる時はトップに変更 for (htiNext = htiCur; htiNext != NULL; ) { htiItem = htiNext; htiNext = TreeView_GetParent( hwndTree, htiItem ); } if (htiCur != htiItem) { htiCur = htiItem; TreeView_SelectItem( hwndTree, htiCur ); } } std::vector<HTREEITEM> tree; HTREEITEM item = TreeView_GetRoot(hwndTree); while( 0 < tree.size() || item != NULL ){ while(item != NULL && (int)tree.size() < nMaxDepth ){ // 先に展開してからGetChildしないと、ファイルツリーのサブアイテムが展開されない TreeView_Expand(hwndTree, item, bExpand ? TVE_EXPAND : TVE_COLLAPSE); tree.push_back(item); item = TreeView_GetChild(hwndTree, item); } item = tree.back(); tree.pop_back(); item = TreeView_GetNextSibling(hwndTree, item); } // 選択位置を戻す if (htiCur == NULL) { if (bExpand ) { htiItem = TreeView_GetRoot( hwndTree ); TreeView_SelectSetFirstVisible( hwndTree, htiItem ); } TreeView_SelectItem( hwndTree, NULL ); } else { TreeView_SelectSetFirstVisible( hwndTree, htiCur ); } ::SendMessageAny(hwndTree, WM_SETREDRAW, (WPARAM)TRUE, 0); }
void CCList::SelectGroups(HTREEITEM hCurItem, bool bSelected) { // select/deselect all child items HTREEITEM hItem = TreeView_GetChild(hTreeView, hCurItem); HTREEITEM hLimitItem = GetNextItem(MCLGN_NEXT | MCLGN_ANY | MCLGN_NOTCHILD, hCurItem); while (hItem && hItem != hLimitItem) { TreeView_SetItemState(hTreeView, hItem, bSelected ? TVIS_SELECTED : 0, TVIS_SELECTED); Array_SetItemState(hItem, bSelected); hItem = GetNextItem(MCLGN_NEXT | MCLGN_ANY | MCLGN_MULTILEVEL, hItem); } // select/deselect all parent groups hCurItem = TreeView_GetParent(hTreeView, hCurItem); if (bSelected) { while (hCurItem) { // select until we'll find an unselected item or until we'll reach the root hItem = TreeView_GetChild(hTreeView, hCurItem); while (hItem) { // walk through all siblings if (!(TreeView_GetItemState(hTreeView, hItem, TVIS_SELECTED) & TVIS_SELECTED)) break; hItem = TreeView_GetNextSibling(hTreeView, hItem); } if (hItem) // means there was at least one unselected item break; TreeView_SetItemState(hTreeView, hCurItem, TVIS_SELECTED, TVIS_SELECTED); Array_SetItemState(hCurItem, true); hCurItem = TreeView_GetParent(hTreeView, hCurItem); } } while (hCurItem) { // and deselect all remaining parent groups TreeView_SetItemState(hTreeView, hCurItem, 0, TVIS_SELECTED); Array_SetItemState(hCurItem, false); hCurItem = TreeView_GetParent(hTreeView, hCurItem); } }
void plComponentDlg::IDeleteComponent(plMaxNode *component) { if (!component) return; // Make sure this components interface isn't showing if (plComponentUtil::Instance().IsOpen()) plComponentUtil::Instance().IComponentPreDelete(component->ConvertToComponent()); // Delete the component from the scene theHold.Begin(); fInterface->DeleteNode(component); theHold.Accept(_T("Delete Component")); // Delete the component from the tree HWND hTree = GetDlgItem(fhDlg, IDC_TREE); HTREEITEM hItem = TreeView_GetSelection(hTree); HTREEITEM hParent = TreeView_GetParent(hTree, hItem); TreeView_DeleteItem(hTree, hItem); // If that was the only component of this type, delete the type too if (!TreeView_GetChild(hTree, hParent)) { HTREEITEM hCategory = TreeView_GetParent(hTree, hParent); TreeView_DeleteItem(hTree, hParent); // If this is the only type in this category, delete the category too! // Sadly, this is the most we can delete. if (!TreeView_GetChild(hTree, hCategory)) TreeView_DeleteItem(hTree, hCategory); } // Update the rollups in case the selected object had this component attached if (plComponentUtil::Instance().IsOpen()) plComponentUtil::Instance().IUpdateRollups(); }
void SelectTreeViewFolder(int folder_id) { HWND hTreeView = GetTreeView(); HTREEITEM hti; TVITEM tvi; hti = TreeView_GetRoot(hTreeView); while (hti != NULL) { HTREEITEM hti_next; tvi.hItem = hti; tvi.mask = TVIF_PARAM; TreeView_GetItem(hTreeView,&tvi); if (((LPTREEFOLDER)tvi.lParam)->m_nFolderId == folder_id) { TreeView_SelectItem(hTreeView,tvi.hItem); SetCurrentFolder((LPTREEFOLDER)tvi.lParam); return; } hti_next = TreeView_GetChild(hTreeView,hti); if (hti_next == NULL) { hti_next = TreeView_GetNextSibling(hTreeView,hti); if (hti_next == NULL) { hti_next = TreeView_GetParent(hTreeView,hti); if (hti_next != NULL) hti_next = TreeView_GetNextSibling(hTreeView,hti_next); } } hti = hti_next; } // could not find folder to select // make sure we select something tvi.hItem = TreeView_GetRoot(hTreeView); tvi.mask = TVIF_PARAM; TreeView_GetItem(hTreeView,&tvi); TreeView_SelectItem(hTreeView,tvi.hItem); SetCurrentFolder((LPTREEFOLDER)tvi.lParam); }
UINT wbGetTreeViewItemLevel(PWBOBJ pwbo, HTREEITEM hItem) { UINT nLevel; if(!pwbo || !pwbo->hwnd || !IsWindow(pwbo->hwnd)) return FALSE; if(!hItem) return FALSE; nLevel = 0; while(hItem) { hItem = TreeView_GetParent(pwbo->hwnd, hItem); nLevel++; } return nLevel; }
/////////////////////////////////////////////////////////////// // GSFinder + TQのコードを引っ張ってきた。 // Qtaさんありがとー!! // -- Ex.Q -- // ツリー ビューの項目の絶対パスを求める void CFolderDlg::GetTree(HWND hwndTV, HTREEITEM hItem, LPTSTR pszKey) { CTempStr str(IDS_ROOT_FOLDER_NAME); TCHAR szName[MAX_PATH]; TV_ITEM tvi; memset (&tvi, 0, sizeof (tvi)); // 親を取得 HTREEITEM hParent; hParent = TreeView_GetParent (hwndTV, hItem); if (hParent) { // 項目の親の親・・・を取得する GetTree (hwndTV, hParent, pszKey); // 項目の名前を取得する tvi.mask = TVIF_TEXT; tvi.hItem = hItem; tvi.pszText = szName; tvi.cchTextMax = MAX_PATH; TreeView_GetItem(hwndTV, &tvi); // ルートでなければ¥をつける if (wcscmp(pszKey, str) != 0) lstrcat (pszKey, TEXT("\\")); else lstrcpy (pszKey, TEXT("\\")); // 親のパスに今のフォルダ名を追加 lstrcat (pszKey, szName); } else { // 項目の名前を取得する lstrcpy(pszKey, _T("")); szName[0] = _T('\0'); tvi.mask = TVIF_TEXT | TVIF_PARAM; tvi.hItem = hItem; tvi.pszText = szName; tvi.cchTextMax = MAX_PATH; TreeView_GetItem(hwndTV, &tvi); } }
void replaceTreeItem(HWND hwnd, MCONTACT hContact, const char *module, const char *newModule) { int hItem = findItemInTree(hwnd, hContact, (char *)module); HTREEITEM hParent; if (hItem == -1) return; hParent = TreeView_GetParent(hwnd, (HTREEITEM)hItem); { TVITEM item; item.mask = TVIF_PARAM; item.hItem = (HTREEITEM)hItem; if (TreeView_GetItem(hwnd, &item)) mir_free((ModuleTreeInfoStruct *)item.lParam); TreeView_DeleteItem(hwnd, item.hItem); } if (hParent && newModule) { TVINSERTSTRUCT tvi = {0}; ModuleTreeInfoStruct *lParam; tvi.hParent = hParent; tvi.hInsertAfter = TVI_SORT; tvi.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM; tvi.item.pszText = (char *)newModule; lParam = (ModuleTreeInfoStruct *)mir_calloc(sizeof(ModuleTreeInfoStruct)); lParam->hContact = hContact; lParam->type = KNOWN_MODULE; tvi.item.iImage = 1; tvi.item.iSelectedImage = 2; tvi.item.lParam = (LPARAM)lParam; TreeView_InsertItem(hwnd, &tvi); } }
std::wstring CDialogManage::CTabSkins::GetTreeSelectionPath(HWND tree) { WCHAR buffer[MAX_PATH]; // Get current selection name TVITEM tvi = {0}; tvi.hItem = TreeView_GetSelection(tree); tvi.mask = TVIF_TEXT; tvi.pszText = buffer; tvi.cchTextMax = MAX_PATH; TreeView_GetItem(tree, &tvi); std::wstring path = buffer; while ((tvi.hItem = TreeView_GetParent(tree, tvi.hItem)) != NULL) { TreeView_GetItem(tree, &tvi); path.insert(0, 1, L'\\'); path.insert(0, buffer); } return path; }