コード例 #1
0
ファイル: options.cpp プロジェクト: martok/miranda-ng
INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	HWND hTree = GetDlgItem(hwndDlg, IDC_FILTER);

	switch (msg) {
	case WM_INITDIALOG:
	{
		TranslateDialogDefault(hwndDlg);
		bInitializing = true;
		fill_filter();

		SetWindowLongPtr(hTree, GWL_STYLE, GetWindowLongPtr(hTree, GWL_STYLE) | TVS_NOHSCROLL);

		HIMAGELIST himlButtonIcons = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 2, 2);
		TreeView_SetImageList(hTree, himlButtonIcons, TVSIL_NORMAL);
		TreeView_DeleteAllItems(hTree);

		for (int i = 2; i < nII; i++) { // we don`t need it IGNORE_ALL and IGNORE_MESSAGE
			TVINSERTSTRUCT tvis = { 0 };
			int index = ImageList_AddIcon(himlButtonIcons, LoadSkinnedIcon(ii[i].icon));
			tvis.hParent = NULL;
			tvis.hInsertAfter = TVI_LAST;
			tvis.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_STATE;
			tvis.item.lParam = (LPARAM)(ii[i].type);
			tvis.item.pszText = TranslateTS(ii[i].name);
			tvis.item.iImage = tvis.item.iSelectedImage = index;
			HTREEITEM hti = TreeView_InsertItem(hTree, &tvis);
			TreeView_SetCheckState(hTree, hti, checkState(ii[i].type));
		}

		CheckDlgButton(hwndDlg, IDC_IGNORE_IGNOREALL, bUseMirandaSettings ? BST_CHECKED : BST_UNCHECKED);
		EnableWindow(GetDlgItem(hwndDlg, IDC_FILTER), !bUseMirandaSettings);
		bInitializing = false;
	}
	return TRUE;

	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDC_IGNORE_IGNOREALL:
			EnableWindow(GetDlgItem(hwndDlg, IDC_FILTER), BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_IGNORE_IGNOREALL));
			SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
			break;
		}
		break;

	case WM_NOTIFY:
		switch (((LPNMHDR)lParam)->idFrom) {
		case 0:
			switch (((LPNMHDR)lParam)->code) {
			case PSN_APPLY:
			{
				DWORD flags = 0;
				TVITEM tvi;
				tvi.mask = TVIF_HANDLE | TBIF_LPARAM;
				HWND hTree = GetDlgItem(hwndDlg, IDC_FILTER);
				tvi.hItem = TreeView_GetRoot(hTree); //check ignore all
				while (tvi.hItem) {
					TreeView_GetItem(hTree, &tvi);
					if (TreeView_GetCheckState(hTree, tvi.hItem)) flags |= 1 << (tvi.lParam - 1);
					tvi.hItem = TreeView_GetNextSibling(hTree, tvi.hItem);
				}
				db_set_dw(NULL, MODULENAME, "Filter", flags);

				bUseMirandaSettings = IsDlgButtonChecked(hwndDlg, IDC_IGNORE_IGNOREALL) ? 1 : 0;
				db_set_b(NULL, MODULENAME, "UseMirandaSettings", bUseMirandaSettings);

				fill_filter();
			}
			}
		case IDC_FILTER:
			if (((LPNMHDR)lParam)->code == NM_CLICK)
				SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
			break;
		}
	}
	return FALSE;
}
コード例 #2
0
static LRESULT CALLBACK ToolBar_OptDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam)
{
	static HIMAGELIST himlButtonIcons=NULL;
	static BOOL dragging=FALSE;
	static HANDLE hDragItem=NULL;
	switch (msg)
	{
	case WM_DESTROY:
		ImageList_Destroy(himlButtonIcons);
		break;
	case WM_INITDIALOG:
		{
			HWND hTree=GetDlgItem(hwndDlg,IDC_BTNORDER);
			TranslateDialogDefault(hwndDlg);
			SetWindowLong(hTree,GWL_STYLE,GetWindowLong(hTree,GWL_STYLE)|TVS_NOHSCROLL);
			{					
				himlButtonIcons=ImageList_Create(GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),ILC_COLOR32|ILC_MASK,2,2);
				TreeView_SetImageList(hTree,himlButtonIcons,TVSIL_NORMAL);
			}
			TreeView_DeleteAllItems(hTree);
			tblock;
			
			qsort(tbdat.listOfButtons->items,tbdat.listOfButtons->realCount,sizeof(MTB_BUTTONINFO *),sttSortButtons);
			{				
				int i=0;
				for (i=0; i<tbdat.listOfButtons->realCount; i++)
				{
					TVINSERTSTRUCT tvis={0};
					HTREEITEM hti;
					MTB_BUTTONINFO * mtbi = (MTB_BUTTONINFO*) tbdat.listOfButtons->items[i];
					TCHAR * szTempName=mir_a2t(mtbi->szButtonName);
					HICON hIcon = (HICON)CallService(MS_SKIN2_GETICONBYHANDLE, 0, (LPARAM)mtbi->hPrimaryIconHandle);
					int index = ImageList_AddIcon(himlButtonIcons, hIcon);
					CallService(MS_SKIN2_RELEASEICON, (WPARAM)hIcon, 0);
					tvis.hParent=NULL;
					tvis.hInsertAfter=TVI_LAST;
					tvis.item.mask=TVIF_PARAM|TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_STATE;	
					tvis.item.lParam=(LPARAM)(mtbi);
					tvis.item.pszText=TranslateTS(szTempName);
					tvis.item.iImage=tvis.item.iSelectedImage=index;
					hti=TreeView_InsertItem(hTree,&tvis);
					TreeView_SetCheckState(hTree, hti, mtbi->bVisible );
					mir_free(szTempName);
				}				
			}
			tbunlock;

			SendDlgItemMessage(hwndDlg,IDC_SPIN_W,UDM_SETRANGE,0,MAKELONG(50,10));
			SendDlgItemMessage(hwndDlg,IDC_SPIN_W,UDM_SETPOS,0,MAKELONG(ModernGetSettingByte(NULL, "ModernToolBar", "option_Bar0_BtnWidth",  SETTINGS_BARBTNWIDTH_DEFAULT),0));

			SendDlgItemMessage(hwndDlg,IDC_SPIN_H,UDM_SETRANGE,0,MAKELONG(50,10));
			SendDlgItemMessage(hwndDlg,IDC_SPIN_H,UDM_SETPOS,0,MAKELONG(ModernGetSettingByte(NULL, "ModernToolBar", "option_Bar0_BtnHeight", SETTINGS_BARBTNHEIGHT_DEFAULT),0));

			SendDlgItemMessage(hwndDlg,IDC_SPIN_S,UDM_SETRANGE,0,MAKELONG(20,0));
			SendDlgItemMessage(hwndDlg,IDC_SPIN_S,UDM_SETPOS,0,MAKELONG(ModernGetSettingByte(NULL, "ModernToolBar", "option_Bar0_BtnSpace",  SETTINGS_BARBTNSPACE_DEFAULT),0));

			CheckDlgButton(hwndDlg, IDC_CHECK_AUTOSIZE, ModernGetSettingByte(NULL, "ModernToolBar", "option_Bar0_Autosize", SETTINGS_BARAUTOSIZE_DEFAULT) ? BST_CHECKED : BST_UNCHECKED);
			CheckDlgButton(hwndDlg, IDC_CHECK_MULTILINE, ModernGetSettingByte(NULL,"ModernToolBar", "option_Bar0_Multiline", SETTINGS_BARMULTILINE_DEFAULT) ? BST_CHECKED : BST_UNCHECKED);

			CheckDlgButton(hwndDlg, IDC_TBSHOW, ModernGetSettingByte(NULL,"CLUI","ShowButtonBar",SETTINGS_SHOWBUTTONBAR_DEFAULT) ? BST_CHECKED : BST_UNCHECKED);
			{
				int i;
				BOOL en=IsDlgButtonChecked(hwndDlg,IDC_TBSHOW);
				for (i=0; i<SIZEOF(ControlIDS); i++)
					EnableWindow(GetDlgItem(hwndDlg,ControlIDS[i]), en);
			}
			return TRUE;
		}

	case WM_NOTIFY:
		{
			switch(((LPNMHDR)lParam)->idFrom) 
			{		
			case 0: 
				{
					switch (((LPNMHDR)lParam)->code)
					{
					case PSN_APPLY:
						{
							int order=100;
							HWND hTree=GetDlgItem(hwndDlg,IDC_BTNORDER);
							int count=TreeView_GetCount(hTree);
							HTREEITEM hItem;
							sttDeleteOrderSettings();
							hItem=TreeView_GetRoot(hTree);
							do
							{
								TVITEM tvi={0};
								MTB_BUTTONINFO *mtbi;
								tvi.mask=TBIF_LPARAM|TVIF_HANDLE;
								tvi.hItem=hItem;
								TreeView_GetItem(hTree, &tvi);
								mtbi=(MTB_BUTTONINFO *)tvi.lParam;
								if (mtbi)
								{
									char szTempSetting[200];
									mir_snprintf(szTempSetting, SIZEOF(szTempSetting), "order_%s", mtbi->szButtonID);
									ModernWriteSettingDword(NULL, "ModernToolBar", szTempSetting, order);
									order+=10;
									mir_snprintf(szTempSetting, SIZEOF(szTempSetting), "visible_%s", mtbi->szButtonID);
									ModernWriteSettingByte(NULL, "ModernToolBar", szTempSetting, TreeView_GetCheckState(hTree,hItem));
								}
								hItem=TreeView_GetNextSibling(hTree,hItem);
							} while (hItem!=NULL);
							ModernWriteSettingByte(NULL,"CLUI","ShowButtonBar",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_TBSHOW));
							ModernWriteSettingByte(NULL,"ModernToolBar","option_Bar0_BtnWidth", (BYTE)SendDlgItemMessage(hwndDlg,IDC_SPIN_W,UDM_GETPOS,0,0));
							ModernWriteSettingByte(NULL,"ModernToolBar","option_Bar0_BtnHeight",(BYTE)SendDlgItemMessage(hwndDlg,IDC_SPIN_H,UDM_GETPOS,0,0));
							ModernWriteSettingByte(NULL,"ModernToolBar","option_Bar0_BtnSpace", (BYTE)SendDlgItemMessage(hwndDlg,IDC_SPIN_S,UDM_GETPOS,0,0));
							ModernWriteSettingByte(NULL, "ModernToolBar", "option_Bar0_Autosize", (BYTE)IsDlgButtonChecked(hwndDlg,IDC_CHECK_AUTOSIZE));
							ModernWriteSettingByte(NULL,"ModernToolBar", "option_Bar0_Multiline", (BYTE)IsDlgButtonChecked(hwndDlg,IDC_CHECK_MULTILINE));
							
							sttReloadButtons();
							return TRUE;
						}
					}
					break;
				}
			case IDC_BTNORDER:
				{
					switch (((LPNMHDR)lParam)->code) 
					{
					case TVN_BEGINDRAGA:
					case TVN_BEGINDRAGW:
						SetCapture(hwndDlg);
						dragging=TRUE;
						hDragItem=((LPNMTREEVIEWA)lParam)->itemNew.hItem;
						TreeView_SelectItem(GetDlgItem(hwndDlg,IDC_BTNORDER),hDragItem);
						break;
					case NM_CLICK:
						{						
							TVHITTESTINFO hti;
							hti.pt.x=(short)LOWORD(GetMessagePos());
							hti.pt.y=(short)HIWORD(GetMessagePos());
							ScreenToClient(((LPNMHDR)lParam)->hwndFrom,&hti.pt);
							if(TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom,&hti))
								if(hti.flags&TVHT_ONITEMSTATEICON) 
									SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0);
						};
					}
					break;
				}
			} 
			break;
		}
	case WM_MOUSEMOVE:
		{
			if(!dragging) break;
			{	
				TVHITTESTINFO hti;
				hti.pt.x=(short)LOWORD(lParam);
				hti.pt.y=(short)HIWORD(lParam);
				ClientToScreen(hwndDlg,&hti.pt);
				ScreenToClient(GetDlgItem(hwndDlg,IDC_BTNORDER),&hti.pt);
				TreeView_HitTest(GetDlgItem(hwndDlg,IDC_BTNORDER),&hti);
				if(hti.flags&(TVHT_ONITEM|TVHT_ONITEMRIGHT))
				{
					HTREEITEM it=hti.hItem;
					hti.pt.y-=TreeView_GetItemHeight(GetDlgItem(hwndDlg,IDC_BTNORDER))/2;
					TreeView_HitTest(GetDlgItem(hwndDlg,IDC_BTNORDER),&hti);
					if (!(hti.flags&TVHT_ABOVE))
						TreeView_SetInsertMark(GetDlgItem(hwndDlg,IDC_BTNORDER),hti.hItem,1);
					else 
						TreeView_SetInsertMark(GetDlgItem(hwndDlg,IDC_BTNORDER),it,0);
				}
				else 
				{
					if(hti.flags&TVHT_ABOVE) SendDlgItemMessage(hwndDlg,IDC_BTNORDER,WM_VSCROLL,MAKEWPARAM(SB_LINEUP,0),0);
					if(hti.flags&TVHT_BELOW) SendDlgItemMessage(hwndDlg,IDC_BTNORDER,WM_VSCROLL,MAKEWPARAM(SB_LINEDOWN,0),0);
					TreeView_SetInsertMark(GetDlgItem(hwndDlg,IDC_BTNORDER),NULL,0);
				}
			}	
		}
		break;
	case WM_LBUTTONUP:
		{
			if(!dragging) break;
			TreeView_SetInsertMark(GetDlgItem(hwndDlg,IDC_BTNORDER),NULL,0);
			dragging=0;
			ReleaseCapture();
			{	
				TVHITTESTINFO hti;
				TVITEM tvi;
				hti.pt.x=(short)LOWORD(lParam);
				hti.pt.y=(short)HIWORD(lParam);
				ClientToScreen(hwndDlg,&hti.pt);
				ScreenToClient(GetDlgItem(hwndDlg,IDC_BTNORDER),&hti.pt);
				hti.pt.y-=TreeView_GetItemHeight(GetDlgItem(hwndDlg,IDC_BTNORDER))/2;
				TreeView_HitTest(GetDlgItem(hwndDlg,IDC_BTNORDER),&hti);
				if(hDragItem==hti.hItem) break;
				if (hti.flags&TVHT_ABOVE) hti.hItem=TVI_FIRST;
				tvi.mask=TVIF_HANDLE|TVIF_PARAM;
				tvi.hItem=(HTREEITEM)hDragItem;
				TreeView_GetItem(GetDlgItem(hwndDlg,IDC_BTNORDER),&tvi);
				if(hti.flags&(TVHT_ONITEM|TVHT_ONITEMRIGHT)||(hti.hItem==TVI_FIRST)) 
				{
					TVINSERTSTRUCT tvis;
					TCHAR name[128];
					tvis.item.mask=TVIF_HANDLE|TVIF_PARAM|TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_STATE;
					tvis.item.stateMask=0xFFFFFFFF;
					tvis.item.pszText=name;
					tvis.item.cchTextMax=sizeof(name);
					tvis.item.hItem=(HTREEITEM)hDragItem;
					//tvis.item.iImage=tvis.item.iSelectedImage=((MTB_BUTTONINFO *)tvi.lParam)->bVisible;				
					TreeView_GetItem(GetDlgItem(hwndDlg,IDC_BTNORDER),&tvis.item);				
					TreeView_DeleteItem(GetDlgItem(hwndDlg,IDC_BTNORDER),hDragItem);
					tvis.hParent=NULL;
					tvis.hInsertAfter=hti.hItem;
					TreeView_SelectItem(GetDlgItem(hwndDlg,IDC_BTNORDER),TreeView_InsertItem(GetDlgItem(hwndDlg,IDC_BTNORDER),&tvis));
					SendMessage((GetParent(hwndDlg)), PSM_CHANGED, (WPARAM)hwndDlg, 0);
				}
			}
		}
		break; 
	case WM_COMMAND:
		if (LOWORD(wParam)==IDC_TBSHOW) {
			{
				int i;
				BOOL en=IsDlgButtonChecked(hwndDlg,IDC_TBSHOW);
				for (i=0; i<SIZEOF(ControlIDS); i++)
					EnableWindow(GetDlgItem(hwndDlg,ControlIDS[i]), en);
			}
			SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0);
		} else if ( (LOWORD(wParam)==IDC_TEXT_W || 
					 LOWORD(wParam)==IDC_TEXT_H ||
					 LOWORD(wParam)==IDC_TEXT_S ) 
					&& HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus()) return 0; // dont make apply enabled during buddy set crap 
		SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0);
		break;
	}
	return FALSE;
}
コード例 #3
0
ファイル: filterdlg.c プロジェクト: John-Chan/dprobe
VOID
FilterBuildCommand(
	IN PDIALOG_OBJECT Object
	)
{
	HWND hWndTree;
	HTREEITEM DllItem;
	HTREEITEM ApiItem;
	TVITEMEX Item = {0};
	ULONG Unchecked, Checked;
	ULONG ApiNumber;
	struct _MSP_USER_COMMAND* Command;
	struct _BTR_USER_COMMAND* BtrCommand;
	ULONG Length;
	PLIST_ENTRY ListEntry;
	ULONG Number;
	PFILTER_CONTEXT Context;
	PFILTER_NODE Node;
	PBTR_FILTER Filter;
	LIST_ENTRY FilterList;
	ULONG BitNumber;

	Context = SdkGetContext(Object, FILTER_CONTEXT);
	hWndTree = GetDlgItem(Object->hWnd, IDC_TREE_FILTER);
	DllItem = TreeView_GetChild(hWndTree, TVI_ROOT);

	Checked = INDEXTOSTATEIMAGEMASK(CHECKED);
	Unchecked = INDEXTOSTATEIMAGEMASK(UNCHECKED);
	
	InitializeListHead(&FilterList);

	while (DllItem != NULL) {
		
		RtlZeroMemory(&Item, sizeof(Item));
		Item.mask = TVIF_PARAM;
		Item.hItem = DllItem;
		TreeView_GetItem(hWndTree, &Item);

		Node = (PFILTER_NODE)Item.lParam;
		Filter = Node->Filter;

		//
		// Get first child of DllItem
		//

		ApiItem = TreeView_GetChild(hWndTree, DllItem);
		ApiNumber = 0;

		while (ApiItem != NULL) {

			ULONG IsChecked;

			RtlZeroMemory(&Item, sizeof(Item));
			Item.mask = TVIF_PARAM;
			Item.hItem = ApiItem;
			TreeView_GetItem(hWndTree, &Item);

			IsChecked = TreeView_GetCheckState(hWndTree, ApiItem);

			if ((IsChecked == 0 && Item.lParam != 0) || 
				(IsChecked == 1 && Item.lParam == 0)) {

				BtrSetBit(&Node->BitMap, ApiNumber);
				Node->Count += 1;
			} 
			
			ApiNumber += 1;
			ApiItem = TreeView_GetNextSibling(hWndTree, ApiItem);
		}
	
		if (Node->Count != 0) {
			InsertTailList(&FilterList, &Node->ListEntry);
		} else {
			SdkFree(Node);
		}

		DllItem = TreeView_GetNextSibling(hWndTree, DllItem);
	}

	//
	// Copy scanned result into MSP_USER_COMMAND's command list
	//

	Command = NULL;

	if (IsListEmpty(&FilterList) != TRUE) {

		Command = (PMSP_USER_COMMAND)SdkMalloc(sizeof(MSP_USER_COMMAND));
		RtlZeroMemory(Command, sizeof(MSP_USER_COMMAND));
		Command->CommandType = CommandProbe;
		Command->ProcessId = Context->Process->ProcessId;
		Command->Type = PROBE_FILTER;
		Command->Status = 0;
		Command->CommandCount = 0;
		Command->CommandLength = 0;
		Command->FailureCount = 0;

		InitializeListHead(&Command->CommandList);
		InitializeListHead(&Command->FailureList);

		Command->Callback = NULL;
		Command->CallbackContext = NULL;
	}

	while (IsListEmpty(&FilterList) != TRUE) {
	
		ListEntry = RemoveHeadList(&FilterList);
		Node = CONTAINING_RECORD(ListEntry, FILTER_NODE, ListEntry);	

		Length = FIELD_OFFSET(BTR_USER_COMMAND, Probe[Node->Count]);
		BtrCommand = (PBTR_USER_COMMAND)SdkMalloc(Length);
		BtrCommand->Length = Length;
		BtrCommand->Type = PROBE_FILTER;
		BtrCommand->Count = Node->Count;

		Filter = Node->Filter;
		StringCchCopyW(BtrCommand->DllName, MAX_PATH, Filter->FilterFullPath);
	
		BitNumber = 0;

		for(Number = 0; Number < Node->Count; Number += 1) {

			BOOLEAN Activate;

			BitNumber = BtrFindFirstSetBit(&Node->BitMap, BitNumber);
			Activate = BtrTestBit(&Filter->BitMap, BitNumber);

			BtrCommand->Probe[Number].Activate = !Activate;
			BtrCommand->Probe[Number].Number = BitNumber;

			BitNumber += 1;
		}

		InsertTailList(&Command->CommandList, &BtrCommand->ListEntry);
		Command->CommandCount += 1;
		Command->CommandLength += BtrCommand->Length;

		SdkFree(Node);
	}

	Context->Command = Command;
}
コード例 #4
0
ファイル: filterdlg.c プロジェクト: John-Chan/dprobe
ULONG
FilterScanSelection(
	IN PDIALOG_OBJECT Object,
	OUT PLIST_ENTRY DllListHead
	)
{
	HWND hWndTree;
	HTREEITEM DllItem;
	HTREEITEM ApiItem;
	TVITEMEX Item = {0};
	ULONG ApiNumber;
	PFILTER_NODE Node;
	PBTR_FILTER BtrFilter;
	PCSP_FILTER CspFilter;
	ULONG IsChecked;
	ULONG DllCount;
	BTR_BITMAP Bitmap;

	DllCount = 0;
	InitializeListHead(DllListHead);

	hWndTree = GetDlgItem(Object->hWnd, IDC_TREE_FILTER);
	DllItem = TreeView_GetChild(hWndTree, TVI_ROOT);

	while (DllItem != NULL) {
		
		RtlZeroMemory(&Item, sizeof(Item));
		Item.mask = TVIF_PARAM;
		Item.hItem = DllItem;
		TreeView_GetItem(hWndTree, &Item);

		Node = (PFILTER_NODE)Item.lParam;

		if (!Node->NumberOfSelected) {
			DllItem = TreeView_GetNextSibling(hWndTree, DllItem);
			continue;
		}

		CspFilter = (PCSP_FILTER)SdkMalloc(sizeof(CSP_FILTER));
		RtlZeroMemory(CspFilter, sizeof(CSP_FILTER));

		BtrFilter = Node->Filter;
		CspFilter->Count = 0;
		CspFilter->FilterGuid = BtrFilter->FilterGuid;
		StringCchCopy(CspFilter->FilterName, MAX_PATH, BtrFilter->FilterName);

		BtrInitializeBitMap(&Bitmap, CspFilter->Bits, BtrFilter->ProbesCount);

		//
		// Get first child of DllItem
		//

		ApiNumber = 0;
		ApiItem = TreeView_GetChild(hWndTree, DllItem);

		while (ApiItem != NULL) {

			IsChecked = TreeView_GetCheckState(hWndTree, ApiItem);

			if (IsChecked == 1) {
				BtrSetBit(&Bitmap, ApiNumber);
				CspFilter->Count += 1;
			}

			ApiNumber += 1;
			ApiItem = TreeView_GetNextSibling(hWndTree, ApiItem);
		}
	
		ASSERT(CspFilter->Count == Node->NumberOfSelected);
		InsertTailList(DllListHead, &CspFilter->ListEntry);
		DllCount += 1;

		DllItem = TreeView_GetNextSibling(hWndTree, DllItem);
	}

	return DllCount;
}
コード例 #5
0
ファイル: win_ctl_treeview.cpp プロジェクト: Greathood/taiga
UINT TreeView::GetCheckState(HTREEITEM hItem) {
  return TreeView_GetCheckState(m_hWindow, hItem);
}
コード例 #6
0
UINT TreeView::GetCheckState(HTREEITEM item) {
  return TreeView_GetCheckState(window_, item);
}
コード例 #7
0
//-----------------------------------------------------------------------------
//	ExcludePathsDlg_GetCheckState_r
//
//	Caller invokes at node. Returns with state set.
//	State 0: unchecked, 1: checked, -1:unknown.
//	Returns true if All children match, false otherwise.
//-----------------------------------------------------------------------------
bool ExcludePathsDlg_GetCheckState_r( HWND hWndTree, HTREEITEM hTree, int depth, int *pCheckState )
{
	int checkState;

	checkState = TreeView_GetCheckState( hWndTree, hTree );
	if ( *pCheckState == -1 )
	{
		*pCheckState = checkState;
	}
	else if ( *pCheckState != checkState )
	{
		// disparate state, no need to recurse
		return false;
	}

	TVITEM tvi = { 0 };
	tvi.mask = TVIF_HANDLE | TVIF_CHILDREN;
	tvi.hItem = hTree;
	if ( TreeView_GetItem( hWndTree, &tvi ) )
	{
		if ( tvi.cChildren )
		{
			HTREEITEM hChild = TreeView_GetChild( hWndTree, hTree );
			if ( hChild )
			{
				if ( !ExcludePathsDlg_GetCheckState_r( hWndTree, hChild, depth+1, pCheckState ) )
				{
					return false;
				}
			}
		}
	}
	else
	{
		return false;
	}

	if ( !depth )
	{
		// only iterate siblings of the parent's child
		return true;
	}

	HTREEITEM hSibling = hTree;
	while ( 1 )
	{
		hSibling = TreeView_GetNextSibling( hWndTree, hSibling );
		if ( !hSibling )
		{
			break;
		}

		checkState = TreeView_GetCheckState( hWndTree, hSibling );
		if ( *pCheckState != checkState )
		{
			// disparate state, no need to recurse
			return false;
		}

		tvi.hItem = hSibling;
		if ( TreeView_GetItem( hWndTree, &tvi ) )
		{
			if ( tvi.cChildren )
			{
				HTREEITEM hChild = TreeView_GetChild( hWndTree, hSibling );
				if ( hChild )
				{
					if ( !ExcludePathsDlg_GetCheckState_r( hWndTree, hChild, depth+1, pCheckState ) )
					{
						return false;
					}
				}
			}
		}
	}

	return true;
}
コード例 #8
0
//-----------------------------------------------------------------------------
//	ExcludePathsDlg_Proc
//
//-----------------------------------------------------------------------------
BOOL CALLBACK ExcludePathsDlg_Proc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) 
{
	HWND hWndTree; 
	LPNMHDR lpnmh;
	HTREEITEM hTree;
	HTREEITEM hTreeRoot;
	int checkState;
	static bool s_bAllowPopulate = 0;

	switch ( message ) 
	{ 
	case WM_INITDIALOG:
		ExcludePathsDlg_Setup( hWnd );
		s_bAllowPopulate = true;
		return TRUE;

	case WM_NOTIFY: 
		lpnmh = (LPNMHDR)lParam;
		if ( ( lpnmh->code  == NM_CLICK ) && ( lpnmh->idFrom == IDC_PATHS_TREE ) )
		{
			TVHITTESTINFO ht = {0};
			DWORD dwpos = GetMessagePos();
			ht.pt.x = GET_X_LPARAM( dwpos );
			ht.pt.y = GET_Y_LPARAM( dwpos );
			MapWindowPoints( HWND_DESKTOP, lpnmh->hwndFrom, &ht.pt, 1 );
			TreeView_HitTest( lpnmh->hwndFrom, &ht );
			if ( ht.flags & TVHT_ONITEMSTATEICON )
			{
				PostMessage( hWnd, UM_CHECKSTATECHANGE, 0, (LPARAM)ht.hItem );
			}
		}
		break; 

	case UM_CHECKSTATECHANGE:
		hWndTree = GetDlgItem( hWnd, IDC_PATHS_TREE );
		hTreeRoot = TreeView_GetRoot( hWndTree );
		hTree = (HTREEITEM)lParam;
		checkState = TreeView_GetCheckState( hWndTree, hTree );
		if ( checkState != -1 )
		{
			TVITEM tvi = { 0 };
			char szName[MAX_PATH];
			tvi.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT;
			tvi.hItem = hTree;
			tvi.pszText = szName;
			tvi.cchTextMax = sizeof( szName );
			if ( !TreeView_GetItem( hWndTree, &tvi ) )
			{
				break;
			}
			int nDepth = LOWORD( tvi.lParam );
			bool bIsModPath = HIWORD( tvi.lParam ) != 0;

			if ( g_bLinkGameDirs && bIsModPath )
			{
				// a mod path root is at depth 1
				// a child of a mod path (depth > 1), will match all other children in mod paths
				// a mod path (depth = 1) will match all other modpaths
				ExcludePathsDlg_SetCheckStateLinked_r( hWndTree, hTreeRoot, 0, checkState, nDepth == 1 ? NULL : szName );
			}
			else
			{
				ExcludePathsDlg_SetCheckState_r( hWndTree, hTree, 0, checkState );
			}
		}
		break;

	case WM_PAINT:
		if ( s_bAllowPopulate )
		{
			// unfortunate, but tree view needs to paint first before its state can be set
			// related to checkbox style which doesn't manifest until after WM_INITDIALOG
			// stall the initial population until after the first paint
			s_bAllowPopulate = false;
			PostMessage( hWnd, UM_FIRSTTIMEPOPULATE, 0, 0 );
		}
		break;

	case UM_FIRSTTIMEPOPULATE:
		ExcludePathsDlg_Populate( hWnd, false );
		break;

	case WM_COMMAND: 
		switch ( LOWORD( wParam ) ) 
		{
		case IDC_OK: 
			ExcludePathsDlg_SaveChanges( hWnd );
			EndDialog( hWnd, wParam );
			return TRUE; 

		case IDC_PATHS_RESCAN:
			ExcludePathsDlg_Populate( hWnd, true );
			return TRUE;

		case IDC_PATHS_EXPAND:
			// expand from root
			hWndTree = GetDlgItem( hWnd, IDC_PATHS_TREE );
			ExcludePathsDlg_Expand_r( hWndTree, TreeView_GetRoot( hWndTree ), 0, -1, true );
			return TRUE;

		case IDC_PATHS_COLLAPSE:
			// collapse from root
			hWndTree = GetDlgItem( hWnd, IDC_PATHS_TREE );
			ExcludePathsDlg_Expand_r( hWndTree, TreeView_GetRoot( hWndTree ), 0, -1, false );
			return TRUE;

		case IDC_PATHS_LINKGAMEDIRS:
			g_bLinkGameDirs = IsDlgButtonChecked( hWnd, IDC_PATHS_LINKGAMEDIRS );
			return TRUE;

		case IDCANCEL:
		case IDC_CANCEL: 
			EndDialog( hWnd, wParam );
			return TRUE; 
		}
		break; 
	}
	return FALSE; 
} 
コード例 #9
0
ファイル: fcl.cpp プロジェクト: ttsping/columns_ui
	BOOL CALLBACK FCLDialogProc(HWND wnd,UINT msg,WPARAM wp,LPARAM lp)
	{
		switch(msg)
		{
		case WM_INITDIALOG:
			{
				if (m_import)
					SetWindowText(wnd, _T("Select settings to import"));
				HWND wnd_tree = GetDlgItem(wnd, IDC_TREE);
				HWND wnd_combo = m_import ? NULL : GetDlgItem(wnd, IDC_DEST);
				SetWindowLongPtr(wnd_tree, GWL_STYLE, GetWindowLongPtr(wnd_tree, GWL_STYLE)|TVS_CHECKBOXES);

				uih::SetTreeViewWindowExplorerTheme(wnd_tree);

				if (wnd_combo)
				{
					ComboBox_AddString(wnd_combo, L"Any foobar2000 installation");
					ComboBox_AddString(wnd_combo, L"This foobar2000 installation");
					ComboBox_SetCurSel(wnd_combo, 0);
				}

				SendMessage(wnd_tree, WM_SETREDRAW, FALSE, 0);
				TreeView_SetItemHeight(wnd_tree, TreeView_GetItemHeight(wnd_tree)+2);

				cui::fcl::group_list m_groups;
				if (m_import)
				{
					cui::fcl::dataset_list datasets;
					pfc::list_t<GUID> groupslist;
					t_size j, count = datasets.get_count();
					for (j=0; j<count; j++)
					{
						if (m_filter.have_item(datasets[j]->get_guid()))
						{
							GUID guid = datasets[j]->get_group();
							if (!groupslist.have_item(guid))
								groupslist.add_item(guid);

							cui::fcl::group_ptr ptr;
							while (m_groups.find_by_guid(guid, ptr))
							{
								guid = ptr->get_parent_guid();
								if (guid != pfc::guid_null)
									if (!groupslist.have_item(guid))
										groupslist.add_item(guid);
								else break;

							}
						}
					}
					t_size i = m_groups.get_count();
					for (; i; i--)
						if (!groupslist.have_item(m_groups[i-1]->get_guid()))
							m_groups.remove_by_idx(i-1);
				}
				m_groups.sort_by_name();
				cui::fcl::group_list_filtered filtered(m_groups, pfc::guid_null);
				g_populate_tree(wnd_tree, m_groups, filtered);

				SendMessage(wnd_tree, WM_SETREDRAW, TRUE, 0);
				RedrawWindow(wnd_tree,NULL,NULL,RDW_INVALIDATE|RDW_UPDATENOW);
			}
			return TRUE;
		case WM_COMMAND:
			switch (wp)
			{
			case IDOK:
				{
					HWND wnd_tree = GetDlgItem(wnd, IDC_TREE);
					t_size i, count = m_nodes.get_count();
					for (i=0; i<count; i++)
					{
						m_nodes[i].checked = 0 != TreeView_GetCheckState(wnd_tree, m_nodes[i].item);
					}
					HWND wnd_combo = m_import ? NULL : GetDlgItem(wnd, IDC_DEST);
					if (wnd_combo)
					{
						m_mode = ComboBox_GetCurSel(wnd_combo);
					}
				}
				EndDialog(wnd, 1);
				return FALSE;
			case IDCANCEL:
				EndDialog(wnd, 0);
				return FALSE;
			}
			break;
		case WM_CLOSE:
			EndDialog(wnd, 0);
			return 0;
		case WM_DESTROY:
			{
				HWND wnd_tree = GetDlgItem(wnd, IDC_TREE);
				HIMAGELIST il = TreeView_GetImageList(wnd_tree, TVSIL_STATE);
				TreeView_SetImageList(wnd_tree, NULL, TVSIL_STATE);
				ImageList_Destroy(il);
				DestroyWindow(wnd_tree);
			}
			break;
		case WM_NCDESTROY:
			break;
		}

		return FALSE;
	}
