コード例 #1
0
ファイル: ContactList.cpp プロジェクト: tweimer/miranda-ng
// 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);
}
コード例 #2
0
ファイル: ContactList.cpp プロジェクト: tweimer/miranda-ng
// adds a new contact if it doesn't exist yet; returns its hItem
HTREEITEM CCList::AddContact(MCONTACT hContact)
{
	_ASSERT(IsHContactContact(hContact));
	HTREEITEM hContactItem = FindContact(hContact);
	if (hContactItem)
		return hContactItem;

	TVINSERTSTRUCT tvIns;
	memset(&tvIns, 0, sizeof(tvIns));
	tvIns.hParent = AddGroup(db_get_s(hContact, "CList", "Group", L""));
	tvIns.item.pszText = Clist_GetContactDisplayName(hContact);
	tvIns.hInsertAfter = TVI_ROOT;
	tvIns.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
	tvIns.item.iImage = tvIns.item.iSelectedImage = Clist_GetContactIcon(hContact);
	tvIns.item.lParam = Items.AddElem(CCLItemData(hContact));
	return TreeView_InsertItem(hTreeView, &tvIns);
}
コード例 #3
0
ファイル: ContactList.cpp プロジェクト: tweimer/miranda-ng
HTREEITEM CCList::AddInfo(TCString Title, HTREEITEM hParent, HTREEITEM hInsertAfter, LPARAM lParam, HICON hIcon)
{
	TVINSERTSTRUCT tvi = {};
	tvi.item.mask = TVIF_TEXT | TVIF_STATE | TVIF_PARAM;
	tvi.item.pszText = Title;
	tvi.hParent = hParent;
	tvi.hInsertAfter = hInsertAfter;
	tvi.item.lParam = Items.AddElem(CCLItemData());
	Items[tvi.item.lParam].lParam = lParam;
	tvi.item.state = tvi.item.stateMask = TVIS_BOLD | TVIS_EXPANDED;
	if (hIcon) {
		HIMAGELIST iml = TreeView_GetImageList(hTreeView, TVSIL_NORMAL);
		tvi.item.mask |= TVIF_IMAGE | TVIF_SELECTEDIMAGE;
		tvi.item.iImage = tvi.item.iSelectedImage = ImageList_AddIcon(iml, hIcon); // we don't check for duplicate icons, but i think that's ok, judging that the check will require some pretty significant amount of additional coding
		TreeView_SetImageList(hTreeView, iml, TVSIL_NORMAL);
	}
	return TreeView_InsertItem(hTreeView, &tvi);
}
コード例 #4
0
ファイル: ContactList.cpp プロジェクト: Seldom/miranda-ng
// 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);
}