summaryrefslogtreecommitdiff
path: root/plugins/Clist_nicer/src/CLUIFrames/movetogroup.cpp
blob: 7daa97cf9d359edd69c8b0be80a34add45c4ab26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <commonheaders.h>

HANDLE hOnCntMenuBuild;
HANDLE hPriorityItem = 0, hFloatingItem = 0;

static int OnContactMenuBuild(WPARAM wParam,LPARAM lParam)
{
	BYTE bSetting = cfg::getByte("CList", "flt_enabled", 0);
	if (bSetting && !hFloatingItem) {
		CLISTMENUITEM mi = { sizeof(mi) };
		mi.position=200000;
		mi.pszPopupName=(char *)-1;
		mi.pszService="CList/SetContactFloating";
		mi.pszName=LPGEN("&Floating Contact");
		if (SendMessage(pcli->hwndContactTree, CLM_QUERYFLOATINGCONTACT, wParam, 0))
			mi.flags = CMIF_CHECKED;

		hFloatingItem = Menu_AddContactMenuItem(&mi);
	}
	else if ( !bSetting && hFloatingItem) {
		CallService(MS_CLIST_REMOVECONTACTMENUITEM, (WPARAM)hFloatingItem, 0);
		hFloatingItem = 0;
	}
	else {
		CLISTMENUITEM mi = { sizeof(mi) };
		mi.flags = CMIM_FLAGS;
		if (SendMessage(pcli->hwndContactTree, CLM_QUERYFLOATINGCONTACT, wParam, 0))
			mi.flags |= CMIF_CHECKED;

		CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hFloatingItem, (LPARAM)&mi);
	}
	return 0;
}

int MTG_OnmodulesLoad(WPARAM wParam,LPARAM lParam)
{
	hOnCntMenuBuild=HookEvent(ME_CLIST_PREBUILDCONTACTMENU,OnContactMenuBuild);
	return 0;
}

int UnloadMoveToGroup(void)
{
	if (hOnCntMenuBuild)
		UnhookEvent(hOnCntMenuBuild);

	return 0;
}