Esempio n. 1
0
CString CDirTreeCtrl::GetFullPath(HTREEITEM hItem)
{
	// get the Full Path of the item
	CString strReturn;
	CString strTemp;
	HTREEITEM hParent = hItem;

	strReturn = "";

	while ( hParent )
	{
		
		strTemp  = GetItemText( hParent );
		strTemp += "\\";
		strReturn = strTemp + strReturn;
		hParent = GetParentItem( hParent );
	}
    
	strReturn.TrimRight( '\\' );

    return strReturn;

}
Esempio n. 2
0
void CDownloads_Groups::OnSelchanged(NMHDR*, LRESULT* pResult) 
{
	
	HTREEITEM hItem = GetSelectedItem ();
	HTREEITEM hParent = GetParentItem (hItem);

	if (hItem == m_hHistory || hParent == m_hHistory)
	{
		if (hItem == m_hHistCustom)
			CustomizeHistoryFilter (); 

		_pwndDownloads->Set_DWWN (DWWN_HISTORY);
		fsDldHistRecFilter* f = (fsDldHistRecFilter*) GetItemData (hItem);
		_pwndDownloads->m_wndHistory.ApplyFilter (f);
	}
	else if (hItem == m_hDeleted)
	{
		_pwndDownloads->Set_DWWN (DWWN_DELETED);
	}
	else
	{
		
		fsDldFilter* filter = (fsDldFilter*) GetItemData (hItem);
		_pwndDownloads->Set_DWWN (DWWN_LISTOFDOWNLOADS);
		
		if (filter->GetType () == DFT_GROUP)
			_App.View_DownloadsGroups_SelectedFilterId (((fsDldGroupFilter*)filter)->GetGroup ()->nId);
		else if (hItem == m_hTasks)
			_App.View_DownloadsGroups_SelectedFilterId (-2);
		else if (hItem == m_hAllGroups)
			_App.View_DownloadsGroups_SelectedFilterId (-1);
		
		_pwndDownloads->FilterDownloads (filter);	
	}

	*pResult = 0;
}
Esempio n. 3
0
//获取关系
BYTE CUserCompanionList::GetTreeItemCompanion(HTREEITEM hTreeItem)
{
	//效验参数
	ASSERT(hTreeItem!=NULL);
	if (hTreeItem==NULL) return enCompanion_UnKnow;

	//上溯搜索
	do
	{
		//目标判断
		if (hTreeItem==m_hItemDetest) return enCompanion_Detest;
		if (hTreeItem==m_hItemFriend) return enCompanion_Friend;
		if (hTreeItem==m_hItemNormal) return enCompanion_UnKnow;

		//获取父项
		hTreeItem=GetParentItem(hTreeItem);

	} while (hTreeItem!=NULL);

	//错误断言
	ASSERT(FALSE);

	return enCompanion_UnKnow;
}
Esempio n. 4
0
VOID CEasySkinTreeCtrl::DrawTreeItem( CDC * pDC, CRect & rcClient, CRect & rcClipBox )
{
	//首项判断
	HTREEITEM hItemCurrent=GetFirstVisibleItem();
	if (hItemCurrent==NULL) return;

	//获取属性
	UINT uTreeStyte = GetStyle();

	//绘画子项
	do
	{
		//变量定义
		CRect rcItem;
		CRect rcRect;

		//获取状态
		HTREEITEM hParent=GetParentItem(hItemCurrent);
		UINT uItemState=GetItemState(hItemCurrent,TVIF_STATE);

		//获取属性
		bool bDrawChildren=(ItemHasChildren(hItemCurrent)==TRUE);
		bool bDrawSelected=(uItemState&TVIS_SELECTED)&&((this==GetFocus())||(uTreeStyte&TVS_SHOWSELALWAYS));

		//获取区域
		if (GetItemRect(hItemCurrent,rcItem,TRUE))
		{
			//绘画过滤
			if (rcItem.top>=rcClient.bottom) break;
			if (rcItem.top>=rcClipBox.bottom) continue;

			//设置位置
			rcRect.left=0;
			rcRect.top=rcItem.top+1;
			rcRect.bottom=rcItem.bottom;
			rcRect.right=rcClient.Width();

			//绘画选择
			if (bDrawSelected)
			{
				if (m_pPressImg != NULL && !m_pPressImg->IsNull())
					m_pPressImg->Draw(pDC,rcRect);
				else
					pDC->FillSolidRect(&rcRect,m_colPress);
			}

			//绘画经过
 			if ((bDrawSelected==false)&&(m_hItemMouseHover==hItemCurrent))
 			{
				if (m_pHovenImg != NULL && !m_pHovenImg->IsNull())
					m_pHovenImg->Draw(pDC,rcRect);
				else
 					pDC->FillSolidRect(&rcRect,m_colHoven);
 			}

			//绘制箭头
 			if (bDrawChildren && (uTreeStyte&TVS_HASBUTTONS) )
 			{
				if (m_pImageButton != NULL && !m_pImageButton->IsNull())
				{
					//计算位置
					INT nXPos=rcItem.left-m_pImageButton->GetWidth()/2;
					INT nYPos=rcItem.top+1+(rcItem.Height()-m_pImageButton->GetHeight())/2;

					//绘画图标
					INT nIndex=(uItemState&TVIS_EXPANDED)?1L:0L;
					m_pImageButton->DrawImage(pDC,nXPos,nYPos,m_pImageButton->GetWidth()/2,m_pImageButton->GetHeight(),nIndex*m_pImageButton->GetWidth()/2,0);
				
					rcItem.left += m_pImageButton->GetWidth();
					rcItem.right += m_pImageButton->GetWidth();;
				}

 			}

			//绘制列表
			DrawListImage(pDC,rcItem,hItemCurrent,bDrawSelected);	

			//绘制文本
			DrawItemString(pDC,rcItem,hItemCurrent,bDrawSelected);
		}
	} while ((hItemCurrent=GetNextVisibleItem(hItemCurrent))!= NULL);
}
Esempio n. 5
0
// add one item to selection set, or remove it	
BOOL CMultiSelTreeCtrl::SetSelectState(HTREEITEM item, BOOL selected)
{
//	ASSERT(item != NULL);	// Can't ASSERT here! When called from context menu click below any changes, there is no 'item'
	if(item==NULL)
		return FALSE;

	HTREEITEM parent=GetParentItem(item);
	int index = SelectionToIndex(item);
	BOOL found = index != -1;
	BOOL success=TRUE;

	if(found && !selected)  
	{
		// Clear the selected appearance for this item
		success=SetItemState(item, 0, TVIS_CUT | TVIS_BOLD | TVIS_SELECTED);

		// and remove item from selection set
		if(success)
		{
			m_SelectionSet.RemoveAt(index);
			if(m_SelectionSet.GetSize()==0)
				SelectItem(NULL);
		}
	}
	else if(!found && selected)
	{
		// Set the appearance for this item
		success=SetItemState(item, m_SelectFlags, TVIS_CUT | TVIS_BOLD | TVIS_SELECTED);

		// and add it to selection set
		if(success)
		{
			m_SelectionSet.Add((DWORD) item);
			if (!m_ShiftDown && !m_MultiSelect)
				SelectItem(item);
		}
	}
	// !found && !selected --> select atts already correct
	// found && selected --> select atts already correct
	
	if(selected)
	{
		m_LastSelect=item;
		m_LastParent=parent;
	}
	else
	{
		if(m_SelectionSet.GetSize()==0)
			m_LastParent=m_LastSelect=NULL;
		else
		{
			if(found)
				// Only change m_LastSelect if we deleted a selected item
				m_LastSelect= (HTREEITEM) m_SelectionSet.GetAt(0);

			// m_LastParent must still be valid
			m_LastParent=GetParentItem(m_LastSelect);
		}
	}

	ShowNbrSelected();
	return success;
}
Esempio n. 6
0
// Draw TreeCtrl Items
void VividTree::DrawItems( CDC *pDC )
{
	// draw items
	HTREEITEM show_item, parent;
	CRect rc_item;
	CString name;
	COLORREF color;
	DWORD tree_style;
	BITMAP bm;
	CDC dc_mem;
	CBitmap *button;
	int count = 0;
	int state;
	bool selected;
	bool has_children;

	show_item = GetFirstVisibleItem();
	if ( show_item == NULL )
		return;

	dc_mem.CreateCompatibleDC(NULL);
	color = pDC->GetTextColor();
	tree_style = ::GetWindowLong( m_hWnd, GWL_STYLE ); 

	do
	{
		state = GetItemState( show_item, TVIF_STATE );
		parent = GetParentItem( show_item );
		has_children = ItemHasChildren( show_item ) || parent == NULL;
		selected = (state & TVIS_SELECTED) && ((this == GetFocus()) || 
				(tree_style & TVS_SHOWSELALWAYS));

		if ( GetItemRect( show_item, rc_item, TRUE ) )
		{
			if( selected)
			{
				CRect rc_all;
				GetItemRect(show_item,&rc_all, FALSE);
				pDC->FillSolidRect(&rc_all, RGB(170,155,119));
			}
			if ( has_children  || selected )
			{
				COLORREF from;
				CRect rect;
				// Show 
				if ( selected )
					from = m_gradient_bkgd_sel;
				else
					from = m_gradient_bkgd_to - (m_gradient_bkgd_from - m_gradient_bkgd_to);
				rect.top = rc_item.top;
				rect.bottom = rc_item.bottom;
				rect.right = m_h_size + m_h_offset;
				if ( !has_children )
					rect.left = rc_item.left + m_h_offset;
				else
					rect.left = m_h_offset;
				//GradientFillRect( pDC, rect, from, m_gradient_bkgd_to, FALSE );
				//pDC->SetTextColor( RGB( 0, 0, 255 ) );
				pDC->SetTextColor(GetSysColor(COLOR_HIGHLIGHTTEXT));

				if ( has_children )
				{
					// Draw an Open/Close button
					if ( state & TVIS_EXPANDED )
						button = &m_bmp_tree_open;
					else
						button = &m_bmp_tree_closed;
					VERIFY(button->GetObject(sizeof(bm), (LPVOID)&bm));
					CBitmap *bmp_old = (CBitmap*)dc_mem.SelectObject(button); 
					pDC->TransparentBlt(rc_item.left - bm.bmWidth - 2, rc_item.top, bm.bmWidth, bm.bmHeight, 
						&dc_mem, 0, 0,bm.bmWidth,bm.bmWidth, GetSysColor(COLOR_HIGHLIGHTTEXT));
					//pDC->BitBlt( rc_item.left - bm.bmWidth - 2, rc_item.top, bm.bmWidth, bm.bmHeight, 
					//	&dc_mem, 0, 0, SRCCOPY );
					// CleanUp
					dc_mem.SelectObject( bmp_old );
				}
			}
			if ( !has_children )
			{
				// lookup the ICON instance (if any) and draw it
				HICON icon;
				icon = GetItemIcon( show_item );
				if ( icon != NULL )
					DrawIconEx( pDC->m_hDC, rc_item.left - 18, rc_item.top, icon, 16, 16,0,0, DI_NORMAL );
			}
			name = GetItemText( show_item );
			rc_item.DeflateRect( 0,1,0,1 );
			if ( selected )
			{
				if ( !has_children  )
					pDC->SetTextColor( GetSysColor(COLOR_HIGHLIGHTTEXT) );
				COLORREF col = pDC->GetBkColor();
				//pDC->SetBkColor( /*GetSysColor(COLOR_HIGHLIGHT)*/RGB(170,155,119) );
				pDC->DrawText( name, rc_item, DT_LEFT );
				pDC->SetTextColor( color );
				pDC->SetBkColor( col );
			}
			else
			{
				pDC->SetTextColor( GetSysColor(COLOR_HIGHLIGHTTEXT) );
				pDC->DrawText( name, rc_item, DT_LEFT );
				pDC->SetTextColor( color );
			}
			//if ( state & TVIS_BOLD )
			//	pDC->SelectObject( font );
		}
	} while ( (show_item = GetNextVisibleItem( show_item )) != NULL );
}
void CEditTreeCtrl::SortCurrentLevelAndBelow(HTREEITEM hItem) {
	SortCurrentLevel(hItem);
	for(hItem = hItem ? GetChildItem(GetParentItem(hItem)) : GetRootItem(); hItem != 0; hItem = GetNextSiblingItem(hItem))
		if(ItemHasChildren(hItem))
			SortCurrentLevelAndBelow(GetChildItem(hItem));
}
Esempio n. 8
0
void CFileTreeCtrl::expandingItem(NMHDR *pNMHDR, LRESULT *pResult)
{
    LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR);

    HTREEITEM hItem = pNMTreeView->itemNew.hItem;
    UINT uiAction = pNMTreeView->action;

    HTREEITEM hChildItem = GetChildItem(hItem);
    CString sItemText = GetItemText(hItem);
    CString sChildText = GetItemText(hChildItem);

    if(uiAction == TVE_EXPAND)
    {
        if(GetParentItem(hItem) != NULL)
            setImage(hItem, sItemText, uiAction);

        if(sChildText.CompareNoCase(EMPTYITEM) == 0)
        {
            // Prepare for update
            SetRedraw(FALSE);
            SetCursor(LoadCursor(NULL, IDC_WAIT));

            HTREEITEM hParent = GetParentItem(hItem);
            DeleteItem(hChildItem);

            std::wstring sPath;
            if(getPath(hItem, sPath))
            {
                CFileSystem fileio;
                HTREEITEM hNewItem = NULL;
                PathInfo info;

                bool bContinue = fileio.findFirst(sPath, info);

                while(bContinue)
                {
                    if(info.Attributes & FILE_ATTRIBUTE_DIRECTORY)
                    {
                        hNewItem = InsertItem(info.sName.c_str(), hItem, TVI_LAST);
                        setImage(hNewItem, CString(info.sName.c_str()), uiAction);

                        if(fileio.hasDirectories(sPath + info.sName))
                        {
                            InsertItem(EMPTYITEM, hNewItem, TVI_LAST);
                        }

                        // Set item state to required colour
                        if(info.bCovert)
                            SetItemData(hNewItem, FILE_COVERT);
                        else
                            SetItemData(hNewItem, info.Attributes);
                    }

                    bContinue = fileio.findNext(info);
                }

                SortChildren(hItem);
                Expand(hItem, TVE_EXPAND);
            }

            // Update complete
            SetCursor(LoadCursor (NULL, IDC_ARROW));
            SetRedraw(TRUE);
        }
    }
    else if(uiAction == TVE_COLLAPSE)
    {
        if(GetParentItem(hItem) != NULL)
            setImage(hItem, sItemText, uiAction);
    }

    *pResult = 0;
}
Esempio n. 9
0
void CTreeView::CheckTreeItem(HTREEITEM hItem)
{
	SetCheckState(hItem, true);
	if (HTREEITEM hParent = GetParentItem(hItem))
		CheckTreeItem(hParent);
}
bool CEditTreeCtrl::IsAncestor(HTREEITEM hItem, HTREEITEM hCheck) const {
	for(HTREEITEM hParent = hCheck; hParent != 0; hParent = GetParentItem(hParent))
		if(hParent == hItem)
			return true;
	return false;
}
Esempio n. 11
0
void CZoneTree::OnMouseMove(UINT nFlags, CPoint point) 
{
	HTREEITEM	hitem;
	UINT		flags;
	HCURSOR     cur;
	POINT pt = point;
	int x , y;

	if(m_bLDragging) 
	{
		ClientToScreen( &pt );
		CImageList::DragMove(pt);
		
		if((hitem = HitTest(point, &flags)) != NULL) 
		{
			CImageList::DragShowNolock(FALSE);
			
			if(GetParentItem(hitem) == NULL) 
			{
				::SetCursor(cursor_no);
				SelectDropTarget(NULL);
			} 
			else 
			{
				GetItemImage(m_hitemDrag, x, x);
				GetItemImage(hitem, y, y);
				
				switch(x) 
				{
					case MOB_DATA: 
					case MOB_INDEX:
					{
						switch(y) 
						{
							case MOB_INDEX:
							case OBJ_INDEX:
							case OBJECT_DATA:
							case MOB_DATA:
							case ROOM_PARENT:
							case CONTENTS:
							case OBJ_PARENT:
							case MOB_PARENT:
								cur = cursor_no;
								break;
							default:
								cur = cursor_arr;
								break;
						}
						
					}
					break;
					case OBJECT_DATA:
					{
						switch(y) 
						{
							case PEOPLE:
							case OBJ_PARENT:
							case MOB_PARENT:
							case ROOM_PARENT:
							case MOB_INDEX:
							case MOB_DATA:
								cur = cursor_no;
								break;
							default:
								cur = cursor_arr;
								break;
						}
						
					}
					break;
					case OBJ_INDEX: 
					{
						switch(y) 
						{
							case PEOPLE:
							case OBJ_PARENT:
							case MOB_PARENT:
							case ROOM_PARENT:
							case MOB_INDEX:
							case MOB_DATA:
								cur = cursor_no;
								break;
							default:
								cur = cursor_arr;
								break;
						}
						
					}
					break;
				}
			}
			
			if(cur == cursor_arr && cursor_arr != ::GetCursor()) 
			{
				::SetCursor(cursor_arr);
				SelectDropTarget(hitem);
			} 
			else if(cur == cursor_no && cursor_no != ::GetCursor()) 
			{
				::SetCursor(cursor_no);
				SelectDropTarget(NULL);
			}

			m_hitemDrop = hitem;
			CImageList::DragShowNolock(TRUE);
		}
		
		CPoint pos;
		CRect rect;
		
		GetWindowRect(&rect);
		GetCursorPos(&pos);
		
		if(pos.y > rect.bottom)
			SendMessage(WM_VSCROLL, SB_LINEDOWN, 0);
		else if(pos.y < rect.top)
			SendMessage(WM_VSCROLL, SB_LINEUP, 0);
	} 
	else 
	{
		::SetCursor(cursor_arr);
	}

	CTreeCtrl::OnMouseMove(nFlags, point);	
}
Esempio n. 12
0
void CZoneTree::OnLButtonUp(UINT nFlags, CPoint point) 
{
	int i, x;

	CTreeCtrl::OnLButtonUp(nFlags, point);

	if (m_bLDragging)
	{
		m_bLDragging = FALSE;
		
		CImageList::DragLeave(this);
		CImageList::EndDrag();
		
		ReleaseCapture();
		GetItemImage(m_hitemDrag, i, i);

		if(m_pDragImage != NULL) 
		{ 
			delete m_pDragImage; 
			m_pDragImage = NULL; 
		} 

		// Remove drop target highlighting
		SelectDropTarget(NULL);

		if( m_hitemDrag == m_hitemDrop )
			return;

		HTREEITEM	hitem;
		
		// Make sure pt is over some item
		if (((hitem = HitTest(point, &nFlags)) == NULL)  ) 
			return;
		
		// If Drag item is an ancestor of Drop item then return
		HTREEITEM htiParent = m_hitemDrop;
		
		while( (htiParent = GetParentItem( htiParent )) != NULL )
		{
			if( htiParent == m_hitemDrag ) 
				return;
		}
		
		GetItemImage(m_hitemDrag, i, i);
		GetItemImage(m_hitemDrop, x, x);
		
		switch(i) 
		{
			case OBJ_INDEX: 
			case OBJECT_DATA:
			{
				switch(x) 
				{
					case ROOM_DATA:
					{
						room_data *room;
						room = (room_data*)GetItemData(m_hitemDrop);
						m_hitemDrop = room->m_tContents;
						break;
					}
					case CONTENTS:
						break;
					case OBJ_INDEX: 
					{
						obj_index *o_ind;
						
						o_ind = (obj_index*)GetItemData(m_hitemDrop);
						
						if(o_ind->IsContainer()) 
						{
							if(!o_ind->m_tContents) 
								o_ind->m_tContents = InsertItem("Contents", CONTENTS, CONTENTS, o_ind->m_tThis);
						
							m_hitemDrop = o_ind->m_tContents;
						} 
						else 
							return;
					}
					break;
					default: 
						return;
				}
			}
			break;
			case MOB_INDEX:
			case MOB_DATA: 
			{
				switch(x) 
				{
					case ROOM_DATA: 
					{
						room_data *room;
						
						room = (room_data*)GetItemData(m_hitemDrop);
						
						m_hitemDrop = room->m_tPeople;
						break;
					}
					case PEOPLE:
						break;
					default:
						return;
				}
				break;
			}
		}	

		Expand( m_hitemDrop, TVE_EXPAND );

		HTREEITEM htiNew = MoveChildItem( m_hitemDrag, m_hitemDrop, TVI_LAST );
		
		if(i == OBJ_INDEX || i == MOB_INDEX)
			DeleteItem(m_hitemDrag);
		
		SelectItem( htiNew );
	}
}
void COXNetBrowseTree::OnGetDispInfo(NMHDR* pNMHDR, LRESULT* pResult) 
{
	TV_DISPINFO* pTVDispInfo = (TV_DISPINFO*)pNMHDR;
	*pResult = 0;

	if (((pTVDispInfo->item.mask & TVIF_IMAGE) == TVIF_IMAGE) ||
		((pTVDispInfo->item.mask & TVIF_SELECTEDIMAGE) == TVIF_SELECTEDIMAGE))
	{
		// ... Start with unknown type
		int nImage = NET_IMAGE_UNKNOWN;
		// Get the associated net resource
		const NETRESOURCE* pNetResource = NULL;
		pNetResource = GetAssocNetResource(pTVDispInfo->item.hItem);
		if (pNetResource == NULL)
			return;

		switch(pNetResource->dwDisplayType)
		{
		case RESOURCEDISPLAYTYPE_GENERIC:
			nImage = NET_IMAGE_UNKNOWN;
			break;
		case RESOURCEDISPLAYTYPE_DOMAIN:
			nImage = NET_IMAGE_DOMAIN;
			break;
		case RESOURCEDISPLAYTYPE_SERVER:
			nImage = NET_IMAGE_SERVER;
			break;
		case RESOURCEDISPLAYTYPE_SHARE:
			{
				switch(pNetResource->dwType)
				{
				case RESOURCETYPE_DISK:
					nImage = NET_IMAGE_DISK_SHARE;
					break;
				case RESOURCETYPE_PRINT:
					nImage = NET_IMAGE_PRINTER_SHARE;
					break;
				default:
					nImage = NET_IMAGE_OTHER_SHARE;
					break;
				}
			}
			break;
		case RESOURCEDISPLAYTYPE_FILE:
			nImage = NET_IMAGE_FILE;
			break;
		case RESOURCEDISPLAYTYPE_GROUP:
			nImage = NET_IMAGE_GROUP;
			break;
		case RESOURCEDISPLAYTYPE_NETWORK:
			nImage = NET_IMAGE_NETWORK;
			break;
		case RESOURCEDISPLAYTYPE_ROOT:
			nImage = NET_IMAGE_ROOT;
			break;
		case RESOURCEDISPLAYTYPE_SHAREADMIN:
			nImage = NET_IMAGE_SHARADMIN;
			break;
		case RESOURCEDISPLAYTYPE_DIRECTORY:
			nImage = NET_IMAGE_DIRECTORY;
			break;
		case RESOURCEDISPLAYTYPE_TREE:
			nImage = NET_IMAGE_TREE;
			break;
		}

		// Under Windows NT 3.51 The root node of RESOURCE_GLOBALNET tree
		// has display type RESOURCEDISPLAYTYPE_GENERIC instead of RESOURCEDISPLAYTYPE_NETWORK
		// We will adjust for this here
		if ((OSVersion.dwMajorVersion < 4) &&
			(pNetResource->dwScope == RESOURCE_GLOBALNET) &&
			(GetParentItem(pTVDispInfo->item.hItem) == NULL))
		{
			nImage = NET_IMAGE_NETWORK;
		}

		// If the item is expanded, use the next image
		if ((GetItemState(pTVDispInfo->item.hItem, TVIS_EXPANDED) & TVIS_EXPANDED) == TVIS_EXPANDED)
			nImage++;

		// Return the result
		pTVDispInfo->item.iImage = nImage;
		pTVDispInfo->item.iSelectedImage = nImage;
	}
}
Esempio n. 14
0
void CZoneTree::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	CPoint pos;
	int i;
	HTREEITEM it;
	HTREEITEM contents;
	HTREEITEM parent;
	CWinDEDlg *dlg = (CWinDEDlg*)GetParent();

	GetCursorPos(&pos);

	if(nChar == VK_RETURN)    
	{       
		GetParent()->SetFocus();
		OnLButtonDblClk(nFlags, pos);
	}    
	else if(nChar == VK_DELETE)    
	{       
		it = GetSelectedItem();
		GetItemImage(it, i, i);
		switch(i) {
			case AREA_DATA:
				break;
			case ROOM_DATA: {
				room_data *room;
				room = (room_data*)GetItemData(it);
				dlg->DeleteRoom(room->vnum);
				break;
			}
			case MOB_DATA: {
				mob_data *mob;
				mob = (mob_data*)GetItemData(it);
				dlg->DeleteMob(mob->vnum);
				break;
			}
			case OBJECT_DATA: {
				object_data *obj;
				obj = (object_data*)GetItemData(it);
				dlg->DeleteObj(obj->vnum);
				break;
			}
			case MOB_INDEX: {
				mob_index *m_index;
				room_data *room;
				
				contents = GetParentItem(it);
				parent = GetParentItem(contents);
				
				m_index = (mob_index*)GetItemData(it);
				room = (room_data*)GetItemData(parent);
				
				room->RemovePerson(m_index);
				dlg->RemoveItem(m_index->m_tThis);

				delete m_index;
				break;
			}
			case OBJ_INDEX: {
				obj_index *o_index;
				o_index = (obj_index*)GetItemData(it);
				
				//get contents indexs parent item wich is the actual object
				contents = GetParentItem(it);
				parent = GetParentItem(contents);
				
				GetItemImage(parent, i, i);
				
				switch(i) {
					case OBJ_INDEX: {
						obj_index *o_parent;
						o_parent = (obj_index*)GetItemData(parent);
						o_parent->RemoveContent(&o_index);
						break;
					}
					case MOB_INDEX:
						break;
					case ROOM_DATA:
						room_data *room;
						room = (room_data*)GetItemData(parent);
						room->RemoveContent(o_index);
						break;
					case OBJECT_DATA: {
						object_data *obj_parent;
						obj_parent = (object_data*)GetItemData(parent);
						obj_parent->RemoveContent(o_index);
						break;
					}
					case MOB_DATA:
						break;
				}

				if(o_index)
					o_index->RemoveFromList();
				
				dlg->RemoveItem(it);
				break;
			}
		}
	}
}
BOOL CImageTreeCtrl::UpdateDataToDB(){
	_ConnectionPtr m_pCon;
	_RecordsetPtr m_pRs;
	::CoInitialize(NULL);
	try 
	{
		////////////////////////////////////////////////////////////////////////////////////////////
		//获取数据库名称及路径
		/////////////////////////////////////////////////////////////////////////////////////////////////
		//连接数据库
		m_pCon.CreateInstance("ADODB.Connection");
		m_pRs.CreateInstance(_T("ADODB.Recordset"));
		m_pCon->Open(g_strDatabasefilepath.GetString(),"","",adModeUnknown);
		CString strSql;   BOOL is_exist=FALSE;	  CString str_temp;
		switch (m_level)
		{
		case 0:  //Subnet
			{


				//strSql.Format(_T("select * from Building where Main_BuildingName = '%s'"),m_strMainBuildingName);
				strSql.Format(_T("select * from Building order by Main_BuildingName"));
				m_pRs->Open((_variant_t)strSql,_variant_t((IDispatch *)m_pCon,true),adOpenStatic,adLockOptimistic,adCmdText);

				while(VARIANT_FALSE==m_pRs->EndOfFile)
				{	   	 str_temp.Empty();
				str_temp=m_pRs->GetCollect("Building_Name");
				if (str_temp.Compare(m_name_new)==0)
				{	   is_exist=TRUE;
				break;
				}			
				m_pRs->MoveNext();
				}
				m_pRs->Close();
				if (!is_exist)	 //更新的名字在数据库中查找不到的
				{
					////////////先更新Building表/////////////////////
					//CString strSql;
					strSql.Format(_T("update Building set Building_Name='%s' where Building_Name='%s'"),m_name_new,m_name_old);
					//MessageBox(strSql);
					m_pCon->Execute(strSql.GetString(),NULL,adCmdText);

					strSql.Format(_T("select * from ALL_NODE where Building_Name='%s' order by Building_Name"),m_name_old);
					m_pRs->Open((_variant_t)strSql,_variant_t((IDispatch *)m_pCon,true),adOpenStatic,adLockOptimistic,adCmdText);
					while(VARIANT_FALSE==m_pRs->EndOfFile)
					{
						strSql.Format(_T("update ALL_NODE set Building_Name='%s' where Building_Name='%s'"),m_name_new,m_name_old);
						m_pCon->Execute(strSql.GetString(),NULL,adCmdText);
						m_pRs->MoveNext();
					}

					m_pRs->Close();
					return TRUE;
				}
				else
				{

					return FALSE;
				}

				break;	
			}
		case 1:		//Floor
			{	 // strSql=_T("select * from Building where Default_SubBuilding=-1");
				// m_pRs->Open((_variant_t)strSql,_variant_t((IDispatch *)m_pCon,true),adOpenStatic,adLockOptimistic,adCmdText);
				HTREEITEM parentnode=GetParentItem(m_hSelItem);

				CString subnetname=GetItemText(parentnode);//m_pRs->GetCollect("Building_Name");

				//  m_pRs->Close();
				strSql.Format(_T("select * from ALL_NODE where Building_Name='%s' and Floor_name='%s' order by Building_Name"),subnetname,m_name_new);
				m_pRs->Open((_variant_t)strSql,_variant_t((IDispatch *)m_pCon,true),adOpenStatic,adLockOptimistic,adCmdText);

				while(VARIANT_FALSE==m_pRs->EndOfFile)
				{	   	 str_temp.Empty();
				str_temp=m_pRs->GetCollect("Floor_name");
				if (str_temp.Compare(m_name_new)==0)
				{is_exist=TRUE;
				break;
				}			
				m_pRs->MoveNext();
				}
				m_pRs->Close();

				if (is_exist)
				{
					return FALSE;
				} 
				else
				{  	strSql.Format(_T("select * from ALL_NODE where Building_Name='%s' and Floor_name='%s' order by Building_Name"),subnetname,m_name_old);
				m_pRs->Open((_variant_t)strSql,_variant_t((IDispatch *)m_pCon,true),adOpenStatic,adLockOptimistic,adCmdText);
				while(VARIANT_FALSE==m_pRs->EndOfFile)
				{
					strSql.Format(_T("update ALL_NODE set Floor_name='%s' where Floor_name='%s'"),m_name_new,m_name_old);
					m_pCon->Execute(strSql.GetString(),NULL,adCmdText);
					m_pRs->MoveNext();
				}
				m_pRs->Close();
				return TRUE;
				}


				break;
			}
		case 2:		//Room
			{
				//Subnet
				HTREEITEM root=GetRootItem();
				CString subnetname=GetItemText(root);
				//Floor
				HTREEITEM parentnode=GetParentItem(m_hSelItem);
				CString Floorname=GetItemText(parentnode);
				strSql.Format(_T("select * from ALL_NODE where Building_Name='%s' and Floor_name='%s' and Room_name='%s' order by Building_Name"),subnetname,Floorname,m_name_new);
				m_pRs->Open((_variant_t)strSql,_variant_t((IDispatch *)m_pCon,true),adOpenStatic,adLockOptimistic,adCmdText);

				while(VARIANT_FALSE==m_pRs->EndOfFile)
				{	   	 str_temp.Empty();
				str_temp=m_pRs->GetCollect("Room_name");
				if (str_temp.Compare(m_name_new)==0)
				{	   is_exist=TRUE;
				break;
				}			
				m_pRs->MoveNext();
				}
				m_pRs->Close();


				if (is_exist)
				{
					return FALSE;
				} 
				else
				{strSql.Format(_T("select * from ALL_NODE where Building_Name='%s' and Floor_name='%s' and Room_name='%s' order by Building_Name"),subnetname,Floorname,m_name_old);
				m_pRs->Open((_variant_t)strSql,_variant_t((IDispatch *)m_pCon,true),adOpenStatic,adLockOptimistic,adCmdText);

				while(VARIANT_FALSE==m_pRs->EndOfFile)
				{
					strSql.Format(_T("update ALL_NODE set Room_name='%s' where Room_name='%s'"),m_name_new,m_name_old);
					m_pCon->Execute(strSql.GetString(),NULL,adCmdText);
					m_pRs->MoveNext();
				}
				m_pRs->Close();

				return TRUE; 
				}


				break;
			}
		case 3:		//Device Name Leaf
			{
				//Subnet
				HTREEITEM root=GetRootItem();
				CString subnetname=GetItemText(root);
				//Room
				HTREEITEM parentnode=GetParentItem(m_hSelItem);
				CString Roomname=GetItemText(parentnode);
				//Floor
				HTREEITEM floornode=GetParentItem(parentnode);
				CString Floorname=GetItemText(floornode);
				strSql.Format(_T("select * from ALL_NODE where Building_Name='%s' and Floor_name='%s' and Room_name='%s' and Product_name='%s' order by Building_Name"),subnetname,Floorname,Roomname,m_name_new);
				m_pRs->Open((_variant_t)strSql,_variant_t((IDispatch *)m_pCon,true),adOpenStatic,adLockOptimistic,adCmdText);

				while(VARIANT_FALSE==m_pRs->EndOfFile)
				{	   	 str_temp.Empty();
				str_temp=m_pRs->GetCollect("Product_name");
				if (str_temp.Compare(m_name_new)==0)
				{	   is_exist=TRUE;
				break;
				}			
				m_pRs->MoveNext();
				}

				m_pRs->Close();	

				if (is_exist)
				{
					return FALSE;
				}
				else
				{
					strSql.Format(_T("select * from ALL_NODE where Building_Name='%s' and Floor_name='%s' and Room_name='%s' and Product_name='%s' order by Building_Name"),subnetname,Floorname,Roomname,m_name_old);
					m_pRs->Open((_variant_t)strSql,_variant_t((IDispatch *)m_pCon,true),adOpenStatic,adLockOptimistic,adCmdText);
					while(VARIANT_FALSE==m_pRs->EndOfFile)
					{
						strSql.Format(_T("update ALL_NODE set Product_name='%s' where Product_name='%s'"),m_name_new,m_name_old);
						m_pCon->Execute(strSql.GetString(),NULL,adCmdText);
						m_pRs->MoveNext();
					}
					m_pRs->Close();
					return TRUE;
				}

				break;
			}
		}
	}
	catch(_com_error e)
	{
		/* AfxMessageBox(e.Description());*/
		//MessageBox(m_name_new+_T("  has been here\n Please change another name!"));

		return FALSE;
		m_pCon->Close();
	}
	m_pCon->Close();  
	return TRUE;
}
BOOL CImageTreeCtrl::SetItemImage(HTREEITEM hItem, int nImage, int nSelectedImage)
{
	//tree0412 屏蔽下面原有的
#if 0
	BOOL bReturn=CTreeCtrl::SetItemImage( hItem, nImage, nSelectedImage );

	HTREEITEM hParentItem;//,hBrotherItem;	
	static int dd=0;
	//查找子节点,没有就结束
	hParentItem=GetParentItem(hItem);
	int brother_nImage,brother_nSelectedImage;
	if(hParentItem)
	{	 
//Subnet,Floor_xx,Room_xx 只有当全部设备没有连接时才显示“没连接图标”,否则不改变这三个图标
#if 0  //LSC
		//have parentitem 
		if(!is_connection_by_image(nImage,nSelectedImage))
		{//this is disconnection
			GetItemImage(hParentItem,brother_nImage,brother_nSelectedImage);
			if(is_connection_by_image(brother_nImage,brother_nSelectedImage))
				SetItemImage(hParentItem,6,brother_nSelectedImage);
			return bReturn;////////////////////unconnection return ;
		}	

		/////////////prev
		hBrotherItem=GetPrevSiblingItem(hItem);
		if(hBrotherItem)
			GetItemImage(hBrotherItem,brother_nImage,brother_nSelectedImage);
		while(hBrotherItem)
		{
			if(!is_connection_by_image(brother_nImage,brother_nSelectedImage))
			{//one brother is disconnection
				GetItemImage(hParentItem,brother_nImage,brother_nSelectedImage);
				if(is_connection_by_image(brother_nImage,brother_nSelectedImage))
					SetItemImage(hParentItem,6,brother_nSelectedImage);
				return bReturn;////////////////////unconnection return ;
			}			
			hBrotherItem=GetPrevSiblingItem(hBrotherItem);
			if(hBrotherItem)
				GetItemImage(hBrotherItem,brother_nImage,brother_nSelectedImage);
		}	
		/////////////next
		hBrotherItem=GetNextSiblingItem(hItem);
		if(hBrotherItem)
			GetItemImage(hBrotherItem,brother_nImage,brother_nSelectedImage);
		while(hBrotherItem)
		{
			if(!is_connection_by_image(brother_nImage,brother_nSelectedImage))
			{//one brother is disconnection
				GetItemImage(hParentItem,brother_nImage,brother_nSelectedImage);
				if(is_connection_by_image(brother_nImage,brother_nSelectedImage))
					SetItemImage(hParentItem,6,brother_nSelectedImage);
				return bReturn;////////////////////unconnection return ;
			}
			hBrotherItem=GetNextSiblingItem(hBrotherItem);
			if(hBrotherItem)
				GetItemImage(hBrotherItem,brother_nImage,brother_nSelectedImage);
		}		
#endif
		//every brother is connection
//		GetItemImage(hParentItem,brother_nImage,brother_nSelectedImage);
// 		if(!is_connection_by_image(brother_nImage,brother_nSelectedImage))
// 			SetItemImage(hParentItem,brother_nSelectedImage,brother_nSelectedImage);
	}
	return bReturn;
#endif
//tree0412

//tree0412
	BOOL bReturn=CTreeCtrl::SetItemImage( hItem, nImage, nSelectedImage );
	return bReturn;
//tree0412
}
Esempio n. 17
0
void CTreeFileCtrl::EndDragging(BOOL bCancel)
{
  if (IsDragging())
  {
    KillTimer(m_nTimerID);

    CImageList::DragLeave(this);
    CImageList::EndDrag();
    ReleaseCapture();

    delete m_pilDrag;
    m_pilDrag = NULL;

    //Remove drop target highlighting
    SelectDropTarget(NULL);

    m_hItemDrop = GetDropTarget(m_hItemDrop);
    if (m_hItemDrop == NULL)
      return;

    if (!bCancel)
    {
      //Also need to make the change on disk
      CString sFromPath = ItemToPath(m_hItemDrag);
      CString sToPath = ItemToPath(m_hItemDrop);

      int nFromLength = sFromPath.GetLength();
      int nToLength = sToPath.GetLength();
      SHFILEOPSTRUCT shfo;
      ZeroMemory(&shfo, sizeof(SHFILEOPSTRUCT));
      shfo.hwnd = GetSafeHwnd();

      if ((GetKeyState(VK_CONTROL) & 0x8000))
        shfo.wFunc = FO_COPY;
      else
        shfo.wFunc = FO_MOVE;

      shfo.fFlags = FOF_SILENT | FOF_NOCONFIRMMKDIR;
      //Undo is not allowed if the SHIFT key is held down
      if (!(GetKeyState(VK_SHIFT) & 0x8000))
        shfo.fFlags |= FOF_ALLOWUNDO;

      TCHAR* pszFrom = new TCHAR[nFromLength + 2];
      _tcscpy(pszFrom, sFromPath);
      pszFrom[nFromLength+1] = _T('\0');
      shfo.pFrom = pszFrom;

      TCHAR* pszTo = new TCHAR[nToLength + 2];
      _tcscpy(pszTo, sToPath);
      pszTo[nToLength+1] = _T('\0');
      shfo.pTo = pszTo;

      //Let the shell perform the actual deletion
      BOOL bSuccess = ((SHFileOperation(&shfo) == 0) && (shfo.fAnyOperationsAborted == FALSE));

      //Free up the memory we had allocated
      delete [] pszFrom;
      delete [] pszTo;

      if (bSuccess)
      {
        //Only copy the item in the tree if there is not an item with the same
        //text under m_hItemDrop
        CString sText = GetItemText(m_hItemDrag);
        if (!HasChildWithText(m_hItemDrop, sText))
        {
          //Do the actual copy
          BOOL bHadChildren = (GetChildItem(m_hItemDrop) != NULL);
          CopyBranch(m_hItemDrag, m_hItemDrop);

          //Update the children indicator for the folder we just dropped into
          if (!bHadChildren)
          {
            TV_ITEM tvItem;
            tvItem.hItem = m_hItemDrop;
            tvItem.mask = TVIF_CHILDREN;  
            tvItem.cChildren = 1;
            SetItem(&tvItem);
          }
        }

        BOOL bExpanded = (GetChildItem(m_hItemDrop) != NULL); 
        if (shfo.wFunc == FO_MOVE)
        {
          //Get the parent of the item we moved prior to deleting it
          HTREEITEM hParent = GetParentItem(m_hItemDrag);

          //Delete the item we just moved
          DeleteItem(m_hItemDrag);

          //Update the children indicator for the item we just dragged from
          BOOL bHasChildren = (GetChildItem(hParent) != NULL);
          if (hParent && !bHasChildren)
          {
            TV_ITEM tvItem;
            tvItem.hItem = hParent;
            tvItem.mask = TVIF_CHILDREN;  
            tvItem.cChildren = 0;
            SetItem(&tvItem);
          }
        }
        SetSelectedPath(sToPath, bExpanded);
      }
    }
  }
}
//绘画子项
VOID CServerItemView::DrawTreeItem(CDC * pDC, CRect & rcClient, CRect & rcClipBox)
{
	//首项判断
	HTREEITEM hItemCurrent=GetFirstVisibleItem();
	if (hItemCurrent==NULL) return;

	//获取属性
	UINT uTreeStyte=GetWindowLong(m_hWnd,GWL_STYLE);

	////获取对象
	//ASSERT(CSkinRenderManager::GetInstance()!=NULL);
	//CSkinRenderManager * pSkinRenderManager=CSkinRenderManager::GetInstance();

	//绘画子项
	do
	{
		//变量定义
		CRect rcItem;
		CRect rcRect;

		//获取状态
		HTREEITEM hParent=GetParentItem(hItemCurrent);
		UINT uItemState=GetItemState(hItemCurrent,TVIF_STATE);

		//获取属性
		bool bDrawChildren=(ItemHasChildren(hItemCurrent)==TRUE);
		bool bDrawSelected=(uItemState&TVIS_SELECTED)&&((this==GetFocus())||(uTreeStyte&TVS_SHOWSELALWAYS));

		//获取区域
		if (GetItemRect(hItemCurrent,rcItem,TRUE))
		{
			//绘画过滤
			if (rcItem.top>=rcClient.bottom)
				break;
			if (rcItem.top>=rcClipBox.bottom)
				continue;

			//设置位置
			rcRect.left=0;
			rcRect.top=rcItem.top+1;
			rcRect.bottom=rcItem.bottom;
			rcRect.right=rcClient.Width();

			//绘画选择
			if (bDrawSelected==true)
			{
				pDC->FillSolidRect(&rcRect,RGB(253,231,161));
			}

			//绘画经过
			if ((bDrawSelected==false)&&(m_hItemMouseHover==hItemCurrent))
			{
				pDC->FillSolidRect(&rcRect,RGB(157,182,249));
			}

			//绘制箭头
			if (bDrawChildren==true)
			{
				//计算位置
				INT nXPos=rcItem.left-m_ImageArrow.GetWidth()/2-25;
				INT nYPos=rcItem.top+1+(rcItem.Height()-m_ImageArrow.GetHeight())/2;

				//绘画图标
				INT nIndex=(uItemState&TVIS_EXPANDED)?1L:0L;
				m_ImageArrow.DrawImage(pDC,nXPos,nYPos,m_ImageArrow.GetWidth()/2,m_ImageArrow.GetHeight(),nIndex*m_ImageArrow.GetWidth()/2,0);
			}

			//绘制列表
			DrawListImage(pDC,rcItem,hItemCurrent);	

			rcItem.right+=20;
			//绘制文本
			DrawItemString(pDC,rcItem,hItemCurrent,bDrawSelected);
		}
	} while ((hItemCurrent=GetNextVisibleItem(hItemCurrent))!= NULL);

	return;
}
Esempio n. 19
0
void CZoneTree::ConvertObjToIndex(HTREEITEM &hItem, HTREEITEM &hNewItem, HTREEITEM &htiNewParent)
{
	HTREEITEM par;
	int x, y;
	obj_index *o_index;
	
	par = GetParentItem(htiNewParent);
	
	GetItemImage(htiNewParent, x, x);
	
	switch(x) 
	{
	case CONTENTS:
		GetItemImage(par, y, y);
		switch(y) 
		{
		case OBJ_INDEX:
			obj_index *o_parent;

			o_parent = (obj_index*)GetItemData(par);

			if(o_parent) 
			{
				o_index = o_parent->AddContent((object_data*)GetItemData(hItem));
				o_index->m_tThis = hNewItem;
			}

			SetItemImage(hNewItem, OBJ_INDEX, OBJ_INDEX);
			SetItemData(hNewItem, (DWORD)o_index);
			
			break;
		case MOB_INDEX:
			break;
		case ROOM_DATA:
			room_data *room;
							
			room = (room_data*)GetItemData(par);

			if(room) {
				o_index = room->AddContent((object_data*)GetItemData(hItem));
				o_index->m_tThis = hNewItem;
			}

			SetItemImage(hNewItem, OBJ_INDEX, OBJ_INDEX);
			SetItemData(hNewItem, (DWORD)o_index);
			
			break;
		}
	/*	case OBJECT_DATA:
			
			GetItemImage(htiNewParent, y, y);
			switch(y)
			{
			case OBJ_INDEX:
				obj_index *o_parent;

				o_parent = (obj_index*)GetItemData(htiNewParent);

				if(o_parent) 
				{
					o_index = o_parent->AddContent((object_data*)GetItemData(hItem));
					o_index->m_tThis = hNewItem;
				}

				SetItemImage(hNewItem, OBJ_INDEX, OBJ_INDEX);
				SetItemData(hNewItem, (DWORD)o_index);
				break;
			}
			
			break;*/
	}
}
Esempio n. 20
0
void CCheckBoxTree::OnLButtonDown(UINT nFlags, CPoint point)
{
    UINT nHitTestFlags = 0;
    HTREEITEM hItem = HitTest(point, &nHitTestFlags);
    //MessageBox( "BEFORE IF", "IF1", MB_OK);
    if((hItem != nullptr) && (TVHT_ONITEMSTATEICON & nHitTestFlags))
    {
        //MessageBox( "INSIDE IF", "IF1", MB_OK);
        //BOOL bCheck= GetCheck(hItem);
        BOOL bCheck = bIsItemChecked(hItem);

        //vSetCheck(hItem,!bCheck);

        vSetCheckChildren(hItem,!bCheck);


        if(!bCheck)
        {
            HTREEITEM root,parent;

            root=GetRootItem();
            SetCheck(root);

            parent=GetParentItem(hItem);
            SetCheck(parent);
        }

        if(bCheck)
        {

            HTREEITEM root;
            HTREEITEM child;
            root=GetRootItem();
            SetCheck(root,0);

            while(ItemHasChildren(root))
            {
                //MessageBox("wHILE1", "WHILE1", MB_OK);
                HTREEITEM parent=GetChildItem(root);
                while(ItemHasChildren(parent))
                {
                    if(GetCheck(parent))
                    {
                        SetCheck(parent,0);
                        child=GetChildItem(parent);
                        //MessageBox( "wHILE2", "WHILE2", MB_OK);
                        while(child)
                        {
                            if(GetCheck(child))
                            {

                                SetCheck(root);
                                SetCheck(parent);
                            }
                            child=GetNextSiblingItem(child);
                            if ( child == nullptr )
                            {
                                break;
                            }
                        }
                    }
                    parent=GetNextSiblingItem(parent);
                    if ( parent == nullptr )
                    {
                        break;
                    }

                }

                parent=GetNextSiblingItem(parent);
                if ( parent == nullptr )
                {
                    break;
                }

            }
        }
    }

    else
    {
        //MessageBox( "INSIDE ELSE", "ELSE", MB_OK);
        CTreeCtrl::OnLButtonDown(nFlags, point);
    }
}
Esempio n. 21
0
void CDownloads_Groups::ShowGrpContextMenu(HTREEITEM hItem, BOOL bAutoDetect)
{
	if (bAutoDetect)	
	{
		hItem = GetSelectedItem ();
		if (hItem)
		{
			RECT rc;
			GetItemRect (hItem, &rc, TRUE);
			m_rbX = rc.left;
			m_rbY = rc.top;
		}
	}

	m_hContextMenuItem = hItem;

	if (hItem)
	{
		if (hItem == m_hDeleted)
		{
			ShowDeletedContextMenu ();
			return;
		}

		if (hItem == m_hHistory || GetParentItem (hItem) == m_hHistory)
		{
			ShowHistoryContextMenu ();
			return;
		}
	}

	CMenu menu;
	menu.LoadMenu (IDM_GROUP);
	CMenu *pPopup = menu.GetSubMenu (0);

	ApplyLanguageToMenu (pPopup);

	pPopup->SetDefaultItem (ID_GRPPROPERTIES);

	if (hItem)	
	{
		
		
		if (hItem == m_hAllGroups || IsGroupItem (hItem))
		{
			if (hItem == m_hAllGroups)
			{
				pPopup->EnableMenuItem (ID_GRPDELETE, MF_BYCOMMAND | MF_GRAYED);
				pPopup->EnableMenuItem (ID_OPENGROUPFOLDER, MF_BYCOMMAND | MF_GRAYED);
				pPopup->ModifyMenu (ID_GRPPROPERTIES, MF_BYCOMMAND, ID_GRPSETROOTFOLDER, LS (L_SETGRPROOTFOLDER));
			}

			if (hItem == m_hOther)
			{
				pPopup->EnableMenuItem (ID_GRPDELETE, MF_BYCOMMAND | MF_GRAYED);
			}
		}
		else
		{
			pPopup->EnableMenuItem (ID_GRPPROPERTIES, MF_BYCOMMAND | MF_GRAYED);
			pPopup->EnableMenuItem (ID_GRPDELETE, MF_BYCOMMAND | MF_GRAYED);
			pPopup->EnableMenuItem (ID_OPENGROUPFOLDER, MF_BYCOMMAND | MF_GRAYED);
		
			if (hItem != m_hFilters && hItem != m_hCompleted && hItem != m_hAllGroups)
			{
				pPopup->EnableMenuItem (ID_GRPDELETEALLSUCCESSFUL, MF_BYCOMMAND | MF_GRAYED);
				pPopup->EnableMenuItem (ID_GRPDELETEALLDEADDLDS, MF_BYCOMMAND | MF_GRAYED);
			}
			else if (hItem == m_hCompleted)
			{
				pPopup->EnableMenuItem (ID_GRPSTARTALL, MF_BYCOMMAND | MF_GRAYED);
				pPopup->EnableMenuItem (ID_GRPSTOPALL, MF_BYCOMMAND | MF_GRAYED);
				pPopup->EnableMenuItem (ID_GRPDELETEALL, MF_BYCOMMAND | MF_GRAYED);
			}	
		}
	}
	else  
	{
		

		pPopup->EnableMenuItem (ID_GRPPROPERTIES, MF_BYCOMMAND | MF_GRAYED);
		pPopup->EnableMenuItem (ID_GRPDELETE, MF_BYCOMMAND | MF_GRAYED);
		pPopup->EnableMenuItem (ID_OPENGROUPFOLDER, MF_BYCOMMAND | MF_GRAYED);
		pPopup->EnableMenuItem (ID_GRPSTARTALL, MF_BYCOMMAND | MF_GRAYED);
		pPopup->EnableMenuItem (ID_GRPSTOPALL, MF_BYCOMMAND | MF_GRAYED);
		pPopup->EnableMenuItem (ID_GRPDELETEALL, MF_BYCOMMAND | MF_GRAYED);
		pPopup->EnableMenuItem (ID_GRPDELETEALLSUCCESSFUL, MF_BYCOMMAND | MF_GRAYED);
		pPopup->EnableMenuItem (ID_GRPDELETEALLDEADDLDS, MF_BYCOMMAND | MF_GRAYED);
	}

	CPoint pt (m_rbX, m_rbY);
	ClientToScreen (&pt);

	m_odmenu.Attach (&menu, FALSE);

	fsSetImage images [] =
	{
		fsSetImage (ID_GRPCREATE, 0),
		fsSetImage (ID_GRPDELETE, 1),
		fsSetImage (ID_GRPDELETEALL, 2),
		fsSetImage (ID_GRPPROPERTIES, 3),
	};

	m_odmenu.SetImages (images, sizeof (images) / sizeof (fsSetImage));

	pPopup->TrackPopupMenu (TPM_RIGHTBUTTON | TPM_TOPALIGN | TPM_LEFTALIGN,	pt.x, pt.y, this);
	m_odmenu.Detach ();

	menu.DestroyMenu ();
}
bool CEditTreeCtrl::DoInsertSibling(HTREEITEM hItem) {
	TRACE1(_T("CEditTreeCtrl::OnInsertSibling('%s')\n"), LPCTSTR(GetItemText(hItem)));
	TVINSERTSTRUCT ins;
	SetupInsertStruct(ins, GetParentItem(hItem));
	return NewItem(ins);
}
Esempio n. 23
0
/*
Function	:OnNetGetMsg
Notes		:收到服务器转发的好友消息
Author		:Fred Huang
Date		:2008-04-7
Parameter	:pData-服务器返回的数据
return		:void
*/
void CIMMain::OnNetGetMsg(void * pData)
{

	try
	{
		MSG_IM_S_MSG *msg=(MSG_IM_S_MSG*)pData;
		//找到用户在树中的位置
		HTREEITEM hti=FindUserITEM(msg->dwUserID+1000);

		int charType = GetMainRoom()->m_PlaceUserInfo.iAddFriendType / 65535;
		
		if (charType == 1)
		{
			return;
		}
		if (charType == 2 && GetParentItem(hti) != htiFamilier)
		{
			return;
		}

		if(!hti)
		{//如果没有,则加到陌生人中
			hti=InsertItem(msg->szUserName,2,2,htiUnfamilier);
			SetItemData(hti,msg->dwUserID+1000);
		}
		else
		{//如果在黑名单中,直接返回,不响应
			if(GetParentItem(hti)==htiBlack)
				return;
		}
		//打开对话框
		//激活信息窗口
#ifndef  MAINROOM_USE_SHORTMSG
		CIMSession * session=openIMSession(msg->dwUserID,msg->szUserName);		if(!session)return;
		if(!session->m_hWnd)return;
		session->ShowWindow(SW_SHOW);
		session->setUserOnline(true);
		//添加消息
		session->OnGetMessage(msg);
#else
		CShortMessage * pShortMessageWnd=NULL;
		if (msg->dwUserID == GetMainRoom()->m_PlaceUserInfo.dwUserID)
		{
			//自己发送的消息
			pShortMessageWnd=openShortMsg(msg->dwRemoteUserID,msg->szUserName);
			if (pShortMessageWnd!=NULL) 
			{
				pShortMessageWnd->OnRecvMessage(msg->szUserName,msg->szMsg,RGB(0, 0, 255));
			}
		}
		else	//其他游戏者发送信息	
		{
			pShortMessageWnd = openShortMsg(msg->dwUserID,msg->szUserName);
			if (pShortMessageWnd!=NULL)
			{
				pShortMessageWnd->OnRecvMessage(msg->szUserName,msg->szMsg,RGB(255, 0, 0));
			}

		}
#endif
	}
	catch (...)
	{
		TCHAR smsg[1000]={0};
		wsprintf(smsg,"IM_TRY_CATCH : [%s]",__FUNCTION__);
	}
}
void CEditTreeCtrl::SortCurrentLevel(HTREEITEM hItem) {
	if(!hItem)
		hItem = GetSelectedItem();
	if(CanSortLevel(hItem))
		SortChildren(hItem ? GetParentItem(hItem) : hItem);
}
Esempio n. 25
0
BOOL CZoneTree::MenuSelect(UINT id)
{	
	HTREEITEM it, par;
	room_data *room;
	int index;
	CPoint pos;
	CWinDEDlg *parent = (CWinDEDlg*)GetParent();
	
	
	switch(id) {
	case ID_TREE_GOTO:
		par = GetSelectedItem();
		
		room = (room_data*)GetItemData(par);

		parent->in_room = room;

		parent->ShowRoom();
		break;
	case ID_TREE_EDIT_AREA:
	case ID_TREE_EDIT_ROOM:
	case ID_TREE_EDIT_MINDEX:
	case ID_TREE_EDIT_OINDEX:
	case ID_TREE_EDIT_MOB:
	case ID_TREE_EDIT_OBJ:
		GetCursorPos(&pos);
		OnLButtonDblClk(0, pos);
		break;
	case ID_TREE_DELETE_ROOM:
	case ID_TREE_DELETE_MOB:
	case ID_TREE_DELETE_OBJ:
	case ID_TREE_DELETE_OINDEX:
	case ID_TREE_DELETE_MINDEX:
		OnKeyUp(VK_DELETE, 1, 0);
		break;
	case ID_TREE_NEW_AREA:
		parent->OnNewArea();
		break;
	case ID_TREE_SAVE_AREA:
		parent->OnSave();
		break;
	case ID_TREE_OPEN_AREA:
		parent->OnOpen();
		break;
	case ID_TREE_DELETE_ROOMS:
		parent->DeleteAllRooms();
		break;
	case ID_TREE_DELETE_MOBS:
		parent->DeleteAllMobs();
		break;
	case ID_TREE_DELETE_OBJS:
		parent->DeleteAllObjs();
		break;
	case ID_TREE_ROOM_GRID:
		parent->OnCreateGrid();
		break;
	case ID_TREE_FRIENDS: {
		mob_index *mob;
		DlgEditFriends friends;

		it = GetSelectedItem();
		
		mob = (mob_index*)GetItemData(it);

		friends.mob = mob;

		friends.DoModal();
							   }
		break;
	case ID_TREE_REMOVE_PEOPLE:
		it = GetSelectedItem();
		par = GetParentItem(it);
		
		room = (room_data*)GetItemData(par);
		
		DeleteItem(it);
		
		if(room) {
			room->m_tPeople = parent->InsertItem(CString("Occupants"), room->m_tThis, NULL, PEOPLE);
			room->RemoveEveryone();
		}
		
		SortChildren(par);
		
		break;
	case ID_TREE_EDIT_EQUIP: {
		mob_index *mob;
		DlgEquipMob dlg_eq;

		it = GetSelectedItem();
		mob = (mob_index*)GetItemData(it);
		
		dlg_eq.mob = mob;
		dlg_eq.DoModal();
		}
		break;
	case ID_TREE_NEW_MOB:
		parent->OnNewMob();
		break;
	case ID_TREE_NEW_OBJ:
		parent->OnNewObject();
		break;
	case ID_TREE_NEW_ROOM:
		parent->OnNewRoom();
		break;
	case ID_TREE_EDIT_CONTENTS:
		{
			DlgEditContents dlg_inv(this);
			par = GetSelectedItem();
		
			dlg_inv.obj= (obj_index*)GetItemData(par);

			dlg_inv.DoModal();
		}

		break;
	case ID_TREE_REMOVE_CONTENTS:
		it = GetSelectedItem();
		par = GetParentItem(it);

		GetItemImage(par, index, index);

		switch(index) {
		case ROOM_DATA:
			room = (room_data*)GetItemData(par);
			
			DeleteItem(it);

			if(room) {
				room->m_tContents = parent->InsertItem(CString("Contents"), room->m_tThis, NULL, CONTENTS);
				room->RemoveContents();
			}
			
			SortChildren(par);
			
			break;
		case OBJECT_DATA: {
			object_data *obj = (object_data*)GetItemData(par);

			DeleteItem(it);

			if(obj) {
				obj->RemoveContents();
			}
			break;
		}
		case OBJ_INDEX: {
			obj_index *obj = (obj_index*)GetItemData(par);

			DeleteItem(it);

			if(obj)
				obj->RemoveContents();

			break;
		}
		case MOB_INDEX:
			break;
		case MOB_DATA:
			
			break;
		}
		break;
		
	}

	return true;
}
Esempio n. 26
0
void CZoneTree::CopyObjIndex(HTREEITEM &hItem, HTREEITEM &hNewItem, HTREEITEM &htiNewParent)
{
	HTREEITEM pparent, content;
	int x, y;
	obj_index *index;
	content = GetParentItem(hItem);
	pparent = GetParentItem(content);

	GetItemImage(pparent, x, x);
	
	index = (obj_index*)GetItemData(hItem);
	
	//copy from x
	switch(x) {
	case OBJECT_DATA:
		object_data *obj;
		
		obj = (object_data*)GetItemData(pparent);
		
		obj->RemoveContent(index);

		pparent = GetParentItem(htiNewParent);

		GetItemImage(pparent, y, y);
		break;
	case OBJ_INDEX:
		break;
	case MOB_INDEX:
		break;
	case ROOM_DATA:
		room_data *room;
		
		room = (room_data*)GetItemData(pparent);
		
		room->RemoveContent(index);

		pparent = GetParentItem(htiNewParent);
		
		GetItemImage(pparent, y, y);
	}
	
	//copy to y
	switch(y) {
	case ROOM_DATA:
		room_data *room;
		room = (room_data*)GetItemData(pparent);
				
		room->AddContent(index);
		index->m_tThis = hNewItem;
				
		SetItemData(hNewItem, (DWORD)index);	
		GetItemImage(content, x, x);
		
		if(x !=CONTENTS)
			DeleteItem(hItem);
		break;
	case OBJ_INDEX:
	case MOB_INDEX:
		break;
	}
}
Esempio n. 27
0
void KUIMulStatusTree::TravelSiblingAndParent(HTREEITEM hItem, int nCheck)
{
    HTREEITEM hNextSiblingItem = NULL;
    HTREEITEM hPrevSiblingItem = NULL;
    HTREEITEM hParentItem = NULL;

    HWND hParent = GetParent();
    UINT nState  = 0;

    //查找父节点,没有就结束
    hParentItem = GetParentItem(hItem);

    int nRetCode = false;

    if(hParentItem != NULL)
    {
        int nState = nCheck;//设初始值,防止没有兄弟节点时出错

        //查找当前节点下面的兄弟节点的状态
        hNextSiblingItem = GetNextSiblingItem(hItem);

        while(hNextSiblingItem != NULL)
        {
            nRetCode = GetCheck(hNextSiblingItem, nState);

            if(nState != nCheck && nRetCode)
                break;
            else 
                hNextSiblingItem = GetNextSiblingItem(hNextSiblingItem);
        }

        if( nCheck == nState)
        {
            //查找当前节点上面的兄弟节点的状态
            hPrevSiblingItem = GetPrevSiblingItem(hItem);

            while(hPrevSiblingItem != NULL)
            {
                nRetCode = GetCheck(hPrevSiblingItem, nState);

                if(nState != nCheck && nRetCode)
                    break;
                else 
                    hPrevSiblingItem = GetPrevSiblingItem(hPrevSiblingItem);
            }
        }

        if( nCheck == nState || nState == 0)
        {
            nRetCode = GetCheck( hParentItem, nState);

            if( nState != 0)
            {
                //如果状态一致,则父节点的状态与当前节点的状态一致
                nState = GetItemState(hParentItem, TVIS_STATEIMAGEMASK);
                if (nState != INDEXTOSTATEIMAGEMASK(nCheck))
                {        
                    SetItemState(hParentItem, INDEXTOSTATEIMAGEMASK(nCheck), TVIS_STATEIMAGEMASK);
                    if (hParent != NULL)
                    {
                       // ::SendMessage(hParent, WM_KAN_NOTIFY_TREE_CHECKED_CHANGE, (WPARAM)hParentItem, (LPARAM)nCheck);
                    }
                }

            }
            //再递归处理父节点的兄弟节点和其父节点

            TravelSiblingAndParent(hParentItem, nCheck);
        }
        else
        {
            //状态不一致,则当前节点的父节点、父节点的父节点……状态均为第三态
            hParentItem = GetParentItem(hItem);

            while(hParentItem != NULL)
            {
                nRetCode = GetCheck(hParentItem, nState);

                if(nState !=0)
                {
                    nState = GetItemState(hParentItem, TVIS_STATEIMAGEMASK);
                    SetItemState(hParentItem, INDEXTOSTATEIMAGEMASK(EM_TVIS_INDETERMINING), TVIS_STATEIMAGEMASK);
                    if (hParent != NULL)
                    {
                        //::SendMessage(hParent, WM_KAN_NOTIFY_TREE_CHECKED_CHANGE, (WPARAM)hParentItem, (LPARAM)EM_TVIS_INDETERMINING);
                    }
                }

                hParentItem = GetParentItem(hParentItem);
            }
        }
    }	
}
Esempio n. 28
0
void CZoneTree::OnContextMenu(CWnd* pWnd, CPoint point) 
{
	CPoint pos(-1, -1);     
	CMenu menu; 
	int i;
	HTREEITEM hItem;
	HTREEITEM hParent;
	
	GetCursorPos(&pos);    
	ScreenToClient(&pos);     
	
	hItem = GetSelectedItem();
	
	SetFocus();

	if (hItem != NULL)    {       
		GetItemImage(hItem, i, i);

		menu.CreatePopupMenu();

		switch(i) {
			case AREA_DATA: {
				menu.AppendMenu(MF_STRING, ID_TREE_EDIT_AREA, "Edit Area");
				menu.AppendMenu(MF_STRING, ID_TREE_SAVE_AREA, "Save Area");
				menu.AppendMenu(MF_STRING, ID_TREE_NEW_AREA, "New Area");
				menu.AppendMenu(MF_STRING, ID_TREE_OPEN_AREA, "Open Area");
				break;
			}
			case ROOM_DATA: {
				menu.AppendMenu(MF_STRING, ID_TREE_GOTO,		"Goto");
				menu.AppendMenu(MF_STRING, ID_TREE_EDIT_ROOM, "Edit Room");
				menu.AppendMenu(MF_STRING, ID_TREE_DELETE_ROOM, "Delete Room");
				break;
			}
			case MOB_DATA: {
				menu.AppendMenu(MF_STRING, ID_TREE_EDIT_MOB, "Edit Mobile");
				menu.AppendMenu(MF_STRING, ID_TREE_DELETE_MOB, "Delete Mobile");
				break;
			}
			case MOB_INDEX: {
				menu.AppendMenu(MF_STRING, ID_TREE_EDIT_MINDEX,   "Edit Mobile");
				menu.AppendMenu(MF_STRING, ID_TREE_FRIENDS,  "Edit Friends");
				menu.AppendMenu(MF_STRING, ID_TREE_EDIT_EQUIP,    "Edit Equipment");
				menu.AppendMenu(MF_STRING, ID_TREE_DELETE_MINDEX, "Remove From Room");
				break;
			}
			case OBJECT_DATA: {
				menu.AppendMenu(MF_STRING, ID_TREE_EDIT_OBJ, "Edit Object");
				menu.AppendMenu(MF_STRING, ID_TREE_DELETE_OBJ, "Delete Object");
				break;
			}
			case OBJ_INDEX:{
				menu.AppendMenu(MF_STRING, ID_TREE_EDIT_OINDEX, "Edit Object");
				obj_index *obj;
				
				obj = (obj_index*)GetItemData(hItem);
				
				if(obj)
				{
					if(obj->IsContainer())
						menu.AppendMenu(MF_STRING, ID_TREE_EDIT_CONTENTS, "Edit Contents");
				}

				hParent = GetParentItem(hItem);

				GetItemImage(hParent, i, i);
				if(i == CONTENTS) {
					hParent = GetParentItem(hParent);
					GetItemImage(hParent, i, i);
				}

				switch(i) {
				case OBJ_INDEX:
					menu.AppendMenu(MF_STRING, ID_TREE_DELETE_OINDEX, "Remove From Object");
					break;
				case ROOM_DATA:
					menu.AppendMenu(MF_STRING, ID_TREE_DELETE_OINDEX, "Remove From Room");
					break;
				}
				
				break;
			}
			case OBJ_PARENT: {
				menu.AppendMenu(MF_STRING, ID_TREE_NEW_OBJ, "New Object");
				menu.AppendMenu(MF_STRING, ID_TREE_DELETE_OBJS, "Delete All Objects");
				break;
			}
			case MOB_PARENT: {
				menu.AppendMenu(MF_STRING, ID_TREE_NEW_MOB, "New Mobile");
				menu.AppendMenu(MF_STRING, ID_TREE_DELETE_MOBS, "Delete All Mobiles");
				break;
			}
			case ROOM_PARENT: {
				menu.AppendMenu(MF_STRING, ID_TREE_NEW_ROOM, "New Room");
				menu.AppendMenu(MF_STRING, ID_TREE_ROOM_GRID, "Create Room Grid");
				menu.AppendMenu(MF_STRING, ID_TREE_DELETE_ROOMS, "Delete All Rooms");
				break;
			}
			case PEOPLE: {
				menu.AppendMenu(MF_STRING, ID_TREE_REMOVE_PEOPLE, "Remove All Occupants");
				break;
			}
			case CONTENTS: {
				menu.AppendMenu(MF_STRING, ID_TREE_REMOVE_CONTENTS, "Remove All Contents");
				break;
			}
		}
  		       
		GetCursorPos(&pos);        
		      
		menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON, pos.x, pos.y, this);    
	}
}
Esempio n. 29
0
/*
Function	:addUserToList
Notes		:添加用户到树中
Author		:Fred Huang
Date		:2008-04-2
Parameter	:
dwUserID	:用户ID
szUserName	:用户姓名,服务器数据库中是Nickname
sex			:性别,男-1,女-0;
GroupID		:组ID,1-好友,2-陌生人,3-黑名单
onLine		:是否在线
return		:void
*/
void CIMMain::addUserToList(int dwUserID, CString szUsername, int sex, int GroupID, int nOnline)
{
	try
	{

		//如果Sex超出范围,取1
		sex=(sex==0)?0:1;
		//如果online超出范围,取1
		nOnline=(nOnline==0)?0:1;

		//如果组的号码超出范围,取陌生人
		HTREEITEM hRoot=htiUnfamilier;
		if(GroupID==1)
			hRoot=htiFamilier;
		if(GroupID==3)
			hRoot=htiBlack;

		//找出用户现在在树中的位置
		HTREEITEM htiUser=FindUserITEM(dwUserID+1000);
		if(htiUser)
		{
			HTREEITEM htiParent = GetParentItem(htiUser);
			DeleteItem(htiUser);
			if(ItemHasChildren(htiParent) == FALSE)
			{
				SetItemImage(htiParent, 0, 0);
			}
		}

		//取得显示的图标索引
		int nImage = 3;
// 		if(sex==0)
// 		{
// 			if(nOnline==0)
// 				nImage=6;
// 			else
// 				nImage=5;
// 		}
// 		else
// 		{
// 			if(nOnline==0)
// 				nImage=4;
// 			else
// 				nImage=3;
// 		}
		//如果是上线,从显示在上面,否则显示在下面
		if(nOnline)
			htiUser=InsertItem(szUsername,nImage,nImage,hRoot,TVI_FIRST);
		else
			htiUser=InsertItem(szUsername,nImage,nImage,hRoot,TVI_LAST);
		SetItemData(htiUser,dwUserID+1000);
		Expand(GetParentItem(htiUser),TVE_EXPAND);
		//SetItemImage(GetParentItem(htiUser),1,1);

#ifndef  MAINROOM_USE_SHORTMSG
		POSITION pos=imSessionList.GetHeadPosition();
		CIMSession * session=NULL;
		while(pos)
		{
			session=imSessionList.GetNext(pos);
			if(session->m_dwUserId==dwUserID)
			{
				session->setUserOnline(nOnline==0?false:true);
				break;
			}
		}
#endif

	}
	catch (...)
	{
		TCHAR smsg[1000]={0};
		wsprintf(smsg,"IM_TRY_CATCH : [%s]",__FUNCTION__);
	}
}