Пример #1
0
	// 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);
	}
Пример #2
0
void treeview_scroll_to(HWND htv)
{
	if (first_visible_lparam) {
		TreeView_Walk(htv, TVI_ROOT, TRUE, cb_treeview_walk_find_lparam, NULL, FALSE);
		TreeView_SelectSetFirstVisible(htv, first_visible_htvi);
	}
}
Пример #3
0
    bool SelectSetFirstNode(_Ty Key) {

        HTREEITEM hItem = KeyToHandle(Key);

        if (NULL != hItem) {

            return WND_TRUE(TreeView_SelectSetFirstVisible(m_hWnd, hItem));

        }

        return false;
    }