Esempio n. 1
0
// adds a new group if it doesn't exist yet; returns its hItem
HTREEITEM CCList::AddGroup(TCString GroupName)
{
	if (GroupName == L"")
		return TVI_ROOT;

	MGROUP hGroupId = Clist_GroupExists(GroupName);
	if (hGroupId == NULL)
		return nullptr;

	MCONTACT hContact = UINT_PTR(hGroupId) - 1 + HCONTACT_ISGROUP;
	HTREEITEM hGroupItem = FindContact(hContact);
	if (hGroupItem)
		return hGroupItem; // exists already, just return its handle

	TVINSERTSTRUCT tvIns = {};
	tvIns.hParent = TVI_ROOT;
	tvIns.item.pszText = wcsrchr(GroupName, '\\');
	if (tvIns.item.pszText) {
		TCString ParentGroupName(L"");
		tvIns.hParent = AddGroup(ParentGroupName.DiffCat(GroupName, tvIns.item.pszText));
		tvIns.item.pszText++;
	}
	else tvIns.item.pszText = GroupName;

	tvIns.hInsertAfter = TVI_ROOT;
	tvIns.item.mask = TVIF_TEXT | TVIF_STATE | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
	tvIns.item.state = tvIns.item.stateMask = TVIS_BOLD | TVIS_EXPANDED;
	tvIns.item.iImage = tvIns.item.iSelectedImage = IMAGE_GROUPOPEN;
	tvIns.item.lParam = Items.AddElem(CCLItemData(hContact));
	return TreeView_InsertItem(hTreeView, &tvIns);
}
Esempio n. 2
0
// adds a new group if it doesn't exist yet; returns its hItem
HTREEITEM CCList::AddGroup(TCString GroupName)
{
	if (GroupName == _T(""))
		return TVI_ROOT;

	sGroupEnumData GroupEnumData;
	GroupEnumData.GroupName = GroupName;
	GroupEnumData.hGroup = NULL;
	DBCONTACTENUMSETTINGS dbEnum;
	memset(&dbEnum, 0, sizeof(dbEnum));
	dbEnum.lParam = (LPARAM)&GroupEnumData;
	dbEnum.pfnEnumProc = GroupEnum;
	dbEnum.szModule = "CListGroups";
	CallService(MS_DB_CONTACT_ENUMSETTINGS, NULL, (LPARAM)&dbEnum);
	if (!GroupEnumData.hGroup) // means there is no such group in the groups list
		return NULL;

	HTREEITEM hGroupItem = FindContact((UINT_PTR)GroupEnumData.hGroup);
	if (hGroupItem)
		return hGroupItem; // exists already, just return its handle

	TVINSERTSTRUCT tvIns = { 0 };
	tvIns.hParent = TVI_ROOT;
	tvIns.item.pszText = _tcsrchr(GroupName, '\\');
	if (tvIns.item.pszText) {
		TCString ParentGroupName(_T(""));
		tvIns.hParent = AddGroup(ParentGroupName.DiffCat(GroupName, tvIns.item.pszText));
		tvIns.item.pszText++;
	}
	else tvIns.item.pszText = GroupName;

	tvIns.hInsertAfter = TVI_ROOT;
	tvIns.item.mask = TVIF_TEXT | TVIF_STATE | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
	tvIns.item.state = tvIns.item.stateMask = TVIS_BOLD | TVIS_EXPANDED;
	tvIns.item.iImage = tvIns.item.iSelectedImage = IMAGE_GROUPOPEN;
	tvIns.item.lParam = Items.AddElem(CCLItemData((UINT_PTR)GroupEnumData.hGroup));
	return TreeView_InsertItem(hTreeView, &tvIns);
}