コード例 #10
0
void __fastcall TForm1::btnModifyClick(TObject *Sender)
{
if(tvConnectDev->Selected == NULL) return;
    DEVICE_STATUS devStatusInfo;
    String strInfo;
    VersionInfo versionInfo;
    NetParams oldParams, newParams;

    String strIP, strMask, strGate, strMAC;
    strIP = edtDevIP->Text;
    strMask = edtMask->Text;
    strGate = edtGate->Text;
    //strMAC = edtMAC->Text;

    memset(newParams.ucDeviceIP, 0, 16);
    memcpy(newParams.ucDeviceIP, strIP.c_str(), strIP.Length());

    memset(newParams.ucMaskIP, 0, 16);
    memcpy(newParams.ucMaskIP, strMask.c_str(), strMask.Length());

    memset(newParams.ucGateIP, 0, 16);
    memcpy(newParams.ucGateIP, strGate.c_str(), strGate.Length());

    //strMAC.Delete(3 ,1);
    //strMAC.Delete(5 ,1);
    //strMAC.Delete(7 ,1);
    //strMAC.Delete(9 ,1);
    //strMAC.Delete(11 ,1);
    //memset(newParams.ucMac, 0, 6);
    //HexToBin(strMAC.c_str(), newParams.ucMac, 6);

    PDevInfo pDev = NULL;
    TTreeNodes *nodes = tvConnectDev->Items;
    if(nodes != NULL)
    {
        for(int i = 0; i < nodes->Count; i++)
        {
            if(TreeView_GetCheckState(tvConnectDev->Handle,nodes->Item[i]->ItemId))
            {
                String strViewIP = nodes->Item[i]->Text;
                for(int j = 0; j < pDevList->Count; j++)
                {
                    pDev = PDevInfo(pDevList->Items[j]);
                    if(pDev != NULL)
                    {
                        String strDevListIP;
                        strDevListIP.sprintf("%s", pDev->ucIP);
                        if(strDevListIP == strViewIP)
                        {   if(pDev->pHandle != NULL)
                            {
                                int nRes = SetNetParams(pDev->pHandle, &oldParams, &newParams);
                                if(nRes != 0) ShowMessage("修改网络参数失败,返回值 = " + IntToStr(nRes));
                                else ShowMessage("修改网络参数成功");

                                return;
                            }
                        }
                    }
                }

                
            }
            else
            {
                edtDevIP->Text = "";
                edtMask->Text = "";
                edtGate->Text = "";
                //edtMAC->Text = "";
            }
        }
    }
}
コード例 #11
0
// 抓拍数据
void CALLBACK VehicleDataCallbackFuc(void *pUserData, VehicleData *pData)
{
    TForm1 *pThis = (TForm1 *)pUserData;
    if(pThis->tvConnectDev->Selected == NULL) return;

    String strIP;
    bool bFlag = false;
    PDevInfo pDev = NULL;
    TTreeNodes *nodes = pThis->tvConnectDev->Items;
    if(nodes != NULL)
    {
        for(int i = 0; i < nodes->Count; i++)
        {
            if(TreeView_GetCheckState(pThis->tvConnectDev->Handle,nodes->Item[i]->ItemId))
            {
                String strViewIP = nodes->Item[i]->Text;

                // 只显示指定抓拍的设备数据
                strIP.sprintf("%s", pData->ucDeviceIP);
                if(strIP == strViewIP)
                {
                    bFlag = true;
                    break;
                }
            }
        }
    }

     if(!bFlag) return;


     int nColor = pData->PlateColor;
     TDateTime dataTime = Now();
     SYSTEMTIME tm;
     GetSystemTime(&tm);

     String strPlate = (char *)pData->ucPlate;

     String strPath;
     String strBigFile, strCifFile, strPlateFile, strPlateNoFile;
     int iFileHandle = 0;

     // 大图
     if(pData->pucBigImage != NULL && pData->uiBigImageLen > 0)
     {
        strPath = pThis->strImagePath + strIP + "\\大图\\" + FormatDateTime("yyyymmdd", dataTime) + "\\";
        pThis->CreateDirectoryRecurrent(strPath);
        strBigFile = Format("%s%s%03d(%s).jpg", ARRAYOFCONST((strPath, dataTime.FormatString("hhmmss"), tm.wMilliseconds, strPlate)));
        iFileHandle = FileCreate(strBigFile);
        if(iFileHandle != 0)
        {
            FileWrite(iFileHandle, pData->pucBigImage, pData->uiBigImageLen);
            FileClose(iFileHandle);

            if(FileExists(strBigFile))
            {
                pThis->imgBigImg->Picture->LoadFromFile(strBigFile);
            }
        }
     }

     // CIF图
     if(pData->pucCIFImage != NULL && pData->uiCIFImageLen > 0)
     {
        strPath = pThis->strImagePath + strIP + "\\CIF图\\" + dataTime.FormatString("yyyymmdd") + "\\";
        pThis->CreateDirectoryRecurrent(strPath);
        strCifFile = Format("%s%s%03d(%s).jpg", ARRAYOFCONST((strPath, dataTime.FormatString("hhmmss"), tm.wMilliseconds, strPlate)));
        iFileHandle = FileCreate(strCifFile);
        if(iFileHandle != 0)
        {
            FileWrite(iFileHandle, pData->pucCIFImage, pData->uiCIFImageLen);
            FileClose(iFileHandle);

            if(FileExists(strCifFile))
            {
                pThis->imgCIFImg->Picture->LoadFromFile(strCifFile);
            }
        }
     }
     // 车牌图
     if(pData->pucPlateImage != NULL && pData->uiPlateImageLen > 0)
     {
        strPath = pThis->strImagePath + strIP + "\\车牌图\\" + dataTime.FormatString("yyyymmdd") + "\\";
        pThis->CreateDirectoryRecurrent(strPath);
        strPlateFile = Format("%s%s%03d(%s).jpg", ARRAYOFCONST((strPath, dataTime.FormatString("hhmmss"), tm.wMilliseconds, strPlate)));
        iFileHandle = FileCreate(strPlateFile);
        if(iFileHandle != 0)
        {
            FileWrite(iFileHandle, pData->pucPlateImage, pData->uiPlateImageLen);
            FileClose(iFileHandle);
        }

        if(FileExists(strPlateFile))
        {
            pThis->imgPlateImg->Picture->LoadFromFile(strPlateFile);
        }
     }

     // 车牌号码
     pThis->ShowPlate(strPlate, nColor);

}
コード例 #12
0
ファイル: buttonsbar.cpp プロジェクト: 0xmono/miranda-ng
static int SaveTree(HWND hToolBarTree)
{
	bool RSide = false;
	int count = 10;
	DWORD loc_sepcout = 0;
	TCHAR strbuf[128];

	TVITEM tvi;
	tvi.mask = TVIF_TEXT | TVIF_PARAM | TVIF_HANDLE;
	tvi.hItem = TreeView_GetRoot(hToolBarTree);
	tvi.pszText = strbuf;
	tvi.cchTextMax = sizeof(strbuf);
	{
		mir_cslock lck(ToolBarCS);

		while (tvi.hItem != NULL) {
			TreeView_GetItem(hToolBarTree, &tvi);

			if (_tcscmp(tvi.pszText, MIDDLE_SEPARATOR) == 0) {
				RSide = true;
				count = TreeView_GetCount(hToolBarTree) * 10 - count;
				tvi.hItem = TreeView_GetNextSibling(hToolBarTree, tvi.hItem);
				continue;
			}
			CustomButtonData *cbd = (CustomButtonData*)tvi.lParam;
			if (cbd) {
				if (cbd->opFlags) {
					cbd->bIMButton = (cbd->opFlags & BBSF_IMBUTTON) != 0;
					cbd->bChatButton = (cbd->opFlags & BBSF_CHATBUTTON) != 0;
					cbd->bCanBeHidden = (cbd->opFlags & BBSF_CANBEHIDDEN) != 0;
				}
				if (RSide && cbd->bLSided) {
					cbd->bLSided = false;
					cbd->bRSided = true;
					cbd->opFlags |= BBSF_NTBSWAPED;
				}
				else if (!RSide && cbd->bRSided) {
					cbd->bLSided = true;
					cbd->bRSided = false;
					cbd->opFlags |= BBSF_NTBSWAPED;
				}
				if (!TreeView_GetCheckState(hToolBarTree, tvi.hItem)) {
					cbd->bIMButton = false;
					cbd->bChatButton = false;

					if (cbd->bSeparator && !strcmp(cbd->pszModuleName, "Tabsrmm_sep"))
						cbd->opFlags = BBSF_NTBDESTRUCT;
				}
				else {
					if (!cbd->bIMButton && !cbd->bChatButton)
						cbd->bIMButton = true;
					if (cbd->bSeparator && !strcmp(cbd->pszModuleName, "Tabsrmm_sep")) {
						cbd->bHidden = 0;
						cbd->opFlags &= ~BBSF_NTBDESTRUCT;
						++loc_sepcout;
					}
				}

				cbd->dwPosition = (DWORD)count;
				CB_WriteButtonSettings(NULL, cbd);

				if (!(cbd->opFlags & BBSF_NTBDESTRUCT))
					(RSide) ? (count -= 10) : (count += 10);
			}
			
			HTREEITEM hItem = TreeView_GetNextSibling(hToolBarTree, tvi.hItem);
			if (cbd->opFlags & BBSF_NTBDESTRUCT)
				TreeView_DeleteItem(hToolBarTree, tvi.hItem);
			tvi.hItem = hItem;
		}

		qsort(LButtonsList.getArray(), LButtonsList.getCount(), sizeof(void*), sstSortButtons);
		qsort(RButtonsList.getArray(), RButtonsList.getCount(), sizeof(void*), sstSortButtons);
	}
	db_set_dw(0, "TabSRMM_Toolbar", "SeparatorsCount", loc_sepcout);
	dwSepCount = loc_sepcout;
	return 1;
}
コード例 #13
0
ファイル: buttonsbar.cpp プロジェクト: 0xmono/miranda-ng
INT_PTR CALLBACK DlgProcToolBar(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	HTREEITEM hti;

	switch (uMsg) {
	case WM_INITDIALOG:
		hToolBarTree = GetDlgItem(hwndDlg, IDC_TOOLBARTREE);
		{
			LONG_PTR style = GetWindowLongPtr(hToolBarTree, GWL_STYLE);
			style ^= TVS_CHECKBOXES;
			SetWindowLongPtr(hToolBarTree, GWL_STYLE, style);
			style |= TVS_CHECKBOXES;
			style |= TVS_NOHSCROLL;
			SetWindowLongPtr(hToolBarTree, GWL_STYLE, style);
		}
		{
			mir_cslock lck(ToolBarCS);
			BuildMenuObjectsTree(hToolBarTree);
		}

		Utils::enableDlgControl(hwndDlg, IDC_IMCHECK, FALSE);
		Utils::enableDlgControl(hwndDlg, IDC_CHATCHECK, FALSE);
		Utils::enableDlgControl(hwndDlg, IDC_CANBEHIDDEN, FALSE);

		SendDlgItemMessage(hwndDlg, IDC_SPIN1, UDM_SETRANGE, 0, MAKELONG(10, 0));
		SendDlgItemMessage(hwndDlg, IDC_SPIN1, UDM_SETPOS, 0, MAKELONG(PluginConfig.g_iButtonsBarGap, 0));
		TranslateDialogDefault(hwndDlg);
		bOptionsInit = FALSE;
		break;

	case WM_LBUTTONUP:
		if (drag) {
			TreeView_SetInsertMark(hToolBarTree, NULL, 0);
			drag = 0;
			ReleaseCapture();

			TVHITTESTINFO hti;
			hti.pt.x = (short)LOWORD(lParam);
			hti.pt.y = (short)HIWORD(lParam);
			ClientToScreen(hwndDlg, &hti.pt);
			ScreenToClient(hToolBarTree, &hti.pt);
			hti.pt.y -= TreeView_GetItemHeight(hToolBarTree) / 2;
			TreeView_HitTest(hToolBarTree, &hti);
			if (hDragItem == hti.hItem) break;
			if (hti.flags & TVHT_ABOVE)
				hti.hItem = TVI_FIRST;

			TVITEM tvi;
			tvi.mask = TVIF_HANDLE | TVIF_PARAM;
			tvi.hItem = (HTREEITEM)hDragItem;
			TreeView_GetItem(hToolBarTree, &tvi);
			if (hti.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT) || (hti.hItem == TVI_FIRST)) {
				TVINSERTSTRUCT tvis;
				TCHAR strbuf[128];
				tvis.item.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_STATE;
				tvis.item.stateMask = 0xFFFFFFFF;
				tvis.item.pszText = strbuf;
				tvis.item.cchTextMax = sizeof(strbuf);
				tvis.item.hItem = (HTREEITEM)hDragItem;
				TreeView_GetItem(hToolBarTree, &tvis.item);
				TreeView_DeleteItem(hToolBarTree, hDragItem);
				tvis.hParent = NULL;
				tvis.hInsertAfter = hti.hItem;
				TreeView_SelectItem(hToolBarTree, TreeView_InsertItem(hToolBarTree, &tvis));
				SendMessage((GetParent(hwndDlg)), PSM_CHANGED, 0, 0);
			}
		}
		break;

	case WM_MOUSEMOVE:
		if (drag) {
			TVHITTESTINFO hti;
			hti.pt.x = (short)LOWORD(lParam);
			hti.pt.y = (short)HIWORD(lParam);
			ClientToScreen(hwndDlg, &hti.pt);
			ScreenToClient(hToolBarTree, &hti.pt);
			TreeView_HitTest(hToolBarTree, &hti);
			if (hti.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT)) {
				HTREEITEM it = hti.hItem;
				hti.pt.y -= TreeView_GetItemHeight(hToolBarTree) / 2;
				TreeView_HitTest(hToolBarTree, &hti);
				if (!(hti.flags & TVHT_ABOVE))
					TreeView_SetInsertMark(hToolBarTree, hti.hItem, 1);
				else
					TreeView_SetInsertMark(hToolBarTree, it, 0);
			}
			else {
				if (hti.flags & TVHT_ABOVE) SendMessage(hToolBarTree, WM_VSCROLL, MAKEWPARAM(SB_LINEUP, 0), 0);
				if (hti.flags & TVHT_BELOW) SendMessage(hToolBarTree, WM_VSCROLL, MAKEWPARAM(SB_LINEDOWN, 0), 0);
				TreeView_SetInsertMark(hToolBarTree, NULL, 0);
			}
		}
		break;

	case WM_COMMAND:
		if (HIWORD(wParam) == BN_CLICKED && GetFocus() == (HWND)lParam && (HWND)lParam != hToolBarTree)
			SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
		if ((HIWORD(wParam) == EN_CHANGE) && ((HWND)lParam == GetFocus()))
			if (!bOptionsInit)
				SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);

		switch (LOWORD(wParam)) {
		case IDC_BBRESET:
			CallService(MS_DB_MODULE_DELETE, NULL, LPARAM("TabSRMM_Toolbar"));
			CB_HardReInit();
			BuildMenuObjectsTree(hToolBarTree);
			break;

		case IDC_SEPARATOR:
			hti = TreeView_GetSelection(hToolBarTree);
			if (!hti)
				hti = TVI_FIRST;

			CustomButtonData *cbd = new CustomButtonData();
			cbd->bSeparator = cbd->bHidden = cbd->bIMButton = cbd->bLSided = true;
			cbd->dwButtonOrigID = ++dwSepCount;
			cbd->pszModuleName = "Tabsrmm_sep";
			cbd->iButtonWidth = 22;
			cbd->opFlags = BBSF_NTBDESTRUCT;
			LButtonsList.insert(cbd);

			TVINSERTSTRUCT tvis;
			tvis.hParent = NULL;
			tvis.hInsertAfter = hti;
			tvis.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;

			tvis.item.pszText = TranslateT("<Separator>");
			tvis.item.iImage = tvis.item.iSelectedImage = -1;
			tvis.item.lParam = (LPARAM)cbd;
			hti = TreeView_InsertItem(hToolBarTree, &tvis);

			TreeView_SetCheckState(hToolBarTree, hti, (cbd->bIMButton || cbd->bChatButton));
		}
		break;

	case WM_NOTIFY:
		switch (((LPNMHDR)lParam)->idFrom) {
		case 0:
			switch (((LPNMHDR)lParam)->code) {
			case PSN_RESET:
				CB_ReInitCustomButtons();
				dwSepCount = M.GetDword("TabSRMM_Toolbar", "SeparatorsCount", 0);
				return 1;

			case PSN_APPLY:
				hti = TreeView_GetSelection(hToolBarTree);
				if (hti) {
					TVITEM tvi;
					tvi.mask = TVIF_HANDLE | TVIF_PARAM;
					tvi.hItem = hti;
					TreeView_GetItem(hToolBarTree, &tvi);

					if (tvi.lParam) {
						CustomButtonData *cbd = (CustomButtonData*)tvi.lParam;
						if (cbd) {
							cbd->bIMButton = IsDlgButtonChecked(hwndDlg, IDC_IMCHECK) != 0;
							cbd->bChatButton = IsDlgButtonChecked(hwndDlg, IDC_CHATCHECK) != 0;
							cbd->bCanBeHidden = IsDlgButtonChecked(hwndDlg, IDC_CANBEHIDDEN) != 0;
						}
					}
				}

				SaveTree(hToolBarTree);
				CB_ReInitCustomButtons();
				PluginConfig.g_iButtonsBarGap = (BYTE)SendDlgItemMessage(hwndDlg, IDC_SPIN1, UDM_GETPOS, 0, 0);

				if (PluginConfig.g_iButtonsBarGap != M.GetByte("ButtonsBarGap", 1))
					M.BroadcastMessageAsync(WM_SIZE, 0, 0);

				db_set_b(0, SRMSGMOD_T, "ButtonsBarGap", PluginConfig.g_iButtonsBarGap);

				BuildMenuObjectsTree((HWND)hToolBarTree);
				Utils::enableDlgControl(hwndDlg, IDC_IMCHECK, FALSE);
				Utils::enableDlgControl(hwndDlg, IDC_CHATCHECK, FALSE);
				Utils::enableDlgControl(hwndDlg, IDC_CANBEHIDDEN, FALSE);
				return 1;
			}
			break;

		case IDC_TOOLBARTREE:
			switch (((LPNMHDR)lParam)->code) {
			case TVN_BEGINDRAGA:
			case TVN_BEGINDRAGW:
				SetCapture(hwndDlg);
				drag = 1;
				hDragItem = ((LPNMTREEVIEW)lParam)->itemNew.hItem;
				TreeView_SelectItem(hToolBarTree, hDragItem);
				break;

			case TVN_SELCHANGINGA:
			case TVN_SELCHANGINGW:
				hti = TreeView_GetSelection(hToolBarTree);
				if (hti != NULL) {
					TCHAR strbuf[128];

					TVITEM tvi;
					tvi.hItem = hti;
					tvi.pszText = strbuf;
					tvi.cchTextMax = sizeof(strbuf);
					tvi.mask = TVIF_TEXT | TVIF_HANDLE | TVIF_PARAM;
					TreeView_GetItem(hToolBarTree, &tvi);

					if (tvi.lParam == 0 || !TreeView_GetCheckState(hToolBarTree, tvi.hItem) || !_tcscmp(tvi.pszText, MIDDLE_SEPARATOR))
						break;

					CustomButtonData *cbd = (CustomButtonData*)tvi.lParam;
					if (cbd) {
						cbd->opFlags = (IsDlgButtonChecked(hwndDlg, IDC_IMCHECK)) ? BBSF_IMBUTTON : 0;
						cbd->opFlags |= (IsDlgButtonChecked(hwndDlg, IDC_CHATCHECK)) ? BBSF_CHATBUTTON : 0;
						cbd->opFlags |= (IsDlgButtonChecked(hwndDlg, IDC_CANBEHIDDEN)) ? BBSF_CANBEHIDDEN : 0;

						cbd->bIMButton = (IsDlgButtonChecked(hwndDlg, IDC_IMCHECK) ? TRUE : FALSE);
						cbd->bChatButton = (IsDlgButtonChecked(hwndDlg, IDC_CHATCHECK) ? TRUE : FALSE);
						cbd->bCanBeHidden = (IsDlgButtonChecked(hwndDlg, IDC_CANBEHIDDEN) ? TRUE : FALSE);
					}
				}
				break;

			case TVN_SELCHANGEDW:
			case TVN_SELCHANGEDA:
				hti = TreeView_GetSelection(hToolBarTree);
				if (hti != NULL) {
					TCHAR strbuf[128];

					TVITEM tvi;
					tvi.pszText = strbuf;
					tvi.cchTextMax = sizeof(strbuf);
					tvi.mask = TVIF_TEXT | TVIF_HANDLE | TVIF_PARAM;
					tvi.hItem = hti;
					TreeView_GetItem(hToolBarTree, &tvi);

					if (!TreeView_GetCheckState(hToolBarTree, tvi.hItem) || !_tcscmp(tvi.pszText, MIDDLE_SEPARATOR)) {
						Utils::enableDlgControl(hwndDlg, IDC_IMCHECK, FALSE);
						Utils::enableDlgControl(hwndDlg, IDC_CHATCHECK, FALSE);
						Utils::enableDlgControl(hwndDlg, IDC_CANBEHIDDEN, FALSE);
						break;
					}

					if (tvi.lParam == 0)
						break;

					CustomButtonData *cbd = (CustomButtonData*)tvi.lParam;
					if (cbd) {
						Utils::enableDlgControl(hwndDlg, IDC_IMCHECK, TRUE);
						Utils::enableDlgControl(hwndDlg, IDC_CHATCHECK, TRUE);
						Utils::enableDlgControl(hwndDlg, IDC_CANBEHIDDEN, TRUE);
						CheckDlgButton(hwndDlg, IDC_IMCHECK, (cbd->bIMButton) ? 1 : 0);
						CheckDlgButton(hwndDlg, IDC_CHATCHECK, (cbd->bChatButton) ? 1 : 0);
						CheckDlgButton(hwndDlg, IDC_CANBEHIDDEN, (cbd->bCanBeHidden) ? 1 : 0);
					}
				}
				break;

			case NM_CLICK:
				TVHITTESTINFO hti = { 0 };
				GetCursorPos(&hti.pt);
				ScreenToClient(hToolBarTree, &hti.pt);
				if (TreeView_HitTest(hToolBarTree, &hti)) {
					if (hti.flags&TVHT_ONITEMSTATEICON) {
						SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0);
						if (TreeView_GetCheckState(hToolBarTree, hti.hItem)) {
							Utils::enableDlgControl(hwndDlg, IDC_IMCHECK, FALSE);
							Utils::enableDlgControl(hwndDlg, IDC_CHATCHECK, FALSE);
							Utils::enableDlgControl(hwndDlg, IDC_CANBEHIDDEN, FALSE);
							CheckDlgButton(hwndDlg, IDC_IMCHECK, 1);
						}
						else {
							Utils::enableDlgControl(hwndDlg, IDC_IMCHECK, TRUE);
							Utils::enableDlgControl(hwndDlg, IDC_CHATCHECK, TRUE);
							Utils::enableDlgControl(hwndDlg, IDC_CANBEHIDDEN, TRUE);
						}
						TreeView_SelectItem(hToolBarTree, hti.hItem);
					}
				}
			}
		}
		break;

	case WM_DESTROY:
		HIMAGELIST hIml = TreeView_GetImageList(GetDlgItem(hwndDlg, IDC_TOOLBARTREE), TVSIL_NORMAL);
		ImageList_Destroy(hIml);
		hIml = TreeView_GetImageList(GetDlgItem(hwndDlg, IDC_TOOLBARTREE), TVSIL_STATE);
		ImageList_Destroy(hIml);
		break;
	}

	return FALSE;
}