예제 #1
0
/**
 * name:	InitTreeItems()
 * desc:	initialize the tree control's datastructure
 * param:	needWidth	- width to expand the tree by
 * return:	TRUE if initialization is ok, FALSE otherwise
 **/
BOOLEAN CPsTree::InitTreeItems(LPWORD needWidth)
{
	INT i;
	DBVARIANT dbv;

	if (!_hWndTree || !_pItems)
	{
		return FALSE;
	}

	if (!DB::Setting::GetUString(NULL, MODNAME, SET_LASTITEM, &dbv)) 
	{
		_curItem = FindItemIndexByName(dbv.pszVal);
		DB::Variant::Free(&dbv);
	}

	// init the groups
	if ((_dwFlags & PSTVF_GROUPS) || (!_pPs->hContact && myGlobals.CanChangeDetails)) 
	{
		LPSTR pszGroup;
		
		// set treeview styles
		TreeView_SetIndent(_hWndTree, 3);
		SetWindowLongPtr(_hWndTree, GWL_STYLE, GetWindowLongPtr(_hWndTree, GWL_STYLE)|TVS_HASBUTTONS);

		// init the iParent member for all the items
		for (i = 0; i < _numItems; i++) 
		{
			if (_pItems[i] && (pszGroup = _pItems[i]->ParentItemName()) != NULL) 
			{
				INT iParent = FindItemIndexByName(pszGroup);
				
				// need to add an empty parent item
				if (iParent == -1) 
				{
					iParent = AddDummyItem(pszGroup);
				}
				_pItems[i]->Parent(iParent);
				mir_free(pszGroup);
			}
		}
	}

	if (needWidth)
	{
		*needWidth = 0;
	}
	ShowWindow(_hWndTree, SW_HIDE);
	for (i = 0; i < _numItems; i++)
	{
		if (_pItems[i]->State() != DBTVIS_INVISIBLE)
		{
			ShowItem(i, needWidth);
		}
	}
	ShowWindow(_hWndTree, SW_SHOW);
	return TRUE;
}
예제 #2
0
/**
 * name:	FindItemHandleByName
 * class:	CPsTree
 * desc:	returns the treeitem with specified name
 * param:	pszName		- name of the item to search for
 * return:	HTREEITEM if item exists or NULL otherwise
 **/
HTREEITEM CPsTree::FindItemHandleByName(LPCSTR pszName)
{
	int i;

	if ((i = FindItemIndexByName(pszName)) > -1)
	{
		return _pItems[i]->Hti();
	}
	return NULL;
}
예제 #3
0
/**
 * name:	FindItemByName
 * class:	CPsTree
 * desc:	returns the treeitem with specified name
 * param:	pszName		- name of the item to search for
 * return:	HTREEITEM if item exists or NULL otherwise
 **/
CPsTreeItem* CPsTree::FindItemByName(LPCSTR pszName)
{
	int i;
	
	if ((i = FindItemIndexByName(pszName)) > -1) 
	{
		return _pItems[i];
	}
	return NULL;
}