예제 #1
0
LRESULT CMainDlg::OnSaveSelected(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
	CTreeItem ti = m_Tree.GetSelectedItem();
	if(ti)
	{
		int out = ti.GetData()-1;
		if(out >= 0)
		{
			OnSaveFile(wNotifyCode, wID, hWndCtl, bHandled);
		}
		else
		{
			OnSaveFolder(wNotifyCode, wID, hWndCtl, bHandled);
		}
	}

	return 0;
}
예제 #2
0
bool CPetControl::isDoorOrBellbotPresent() const {
	CGameManager *gameManager = getGameManager();
	if (!gameManager)
		return false;
	CViewItem *view = gameManager->getView();
	if (!view)
		return false;

	for (CTreeItem *treeItem = view->getFirstChild(); treeItem;
			treeItem = treeItem->scan(view)) {
		CString name = treeItem->getName();
		if (dynamic_cast<CGameObject *>(treeItem) &&
				(name.contains("Doorbot") || name.contains("BellBot")))
			return true;
	}

	return false;
}
예제 #3
0
LRESULT CMainDlg::OnSaveFile(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
	CTreeItem ti = m_Tree.GetSelectedItem();
	if(ti)
	{
		int out = ti.GetData()-1;
		if(out >= 0)
		{
			CFileDialog fd(false, NULL, PathFindFileName(sc.index[out].filename.c_str()), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, _T("All Files (*.*)"), m_hWnd);
			if(fd.DoModal(m_hWnd) != IDCANCEL)
			{
				sc.SaveFile(sc.index[out], fd.m_szFileName);
			}
		}
	}

	return 0;
}
예제 #4
0
void CuResizableDlgBar::OnItemexpandingTree1(NMHDR* pNMHDR, LRESULT* pResult) 
{
	*pResult = 0;     // default to allow expanding
	NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;

	if (pNMTreeView->action == TVE_EXPAND) {
		HTREEITEM hItem = pNMTreeView->itemNew.hItem;
		CTreeItem *pItem;
		pItem = (CTreeItem *)m_Tree.GetItemData(hItem);
		if (pItem)
			if (!pItem->IsAlreadyExpanded()) {
				if (pItem->CreateSubBranches(hItem))
					 pItem->SetAlreadyExpanded(TRUE);
				else
					*pResult = 1;     // prevent expanding
			}
	}
	bSaveRecommended = TRUE;
}
예제 #5
0
bool CPetControl::isBotInView(const CString &name) const {
	CGameManager *gameManager = getGameManager();
	if (!gameManager)
		return false;
	CViewItem *view = gameManager->getView();
	if (!view)
		return false;

	// Iterate to find NPC
	for (CTreeItem *child = view->getFirstChild(); child; child = child->scan(view)) {
		CGameObject *gameObject = dynamic_cast<CGameObject *>(child);
		if (gameObject) {
			if (!gameObject->getName().compareToIgnoreCase(name))
				return true;
		}
	}

	return false;
}
예제 #6
0
CViewItem *CProjectItem::findView(int roomNumber, int nodeNumber, int viewNumber) {
    CTreeItem *treeItem = getFirstChild();
    CRoomItem *roomItem = nullptr;

    // Scan for the specified room
    if (treeItem) {
        do {
            CTreeItem *childItem = treeItem->getFirstChild();
            CRoomItem *rItem = dynamic_cast<CRoomItem *>(childItem);
            if (rItem && rItem->_roomNumber == roomNumber) {
                roomItem = rItem;
                break;
            }
        } while ((treeItem = treeItem->getNextSibling()) != nullptr);
    }
    if (!roomItem)
        return nullptr;

    // Scan for the specified node within the room
    CNodeItem *nodeItem = nullptr;

    CNodeItem *nItem = dynamic_cast<CNodeItem *>(
                           roomItem->findChildInstanceOf(CNodeItem::_type));
    for (; nItem && !nodeItem; nItem = dynamic_cast<CNodeItem *>(
                                           findNextInstanceOf(CNodeItem::_type, nItem))) {
        if (nItem->_nodeNumber == nodeNumber)
            nodeItem = nItem;
    }
    if (!nodeItem)
        return nullptr;

    // Scan for the specified view within the node
    CViewItem *viewItem = dynamic_cast<CViewItem *>(
                              nodeItem->findChildInstanceOf(CViewItem::_type));
    for (; viewItem; viewItem = dynamic_cast<CViewItem *>(
                                    findNextInstanceOf(CViewItem::_type, viewItem))) {
        if (viewItem->_viewNumber == viewNumber)
            return viewItem;
    }

    return nullptr;
}
예제 #7
0
void CGameManager::update() {
	updateMovies();
	frameMessage(getRoom());
	_timers.update(g_vm->_events->getTicksCount());
	_trueTalkManager.removeCompleted();

	CScreenManager::_screenManagerPtr->_mouseCursor->update();

	CViewItem *view = getView();
	if (view) {
		// Expand the game manager's bounds to encompass all the view's items
		for (CTreeItem *item = view; item; item = item->scan(view)) {
			Rect r = item->getBounds();
			if (!r.isEmpty())
				_bounds.extend(r);
		}

		// Also include the PET control in the bounds
		if (_project) {
			CPetControl *pet = _project->getPetControl();
			if (pet)
				_bounds.extend(pet->getBounds());
		}

		// And the text cursor
		CScreenManager *screenManager = CScreenManager::_screenManagerPtr;
		CTextCursor *textCursor = screenManager->_textCursor;
		if (textCursor && textCursor->_active)
			_bounds.extend(textCursor->getCursorBounds());
		
		// Set the surface bounds
		screenManager->setSurfaceBounds(SURFACE_BACKBUFFER, _bounds);

		// Handle redrawing the view
		if (!_bounds.isEmpty()) {
			_gameView->draw(_bounds);
			_bounds = Rect();
		}

		_gameState.checkForViewChange();
	}
}
예제 #8
0
bool CPetControl::dismissBot(const CString &name) {
	CGameManager *gameManager = getGameManager();
	if (!gameManager)
		return false;
	CViewItem *view = gameManager->getView();
	if (!view)
		return false;

	bool result = false;
	CDismissBotMsg dismissMsg;
	for (CTreeItem *treeItem = view->getFirstChild(); treeItem;
			treeItem = treeItem->scan(view)) {
		if (!treeItem->getName().compareToIgnoreCase(name))
			dismissMsg.execute(treeItem);
		else
			result = true;
	}

	return result;
}
예제 #9
0
BOOL IpmCurSelHasStaticChildren(CWnd* pPropWnd)
{
    CfIpmFrame* pIpmFrame = (CfIpmFrame*)pPropWnd->GetParentFrame();
    ASSERT (pIpmFrame->IsKindOf(RUNTIME_CLASS(CfIpmFrame)));

    // Get selected item handle
    HTREEITEM hItem = pIpmFrame->GetSelectedItem();
    ASSERT (hItem);
    if (!hItem)
        return FALSE;

    CTreeItem *pItem = (CTreeItem*)pIpmFrame->GetPTree()->GetItemData(hItem);
    ASSERT (pItem);
    if (!pItem)
        return FALSE;
    SubBK subBranchKind = pItem->GetSubBK();
    if (subBranchKind == SUBBRANCH_KIND_STATIC)
        return TRUE;
    else
        return FALSE;
}
예제 #10
0
void CMainFrame::InitViews()
{
	//
	{
		CTreeItem t;
		CTreeItem tail;
		//如何插入根节点
		{
			t = m_wndTreeView.InsertItem ( NULL, TVI_ROOT, TVI_LAST);
			t.SetText("root");

		}
		//如何插入子节点
		{
			tail = t.AddTail("child", 0);
		}
		//如同线性列表,head是头,tail是尾;如同std::list, push_front, push_back
		{
			tail.AddHead("head0", 0);
			tail.AddHead("head1", 0);
			tail.AddTail("tail0", 0);
			tail.AddTail("tail1", 0);
		}
	}
	
	// Create list view columns
	m_wndListView.InsertColumn(0, _T("Name"), LVCFMT_LEFT, 200, 0);
	m_wndListView.InsertColumn(1, _T("Size"), LVCFMT_RIGHT, 100, 1);
	m_wndListView.InsertColumn(2, _T("Type"), LVCFMT_LEFT, 100, 2);
}
예제 #11
0
bool CParrotLobbyLinkUpdater::ActMsg(CActMsg *msg) {
	if (msg->_action != "Refresh")
		return false;

	CNodeItem *node = findNode();
	LinkUpdatorEntries *entriesP;
	if (isEquals("ParrotLobbyUpdater_TOW")) {
		entriesP = &_entries[4];
	} else {
		if (node->_nodeNumber > 3)
			return true;
		entriesP = &_entries[node->_nodeNumber];
	}
	int count = entriesP->size();

	for (CTreeItem *item = node->getFirstChild(); item; item = item->scan(node)) {
		CLinkItem *link = dynamic_cast<CLinkItem *>(item);
		if (!link || count == 0)
			continue;

		CString linkName = link->getName();
		char c = linkName.lastChar();
		if (c >= 'a' && c <= 'd')
			linkName.deleteLastChar();

		for (uint idx = 0; idx < entriesP->size(); ++idx) {
			const LinkUpdatorEntry &entry = (*entriesP)[idx];
			if (entry._linkStr == linkName) {
				int val = entry._vals[CParrotLobbyObject::_flags];
				if (val)
					linkName += (char)(0x60 + val);

				link->_name = linkName;
				break;
			}
		}
	}

	return true;
}
예제 #12
0
LRESULT CMainFrame::OnSelChanged(LPNMHDR /*lpNLHDR*/)
{
	CTreeItem itemSelected;
	itemSelected = m_view.GetSelectedItem();

	UIEnable(IDM_AGGR_UNBIND, FALSE);
	UIEnable(IDM_AGGR_SYNCHRONIZE, FALSE);
	UIEnable(IDM_AGGR_ADDMIRROR, FALSE);
	if ( !itemSelected.IsNull() )
	{
		CDiskObjectPtr obj = m_mapObject[itemSelected.GetData()];
		ATLASSERT( obj.get() != NULL );
		CCommandSet cmdSet = 
			CObjectUIHandler::GetUIHandler(obj)->GetCommandSet(obj);
		CCommandSet::iterator itr;
		for ( itr = cmdSet.begin(); itr != cmdSet.end(); itr++ )
		{
			UIEnable( itr->GetID(), !itr->IsDisabled() );
		}
	}
	return 0;
}
예제 #13
0
LRESULT CMainDlg::OnTreeDblClick(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& bHandled)
{
	CTreeItem ti = m_Tree.GetSelectedItem();
	if(ti)
	{
		int out = ti.GetData()-1;
		if(out>=0)
		{
			CString f = sc.index[out].filename.c_str();
			if(!f.Right(4).Compare(".tri"))
			{
				delete file;
				file = new TriFile();
				Load(out);
			}
			else if(!f.Right(4).Compare(".dds"))
			{
				if(loaded)
				{
					Add(f.Right(f.GetLength()-f.ReverseFind('/')-1), out);
					m_p3d.TextureChange(sc, texdata);
				}
			}
			else if(!f.Right(4).Compare(".gr2"))
			{
				delete file;
				file = new GrannyTriFile();
				Load(out);
			}
			else
				MessageBox("WTF?", "Error", MB_ICONERROR | MB_OK);
		}
	}
	else
		if(!loaded)
			EnableAll(FALSE);
	return TRUE;
}
예제 #14
0
void CMainFrame::RefreshAction()
{
	CTreeItem itemSelected;
	itemSelected = m_viewTree.GetSelectedItem();

//	UIEnable(IDM_AGGR_BIND, FALSE);
	UIEnable(IDM_AGGR_UNBIND, FALSE);
	UIEnable(IDM_AGGR_SYNCHRONIZE, FALSE);
	UIEnable(IDM_AGGR_ADDMIRROR, FALSE);

	if ( !itemSelected.IsNull() )
	{
		CDiskObjectPtr obj = m_mapObject[itemSelected.GetData()];
		ATLASSERT( obj.get() != NULL );
		CCommandSet cmdSet = 
			CObjectUIHandler::GetUIHandler(obj)->GetCommandSet(obj);
		CCommandSet::iterator itr;
		for ( itr = cmdSet.begin(); itr != cmdSet.end(); itr++ )
		{
			UIEnable( itr->GetID(), !itr->IsDisabled() );
		}
	}
}
예제 #15
0
BOOL CdIpmDoc::ItemShutdown()
{
	try
	{
		CTreeCtrl* pTree = m_pTreeGD->GetPTree();
		HTREEITEM hItem  = pTree->GetSelectedItem();
		if (hItem) 
		{
			CTreeItem* pItem = (CTreeItem*)pTree->GetItemData(hItem);
			ASSERT (pItem);
			if (pItem)
				return pItem->TreeKillShutdown();
		}
	}
	catch (CeIpmException e)
	{
		AfxMessageBox (e.GetReason(), MB_ICONEXCLAMATION|MB_OK);
	}
	catch (...)
	{
		TRACE0("Exception in: CdIpmDoc::ItemShutdown\n");
	}
	return FALSE;
}
예제 #16
0
LRESULT CMainDlg::OnSaveFolder(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
	CTreeItem ti = m_Tree.GetSelectedItem();
	if(ti)
	{
		int out = ti.GetData()-1;
		if(out < 0)
		{
			CFolderDialog fd(m_hWnd, "Select folder to save files:");
			if(fd.DoModal(m_hWnd) != IDCANCEL)
			{
				CString path = fd.m_szFolderPath;
				CUnstuffDlg dlg; 
				DWORD data[3]; 
				data[0] = (DWORD)&ti;
				data[1] = (DWORD)&sc;
				data[2] = (DWORD)&path;
				dlg.DoModal(m_hWnd, (LPARAM)data); 
			}
		}
	}

	return 0;
}
예제 #17
0
void TreeViewUI::SetItemStateImage(CTreeItem hItem, unsigned int iImage, unsigned int iSelectedImage)
{
	CImageList imagelist = pTreeViewWnd->treeControl.GetImageList(0);
	if (imagelist.m_hImageList == nullptr)
	{
		return;
	}
	
	if (hItem.m_hTreeItem == nullptr)
	{
		return;
	}

	hItem.SetImage(iImage, iSelectedImage);
}
예제 #18
0
CTreeItem *CProjectItem::findSiblingChildInstanceOf(ClassDef *classDef, CTreeItem *startItem) const {
    for (CTreeItem *treeItem = startItem->getParent()->getNextSibling();
            treeItem; treeItem = treeItem->getNextSibling()) {
        for (CTreeItem *childItem = treeItem->getFirstChild();
                childItem; childItem = childItem->getNextSibling()) {
            if (childItem->isInstanceOf(classDef))
                return childItem;
        }
    }

    return nullptr;
}
예제 #19
0
CProjectItem *CProjectItem::loadData(SimpleFile *file) {
    if (!file->IsClassStart())
        return nullptr;

    CProjectItem *root = nullptr;
    CTreeItem *parent = nullptr;
    CTreeItem *item = nullptr;

    do {
        CString entryString = file->readString();

        if (entryString == "ALONG") {
            // Move along, nothing needed
        } else if (entryString == "UP") {
            // Move up
            if (parent == nullptr ||
                    (parent = parent->getParent()) == nullptr)
                break;
        } else if (entryString == "DOWN") {
            // Move down
            if (parent == nullptr)
                parent = item;
            else
                parent = parent->getLastChild();
        } else {
            // Create new class instance
            item = dynamic_cast<CTreeItem *>(CSaveableObject::createInstance(entryString));
            assert(item);

            if (root) {
                // Already created root project
                item->addUnder(parent);
            } else {
                root = dynamic_cast<CProjectItem *>(item);
                assert(root);
                root->_filename = _filename;
            }

            // Load the data for the item
            item->load(file);
        }

        file->IsClassStart();
    } while (file->IsClassStart());

    return root;
}
예제 #20
0
CTreeItem *CProjectItem::findChildInstance(ClassDef *classDef) const {
    CTreeItem *treeItem = getFirstChild();
    if (treeItem == nullptr)
        return nullptr;

    do {
        CTreeItem *childItem = treeItem->getFirstChild();
        if (childItem) {
            do {
                if (childItem->isInstanceOf(classDef))
                    return childItem;
            } while ((childItem = childItem->getNextSibling()) != nullptr);
        }
    } while ((treeItem = treeItem->getNextSibling()) != nullptr);

    return nullptr;
}
예제 #21
0
파일: tree.cpp 프로젝트: jetlive/skiaming
BOOL CTreeItem::ExpandTypeInfo( HTREEITEM hitem )
{
	ASSERT(m_pTree) ;
	ASSERT(hitem) ;

	CTreeItem*  pNewItem = NULL ;
	HRESULT         hr = S_OK ;
	TV_INSERTSTRUCT tvis ;
	CString         strError = "Enumerating TypeInfo" ;
	TYPEATTR*       pattr = NULL ;
	ITypeInfo*      pti = GetTypeInfo() ;
	ASSERT(pti) ;
	BOOL            fExpand = FALSE ;

	tvis.hParent = hitem  ;
	tvis.hInsertAfter = TVI_LAST ;
	tvis.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN ;
	tvis.item.iImage = typeUnknown ;
	tvis.item.iSelectedImage = tvis.item.iImage + 1 ;

	TRY
	{
		ENSURE(pti);
		hr = pti->GetTypeAttr(&pattr) ;
		if FAILED(hr)
		{
			strError.Format(_T("ITypeInfo::GetTypeAttr() failed"), hr ) ;
			AfxThrowMemoryException() ;
		}

		switch(pattr->typekind)
		{
		// typedef [attributes] enum [tag] {
		//      enumlist
		// } enumname;
		//
		// "typedef enum enumname"
		case TKIND_ENUM:
			fExpand = ExpandVars( hitem ) ;
		break ;

		// typedef [attributes]
		//  struct [tag] {
		//      memberlist
		//  } structname;
		//
		// "typedef struct structname"
		case TKIND_RECORD:
			fExpand = ExpandVars( hitem ) ;
		break ;

		// [attributes]
		//  module modulename {
		//      elementlist
		// };
		case TKIND_MODULE:
			if (pattr->cVars)
			{
				// Add "Constants" folder
				//
				#pragma warning (suppress: 6211)
				#pragma warning (suppress: 6014)
				pNewItem = new CTreeItem(m_pTree) ;
				pNewItem->m_Type = typeProperties ;
				pNewItem->SetTypeInfo(pti) ;
				pti->AddRef() ;
				tvis.item.cChildren = pattr->cVars ;
				tvis.item.lParam = (LPARAM)pNewItem ;
				tvis.item.pszText = _T("Constants") ;
				tvis.item.iImage = typeConstants ;
				tvis.item.iSelectedImage = tvis.item.iImage + 1 ;
				m_pTree->InsertItem( &tvis ) ;
				fExpand = TRUE ;
			}
			if (pattr->cFuncs)
			{
				pNewItem = new CTreeItem(m_pTree) ;
				pNewItem->m_Type = typeMethods ;
				pNewItem->SetTypeInfo(pti) ;
				pti->AddRef() ;
				tvis.item.cChildren = pattr->cFuncs ;
				tvis.item.lParam = (LPARAM)pNewItem ;
				tvis.item.pszText = _T("Functions") ;
				tvis.item.iImage = typeMethods ;
				tvis.item.iSelectedImage = tvis.item.iImage + 1 ;
				m_pTree->InsertItem( &tvis ) ;
				fExpand = TRUE ;
			}
		break ;

		// [attributes]
		//  interface interfacename  [:baseinterface] {
		//      functionlist
		// };
		case TKIND_INTERFACE:
			fExpand = ExpandFuncs( hitem) ;
			if (pattr->cImplTypes)
			{
				pNewItem = new CTreeItem(m_pTree) ;
				pNewItem->m_Type = typeImplTypes ;
				pNewItem->SetTypeInfo(pti) ;
				pti->AddRef() ;
				tvis.item.pszText = _T("Inherited Interfaces") ;
				tvis.item.iImage = typeInterface ;
				tvis.item.cChildren = pattr->cImplTypes ;
				tvis.item.lParam = (LPARAM)pNewItem ;
				tvis.item.iSelectedImage = tvis.item.iImage ;
				m_pTree->InsertItem( &tvis ) ;
				fExpand = TRUE ;
			}
		break ;

		// [attributes]
		//  dispinterface intfname {
		//      interface interfacename
		// };
		case TKIND_DISPATCH :
			if (pattr->cVars)
			{
				// Add "Constants" folder
				//
				pNewItem = new CTreeItem(m_pTree) ;
				pNewItem->m_Type = typeConstants ;
				pNewItem->SetTypeInfo(pti) ;
				pti->AddRef() ;
				tvis.item.cChildren = pattr->cVars ;
				tvis.item.lParam = (LPARAM)pNewItem ;
				tvis.item.pszText = _T("Constants") ;
				tvis.item.iImage = typeConstants ;
				tvis.item.iSelectedImage = tvis.item.iImage + 1 ;
				m_pTree->InsertItem( &tvis ) ;

				// Add "Properties" folder
				//
				pNewItem = new CTreeItem(m_pTree) ;
				pNewItem->m_Type = typeProperties ;
				pNewItem->SetTypeInfo(pti) ;
				pti->AddRef() ;
				tvis.item.cChildren = pattr->cVars ;
				tvis.item.lParam = (LPARAM)pNewItem ;
				tvis.item.pszText = _T("Properties") ;
				tvis.item.iImage = typeProperties ;
				tvis.item.iSelectedImage = tvis.item.iImage + 1 ;
				m_pTree->InsertItem( &tvis ) ;
				fExpand = TRUE ;
			 }
			if (pattr->cFuncs)
			{
				pNewItem = new CTreeItem(m_pTree) ;
				pNewItem->m_Type = typeMethods ;
				pNewItem->SetTypeInfo(pti) ;
				pti->AddRef() ;
				tvis.item.cChildren = pattr->cFuncs ;
				tvis.item.lParam = (LPARAM)pNewItem ;
				tvis.item.pszText = _T("Methods") ;
				tvis.item.iImage = typeMethods ;
				tvis.item.iSelectedImage = tvis.item.iImage + 1 ;
				m_pTree->InsertItem( &tvis ) ;
				fExpand = TRUE ;
			}
			if (pattr->cImplTypes)
			{
				pNewItem = new CTreeItem(m_pTree) ;
				pNewItem->m_Type = typeImplTypes ;
				pNewItem->SetTypeInfo(pti) ;
				pti->AddRef() ;
				tvis.item.pszText = _T("Inherited Interfaces") ;
				tvis.item.iImage = typeInterface ;
				tvis.item.cChildren = pattr->cImplTypes ;
				tvis.item.lParam = (LPARAM)pNewItem ;
				tvis.item.iSelectedImage = tvis.item.iImage ;
				m_pTree->InsertItem( &tvis ) ;
				fExpand = TRUE ;
			}
		break ;

		// [attributes]
		//  coclass classname {
		//      [attributes2] [interface | dispinterface] interfacename;
		//      ...
		// };
		case TKIND_COCLASS:
			fExpand = ExpandImplTypes( hitem ) ;
		break ;

		// typedef [attributes] basetype aliasname;
		case TKIND_ALIAS:
			if (pattr->tdescAlias.vt == VT_USERDEFINED)
			{
				ITypeInfo* ptiRefType = NULL ;

				#pragma warning (suppress: 6246)
				HRESULT hr = pti->GetRefTypeInfo( pattr->tdescAlias.hreftype, &ptiRefType ) ;
				if (FAILED(hr))
					AfxThrowOleException( hr ) ;

				pNewItem = new CTreeItem(m_pTree) ;
				pNewItem->SetTypeInfo( ptiRefType ) ;
				pNewItem->m_Type = TypeKindToItemType( pNewItem->GetTypeKind() ) ;
				tvis.item.iImage = TypeKindToItemType( pNewItem->GetTypeKind() ) ;
				tvis.item.cChildren = 1 ;
				tvis.item.lParam = (LPARAM)pNewItem ;
				tvis.item.iSelectedImage = tvis.item.iImage ;
				CString sName;
				pNewItem->GetName(sName, TRUE );
				tvis.item.pszText = sName.GetBuffer(0) ;
				m_pTree->InsertItem( &tvis ) ;
				sName.ReleaseBuffer();
				fExpand = TRUE ;
			}
		break ;

		// typedef [attributes] union [tag] {
		//      memberlist
		// } unionname;
		case TKIND_UNION:
			fExpand = ExpandVars( hitem ) ;
		break ;

		default:
		break ;
		}

		if (pattr)
			pti->ReleaseTypeAttr( pattr ) ;
	}
	CATCH(CException, pException)
	{
		ErrorMessage( strError, hr ) ;
		if (pNewItem)
			delete pNewItem ;

		if (pattr)
			pti->ReleaseTypeAttr( pattr ) ;

		return FALSE ;
	}
예제 #22
0
파일: tree.cpp 프로젝트: jetlive/skiaming
BOOL CTreeItem::ExpandTypeLib( HTREEITEM hitem )
{
	ASSERT(hitem) ;
	CTreeItem*  pNewItem = NULL ;

	UINT            uiTypeInfoCount = GetTypeLib()->GetTypeInfoCount() ;
	HRESULT         hr = S_OK ;
	TV_INSERTSTRUCT tvis ;
	CString         strError = "Enumerating typeinfos";
	TYPEATTR*       pattr = NULL ;
	BOOL            fExpand = FALSE ;

	tvis.hParent = hitem  ;
	tvis.hInsertAfter = TVI_LAST ;
	tvis.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN ;
	tvis.item.cChildren = 1 ;
	TRY
	{
		for (UINT n = 0 ; n < uiTypeInfoCount ; n++)
		{
			#pragma warning (suppress: 6014)
			pNewItem = new CTreeItem( m_pTree ) ;
			pNewItem->m_Type = typeTypeInfo ;
			ASSERT(pNewItem) ;

			tvis.item.lParam = (LPARAM)pNewItem ;
			hr = GetTypeLib()->GetTypeInfo( n, (ITypeInfo**)&pNewItem->m_punk ) ;
			if (FAILED(hr))
			{
				strError.Format(_T("Could not get TypeInfo #%u"), n ) ;
				AfxThrowOleException(hr) ;
			}
			ASSERT(pNewItem->m_punk) ;

			hr = pNewItem->GetTypeInfo()->GetTypeAttr(&pattr) ;
			if FAILED(hr)
			{
				strError.Format(_T("ITypeInfo::GetTypeAttr() failed") ) ;
				AfxThrowOleException(hr) ;
			}

			if ((m_Type == typeTypeLib) ||
				(m_Type == (TypeKindToItemType(pattr->typekind) + 8)))
			{
				tvis.item.iImage = pattr->typekind + typeEnum ;
				tvis.item.iSelectedImage = tvis.item.iImage ;
				CString sName;
				pNewItem->GetName(sName, TRUE );
				tvis.item.pszText = sName.GetBuffer(0);
				m_pTree->InsertItem( &tvis ) ;
				sName.ReleaseBuffer();
				pNewItem->GetTypeInfo()->ReleaseTypeAttr( pattr ) ;
				fExpand = TRUE ;
			}
			else
			{
				pNewItem->GetTypeInfo()->ReleaseTypeAttr( pattr ) ;
				delete pNewItem ;
			}
	   }
	}
	CATCH(CException, pException)
	{
		if (pException->IsKindOf(RUNTIME_CLASS(COleException)))
			ErrorMessage( strError, ((COleException*)pException)->m_sc ) ;
		else
			ErrorMessage( strError, hr ) ;

		if (pNewItem)
			delete pNewItem ;
		return FALSE ;
	}
	END_CATCH

	return fExpand ;
}
예제 #23
0
BOOL CIpmCtrl::SelectItem(LPCTSTR lpszNode, LPCTSTR lpszServer, LPCTSTR lpszUser, LPCTSTR lpszKey, VARIANT FAR* pArrayItem, short nShowTree)
{
	class CaLockDisplayRightPaneProperty
	{
	public:
		CaLockDisplayRightPaneProperty(CdIpmDoc* pDoc):m_pDoc(pDoc), m_bLock(FALSE){}
		~CaLockDisplayRightPaneProperty(){UnLock();}

		void Lock(){m_pDoc->SetLockDisplayRightPane(TRUE);}
		void UnLock(){m_pDoc->SetLockDisplayRightPane(FALSE);}

	protected:
		BOOL m_bLock;
		CdIpmDoc* m_pDoc;
	};

	CWaitCursor doWaitCursor ;
	BOOL bOK = FALSE;
	try 
	{
		CdIpmDoc* pDoc = new CdIpmDoc(lpszKey, pArrayItem, (BOOL)nShowTree);

		if (m_pIpmFrame)
		{
			m_pIpmFrame->ShowWindow (SW_HIDE);
			m_pIpmFrame->DestroyWindow();
			m_pIpmFrame = NULL;
		}

		CaIpmProperty& property = pDoc->GetProperty();
		ConstructPropertySet (property);

		SFILTER* pFilter = theApp.GetFilter();
		SFILTER* pDocFilter = pDoc->GetFilter();
		memcpy (pDocFilter, pFilter, sizeof(SFILTER));
		CaLockDisplayRightPaneProperty lock(pDoc);
		if (nShowTree == 1)
		{
			//
			// During the process of expanding tree up to search item,
			// prohibit the display of the properties of the selected tree item
			lock.Lock();
		}

		CWnd* pParent = this;
		CRect r;
		GetClientRect (r);
		m_pIpmFrame = new CfIpmFrame(pDoc);
		m_pIpmFrame->Create (
			NULL,
			NULL,
			WS_CHILD,
			r,
			pParent);
		if (!m_pIpmFrame)
			return FALSE;

		m_pIpmFrame->InitialUpdateFrame(NULL, TRUE);
		m_pIpmFrame->ShowWindow(SW_SHOW);
		bOK = pDoc->Initiate(lpszNode, lpszServer, lpszUser, NULL);
		if (!bOK)
			return FALSE;

		CTypedPtrList<CObList, CuIpmTreeFastItem*> listItemPath;
		bOK = IPM_BuildItemPath (pDoc, listItemPath);
		if (!bOK)
		{
			while (!listItemPath.IsEmpty())
				delete listItemPath.RemoveHead();
			return FALSE;
		}
		ExpandUpToSearchedItem(m_pIpmFrame, listItemPath, TRUE);
		lock.UnLock();
		//
		// Cleanup:
		while (!listItemPath.IsEmpty())
			delete listItemPath.RemoveHead();

		//
		// Fetch the selected tree item and display the corresponding right pane:
		IPMUPDATEPARAMS ups;
		CTreeGlobalData* pGD = pDoc->GetPTreeGD();
		ASSERT (pGD);
		if (!pGD)
			return FALSE;
		CTreeCtrl* pTree = pGD->GetPTree();
		ASSERT (pTree);
		if (!pTree)
			return FALSE;
		CuDlgIpmTabCtrl* pTabDlg  = (CuDlgIpmTabCtrl*)m_pIpmFrame->GetTabDialog();
		if (!pTabDlg)
			return FALSE;
		HTREEITEM hSelected = pTree->GetSelectedItem();
		if (!hSelected)
			return FALSE;
		//
		// Notify the container of sel change:
		ContainerNotifySelChange();
		memset (&ups, 0, sizeof (ups));
		CTreeItem* pItem = (CTreeItem*)pTree->GetItemData (hSelected);
		if (pItem->IsNoItem() || pItem->IsErrorItem())
		{
			pTabDlg->DisplayPage (NULL);
			return TRUE;
		}
		if (pItem->ItemDisplaysNoPage()) 
		{
			CString caption = pItem->ItemNoPageCaption();
			pTabDlg->DisplayPage (NULL, caption);
			return TRUE;
		}

		if (pItem->HasReplicMonitor())
		{
			pDoc->InitializeReplicator(pItem->GetDBName());
		}

		int nImage = -1, nSelectedImage = -1;
		CImageList* pImageList = pTree->GetImageList (TVSIL_NORMAL);
		HICON hIcon = NULL;
		int nImageCount = pImageList? pImageList->GetImageCount(): 0;
		if (pImageList && pTree->GetItemImage(hSelected, nImage, nSelectedImage))
		{
			if (nImage < nImageCount)
				hIcon = pImageList->ExtractIcon(nImage);
		}
		CuPageInformation* pPageInfo = pItem->GetPageInformation();
		ASSERT(pPageInfo);
		if (!pPageInfo)
			return FALSE;
		int nSelectTab = GetDefaultSelectTab (pDoc);

		CString strItem = pItem->GetRightPaneTitle();
		pItem->UpdateDataWhenSelChange(); // Has an effect only if the class has specialied the method.
		ups.nType   = pItem->GetType();
		ups.pStruct = pItem->GetPTreeItemData()? pItem->GetPTreeItemData()->GetDataPtr(): NULL;
		ups.pSFilter= pDoc->GetPTreeGD()->GetPSFilter();
		pPageInfo->SetUpdateParam (&ups);
		pPageInfo->SetTitle ((LPCTSTR)strItem, pItem, pDoc);
		pPageInfo->SetImage  (hIcon);
		pTabDlg->DisplayPage (pPageInfo, NULL, nSelectTab);

		return TRUE;
	}
	catch(CMemoryException* e)
	{
		theApp.OutOfMemoryMessage();
		e->Delete();
	}
	catch(CResourceException* e)
	{
		AfxMessageBox (IDS_E_LOAD_DLG);
		e->Delete();
	}
	catch(...)
	{
		AfxMessageBox (IDS_E_CONSTRUCT_PROPERTY);
	}
	return FALSE;
}
예제 #24
0
BOOL CdIpmDoc::UpdateDisplay()
{
	TRACE0("CdIpmDoc::UpdateDisplay()\n");
	try
	{
		m_pTreeGD->RefreshAllTreeBranches(); // refresh left pane
		
		IPMUPDATEPARAMS ups;
		memset (&ups, 0, sizeof (ups));
		CTreeItem* pItem = NULL;
		CTreeCtrl* pTree = m_pTreeGD->GetPTree();
		ASSERT (pTree);
		HTREEITEM hSelectedItem = pTree->GetSelectedItem();
		if (!hSelectedItem)
			return FALSE;
		pItem = (CTreeItem*)pTree->GetItemData(hSelectedItem);
		ASSERT (pItem);
		if (pItem->IsNoItem() || pItem->IsErrorItem())
		{
			m_pTabDialog->DisplayPage (NULL);
		}
		else 
		if (pItem->ItemDisplaysNoPage()) 
		{
			CString caption = pItem->ItemNoPageCaption();
			m_pTabDialog->DisplayPage (NULL, caption);
		}
		else 
		{
			int nImage = -1, nSelectedImage = -1;
			CImageList* pImageList = pTree->GetImageList (TVSIL_NORMAL);
			HICON hIcon = NULL;
			int nImageCount = pImageList? pImageList->GetImageCount(): 0;
			if (pImageList && pTree->GetItemImage(hSelectedItem, nImage, nSelectedImage))
			{
				if (nImage < nImageCount)
					hIcon = pImageList->ExtractIcon(nImage);
			}
			CuPageInformation* pPageInfo = pItem->GetPageInformation();
			CString strItem = pItem->GetRightPaneTitle();

			ups.nType   = pItem->GetType();
			ups.pStruct = pItem->GetPTreeItemData()? pItem->GetPTreeItemData()->GetDataPtr(): NULL;
			ups.pSFilter= m_pTreeGD->GetPSFilter();
			pPageInfo->SetUpdateParam (&ups);
			pPageInfo->SetTitle ((LPCTSTR)strItem, pItem, this);

			pPageInfo->SetImage  (hIcon);
			m_pTabDialog->DisplayPage (pPageInfo);
		}

		// Replicator Monitor special management
		// ASSUMES we did not change the current item!
		BOOL bReplMonWasOn = (m_hReplMonHandle != -1) ? TRUE: FALSE;
		BOOL bReplMonToBeOn = pItem->HasReplicMonitor();
		// 3 cases :
		//    - on to off ---> replicator has been uninstalled
		//    - off to on ---> replicator has been installed
		//    - on to on, or off to off: state has not changed
		if (bReplMonWasOn && !bReplMonToBeOn) 
		{
			BOOL bOK = TerminateReplicator();
			ASSERT (bOK);
		}
		else 
		if (!bReplMonWasOn && bReplMonToBeOn)
		{
			CString csDbName = pItem->GetDBName();
			BOOL bOK = InitializeReplicator(csDbName);
			ASSERT (bOK);
		}
		//
		// Refresh right pane
		CfIpmFrame* pIpmFrame = (CfIpmFrame*)pTree->GetParentFrame();
		UpdateAllViews((CView *)pIpmFrame->GetLeftPane());
	}
	catch(CMemoryException* e)
	{
		theApp.OutOfMemoryMessage();
		e->Delete();
		return FALSE;
	}
	catch(CResourceException* e)
	{
		//_T("Cannot load dialog box");
		AfxMessageBox (IDS_E_LOAD_DLG);
		e->Delete();
		return FALSE;
	}
	catch(...)
	{
		//_T("Cannot construct the property pane");
		AfxMessageBox (IDS_E_CONSTRUCT_PROPERTY);
		return FALSE;
	}

	return TRUE;
}
예제 #25
0
void CMainFrame::OnSingle(UINT /*wNotifyCode*/, int /*wID*/, HWND /*hwndCtl*/)
{
	ENTER_CRITICAL_SECTION(&m_csThreadRefreshStatus);

	WTL::CString strMsg;

	CTreeItem itemSelected = m_view.GetSelectedItem();
	if ( itemSelected.IsNull() )
	{
		LEAVE_CRITICAL_SECTION(&m_csThreadRefreshStatus);
		return;
	}

	CDiskObjectPtr obj, parent;
	obj = m_mapObject[m_view.GetItemData(itemSelected)];

	if(!obj->IsUnitDisk())
	{
		LEAVE_CRITICAL_SECTION(&m_csThreadRefreshStatus);
		return;
	}

	// AING_TO_DO
	{
		strMsg.LoadString(IDS_WARNING_SINGLE);
		WTL::CString strTitle;
		strTitle.LoadString(IDS_APPLICATION);

		int ret = MessageBox( 
			strMsg,
			strTitle,
			MB_YESNO | MB_ICONWARNING
			);

		if(IDYES != ret)
		{
			LEAVE_CRITICAL_SECTION(&m_csThreadRefreshStatus);
			return;
		}
	}

	//
	// Check whether any disk is being accessed by other program/computer
	//
	if ( !obj->CanAccessExclusive() )
	{
		LEAVE_CRITICAL_SECTION(&m_csThreadRefreshStatus);
		strMsg.LoadString(IDS_FAIL_TO_ACCESS_EXCLUSIVELY);
		WTL::CString strTitle;
		strTitle.LoadString(IDS_APPLICATION);
		MessageBox( 
			strMsg,
			strTitle,
			MB_OK | MB_ICONWARNING
			);
		return;
	}

	if(!(obj->GetAccessMask() & GENERIC_WRITE))
	{
		LEAVE_CRITICAL_SECTION(&m_csThreadRefreshStatus);
		// "%1!s! does not have a write access privilege. You need to set write key to this NDAS device before this action."
		strMsg.FormatMessage(IDS_ERROR_NOT_REGISTERD_WRITE_FMT,
			obj->GetTitle()
			);
		WTL::CString strTitle;
		strTitle.LoadString(IDS_APPLICATION);
		MessageBox(
			strMsg,
			strTitle,
			MB_OK|MB_ICONERROR
			);

		return;
	}

	NDAS_CONNECTION_INFO ConnectionInfo;

	CUnitDiskObjectPtr unitDisk = 
		boost::dynamic_pointer_cast<CUnitDiskObject>(obj);
	
	ZeroMemory(&ConnectionInfo, sizeof(NDAS_CONNECTION_INFO));

	ConnectionInfo.type = NDAS_CONNECTION_INFO_TYPE_MAC_ADDRESS;
	ConnectionInfo.UnitNo = unitDisk->GetLocation()->GetUnitDiskLocation()->UnitNumber;
	ConnectionInfo.bWriteAccess = TRUE;
	ConnectionInfo.ui64OEMCode = NULL;
	ConnectionInfo.protocol = IPPROTO_LPXTCP;
	CopyMemory(ConnectionInfo.MacAddress, 
		unitDisk->GetLocation()->GetUnitDiskLocation()->MACAddr,
		LPXADDR_NODE_LENGTH);

	UINT32 BindResult = NdasOpBind(
		1,
		&ConnectionInfo,
		NMT_SINGLE);

	LEAVE_CRITICAL_SECTION(&m_csThreadRefreshStatus);

	if(1 != BindResult)
	{
		DWORD dwLastError = ::GetLastError();

		switch(dwLastError)
		{
		case NDASCOMM_ERROR_RW_USER_EXIST:
		case NDASOP_ERROR_ALREADY_USED:
		case NDASOP_ERROR_DEVICE_FAIL:
		case NDASOP_ERROR_NOT_SINGLE_DISK:
		case NDASOP_ERROR_DEVICE_UNSUPPORTED:
		case NDASOP_ERROR_NOT_BOUND_DISK: // does not return this error
			strMsg.FormatMessage(IDS_BIND_FAIL_AT_SINGLE_NDAS_FMT, unitDisk->GetTitle());
			break;
		default:
			strMsg.LoadString(IDS_BIND_FAIL);
			break;
		}

		ShowErrorMessageBox(strMsg);
	}

	CNdasHIXChangeNotify HixChangeNotify(pGetNdasHostGuid());
	BOOL bResults = HixChangeNotify.Initialize();
	if(bResults)
	{
		NDAS_UNITDEVICE_ID unitDeviceId;
		CopyMemory(unitDeviceId.DeviceId.Node, ConnectionInfo.MacAddress, 
			sizeof(unitDeviceId.DeviceId.Node));
		unitDeviceId.UnitNo = ConnectionInfo.UnitNo;
		HixChangeNotify.Notify(unitDeviceId);
	}

	OnRefreshStatus(NULL, NULL, NULL);


}
예제 #26
0
void CMainFrame::OnContextMenu(HWND /*hWnd*/, CPoint pos)
{
	if(m_bRefreshing)
		return;

	ENTER_CRITICAL_SECTION(&m_csThreadRefreshStatus);

	CRect rect;
	CPoint posInView;
	CTreeItem itemSelected;
	m_view.GetWindowRect( rect );

	if ( !rect.PtInRect(pos) )
	{
		// If clicked point is outside the tree control, do nothing.
		LEAVE_CRITICAL_SECTION(&m_csThreadRefreshStatus);
		return;
	}
	// Change screen coordinates to client coordinates
	posInView = pos - rect.TopLeft();

	itemSelected = m_view.HitTest( posInView, NULL );

	CMenu menu;
	CMenu newSubMenu;
	CMenuHandle subMenu;

	menu.LoadMenu( MAKEINTRESOURCE(IDR_CONTEXT_MENU) );
	subMenu = menu.GetSubMenu(0);
	if ( subMenu.IsNull() )
	{
		newSubMenu.CreatePopupMenu();
		subMenu = newSubMenu;
	}
	if ( itemSelected.IsNull() )
	{
		// Display default menu
		subMenu.TrackPopupMenu(
			TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RIGHTBUTTON,
			pos.x, 
			pos.y, 
			m_hWnd
			);
	}
	else
	{
		// Change select
		m_view.SelectItem(itemSelected);

		// Display context menu
		CDiskObjectPtr obj = m_mapObject[itemSelected.GetData()];
		ATLASSERT( obj.get() != NULL );
		CObjectUIHandler::GetUIHandler(obj)->InsertMenu(obj, subMenu);
		subMenu.TrackPopupMenu(
			TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RIGHTBUTTON,
			pos.x, 
			pos.y, 
			m_hWnd
			);
	}

	LEAVE_CRITICAL_SECTION(&m_csThreadRefreshStatus);
}
예제 #27
0
LRESULT CChildFrame::OnTvnSelChanged(int idCtrl, LPNMHDR pNMHDR, BOOL& bHandled)
{ 
    USES_CONVERSION; 
    HRESULT hr = E_FAIL; 

    idCtrl, pNMHDR, bHandled; 
    CTreeViewCtrl ctrlTree = m_wndCatalog; 

    bHandled = FALSE; 

    NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR; 
    ATLASSERT( pNMTreeView ); 

    { 
        m_pData.m_hTreeItem = pNMTreeView->itemNew.hItem; 
        m_pData.m_pTreeView = &m_wndCatalog; 
    } 

    CTreeItem hItem(pNMTreeView->itemNew.hItem, &m_wndCatalog); 

    TREE_ITEM_DATA * pCurrSel = NULL; 
    pCurrSel = (TREE_ITEM_DATA *) ctrlTree.GetItemData(hItem); 

    if (pCurrSel && STGTY_STREAM == pCurrSel->dwStgType) 
    { 
        CComPtr<IStream> spStrm; 
        hr = pCurrSel->spStgOrStrm->QueryInterface(&spStrm); 
        if (FAILED(hr)) return hr; 

        STATSTG st = { 0 }; 
        hr = spStrm->Stat(&st, STATFLAG_NONAME); 
        if (FAILED(hr)) return hr; 

        LARGE_INTEGER liBegin = { 0 }; 
        hr = spStrm->Seek(liBegin, STREAM_SEEK_SET, NULL); 

        BYTE * byBuff = new BYTE[st.cbSize.QuadPart+1]; 
        ZeroMemory(byBuff, (st.cbSize.QuadPart+1)*sizeof(BYTE)); 
        ULONG ulSize = 0; 
        hr = spStrm->Read(byBuff, st.cbSize.QuadPart, &ulSize); 

		ATLASSERT(SUCCEEDED(hr));

        if(st.cbSize.QuadPart) 
        { 
            CComSafeArray data; 
            data.CreateOneDim(VT_UI1, st.cbSize.QuadPart, (const void *)byBuff); 
            m_wndHexEdit.SetData(data); 
        } 
        else 
        {
            CComVariant data; 
            m_wndHexEdit.SetData(data); 
        }

        { 
            m_wndFileDetails.ShowWindow(SW_HIDE); 
            m_wndHexEdit.ShowWindow(SW_NORMAL); 
            SetSplitterPane(SPLIT_PANE_RIGHT, m_wndHexEdit); 
        } 

        delete [] byBuff; 
    } 
    else if (pCurrSel && STGTY_STORAGE == pCurrSel->dwStgType) 
    { 
        CComVariant data; 
        m_wndHexEdit.SetData(data); 
        m_wndHexEdit.ShowWindow(SW_HIDE); 

        std::vector<STATSTG_EX> vecFileInfo; 

        CTreeItem tiChild = hItem.GetChild(); 
        while (FALSE == tiChild.IsNull()) 
        { 
            TREE_ITEM_DATA * pData = (TREE_ITEM_DATA *)tiChild.GetData(); 

            STATSTG_EX statstgex; 

            do 
            { 
                if (pData->dwStgType == STGTY_STREAM) 
                { 
                    CComPtr<IStream> spStrm; 
                    hr = pData->spStgOrStrm->QueryInterface(&spStrm); 
                    if (FAILED(hr)) break; 
                    
                    hr = spStrm->Stat(&statstgex, STATFLAG_NONAME); 
                    if (FAILED(hr)) break; 
                } 
                else if (pData->dwStgType == STGTY_STORAGE) 
                { 
                    CComPtr<IStorage> spStg; 
                    hr = pData->spStgOrStrm->QueryInterface(&spStg); 
                    if (FAILED(hr)) break; 
                    
                    hr = spStg->Stat(&statstgex, STATFLAG_NONAME); 
                    if (FAILED(hr)) break; 
                } 
            } while(0); 
            
            statstgex.htiHost = tiChild.m_hTreeItem; 
            
            TCHAR szSwap[MAX_PATH] = { 0 }; 
            tiChild.GetText(szSwap, _countof(szSwap)); 
            TCHAR2WCHAR(szSwap, statstgex.szwName, _countof(statstgex.szwName)); 
            
            vecFileInfo.push_back(statstgex); 

            tiChild = tiChild.GetNextSibling(); 
        } 

        m_wndFileDetails.SetFileInfo(vecFileInfo); 

        m_wndFileDetails.ShowWindow(SW_NORMAL); 
        SetSplitterPane(SPLIT_PANE_RIGHT, m_wndFileDetails); 
    } 

    return 0;
} 
예제 #28
0
파일: tree.cpp 프로젝트: jetlive/skiaming
BOOL CTreeItem::Expand( HTREEITEM hitem )
{
	BOOL fExpand = FALSE ;

	switch(m_Type)
	{
	case typeUnknown:
	case typeUnknown2:
	break ;

	case typeTypeLib:
		fExpand = ExpandTypeLib( hitem );
	break ;

	case typeTypeLib2:
	{
		// CTypeLibWnd::m_fGroupByType == TRUE
		CTreeItem* pItem ;

		TV_INSERTSTRUCT tvis ;
		tvis.hParent = hitem ;
		tvis.hInsertAfter = TVI_LAST ;
		tvis.item.mask = TVIF_TEXT | TVIF_CHILDREN | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE ;
		tvis.item.iImage = CTreeItem::typeUnknown ;
		tvis.item.iSelectedImage = tvis.item.iImage + 1 ;
		tvis.item.cChildren = 1 ;

		#pragma warning (suppress: 6211) // Not Leaking. pItem is inserted into m_pTree
		pItem = new CTreeItem(m_pTree) ;
		pItem->SetTypeLib( GetTypeLib() ) ;
		GetTypeLib()->AddRef() ;
		pItem->m_Type = CTreeItem::typeEnums ;
		tvis.item.lParam = (LPARAM)pItem ;
		tvis.item.pszText = _T("Enums") ;
		m_pTree->InsertItem(&tvis) ;

		pItem = new CTreeItem(m_pTree) ;
		pItem->SetTypeLib( GetTypeLib() ) ;
		GetTypeLib()->AddRef() ;
		pItem->m_Type = CTreeItem::typeRecords ;
		tvis.item.lParam = (LPARAM)pItem ;
		tvis.item.pszText = _T("Structs") ;
		m_pTree->InsertItem(&tvis) ;

		pItem = new CTreeItem(m_pTree) ;
		pItem->SetTypeLib( GetTypeLib() ) ;
		GetTypeLib()->AddRef() ;
		pItem->m_Type = CTreeItem::typeModules ;
		tvis.item.lParam = (LPARAM)pItem ;
		tvis.item.pszText = _T("Modules") ;
		m_pTree->InsertItem(&tvis) ;

		pItem = new CTreeItem(m_pTree) ;
		pItem->SetTypeLib( GetTypeLib() ) ;
		GetTypeLib()->AddRef() ;
		pItem->m_Type = CTreeItem::typeInterfaces ;
		tvis.item.lParam = (LPARAM)pItem ;
		tvis.item.pszText = _T("Interfaces") ;
		m_pTree->InsertItem(&tvis) ;

		pItem = new CTreeItem(m_pTree) ;
		pItem->SetTypeLib( GetTypeLib() ) ;
		GetTypeLib()->AddRef() ;
		pItem->m_Type = CTreeItem::typeDispinterfaces ;
		tvis.item.lParam = (LPARAM)pItem ;
		tvis.item.pszText = _T("Dispinterfaces") ;
		m_pTree->InsertItem(&tvis) ;

		pItem = new CTreeItem(m_pTree) ;
		pItem->SetTypeLib( GetTypeLib() ) ;
		GetTypeLib()->AddRef() ;
		pItem->m_Type = CTreeItem::typeCoClasses ;
		tvis.item.lParam = (LPARAM)pItem ;
		tvis.item.pszText = _T("CoClasses") ;
		m_pTree->InsertItem(&tvis) ;

		pItem = new CTreeItem(m_pTree) ;
		pItem->SetTypeLib( GetTypeLib() ) ;
		GetTypeLib()->AddRef() ;
		pItem->m_Type = CTreeItem::typeAliases ;
		tvis.item.lParam = (LPARAM)pItem ;
		tvis.item.pszText = _T("Typedefs") ;
		m_pTree->InsertItem(&tvis) ;

		pItem = new CTreeItem(m_pTree) ;
		pItem->SetTypeLib( GetTypeLib() ) ;
		GetTypeLib()->AddRef() ;
		pItem->m_Type = CTreeItem::typeUnions ;
		tvis.item.lParam = (LPARAM)pItem ;
		tvis.item.pszText = _T("Unions") ;
		m_pTree->InsertItem(&tvis) ;

		fExpand = TRUE ;
	}
	break ;

	case typeEnums:
	case typeRecords:
	case typeModules:
	case typeInterfaces:
	case typeDispinterfaces:
	case typeCoClasses:
	case typeAliases:
	case typeUnions:
		fExpand = ExpandTypeLib( hitem ) ;
	break ;

	case typeTypeInfo:
	case typeTypeInfo2:
	case typeEnum:
	case typeRecord:
	case typeModule:
	case typeInterface:
	case typeDispinterface:
	case typeCoClass:
	case typeAlias:
	case typeUnion:
		fExpand = ExpandTypeInfo( hitem ) ;
	break ;

	case typeMethods:
	case typeMethods2:
		fExpand = ExpandFuncs( hitem ) ;
	break ;

	case typeProperties:
	case typeProperties2:
	case typeConstants:
	case typeConstants2:
		fExpand = ExpandVars( hitem ) ;
	break ;

	case typeImplTypes:
	case typeImplTypes2:
		fExpand = ExpandImplTypes( hitem ) ;
	break ;

	case typeMethod:
	case typeProperty:
	case typeConstant:
	default:
	break ;
	}

	return fExpand ;
}
void
CNdasDevicePropGeneralPage::_UpdateLogDeviceData(
	ndas::UnitDevicePtr pUnitDevice)
{
	NDAS_LOGICALDEVICE_ID logDeviceId = pUnitDevice->GetLogicalDeviceId();

	ndas::LogicalDevicePtr pLogDevice;
	if (!ndas::FindLogicalDevice(pLogDevice, logDeviceId))
	{
		m_wndLogDeviceTree.DeleteAllItems();
		m_wndLogDeviceTree.ShowWindow(SW_HIDE);
		m_wndLogDeviceNA.ShowWindow(SW_SHOW);
		return;
	}
	else
	{
		m_wndLogDeviceTree.ShowWindow(SW_SHOW);
		m_wndLogDeviceNA.ShowWindow(SW_HIDE);
	}

	//
	// TODO: To handle errors
	//
	(void) pLogDevice->UpdateInfo();
	(void) pLogDevice->UpdateStatus();

	NDAS_LOGICALDEVICE_TYPE logDevType = pLogDevice->GetType();
	NDAS_LOGICALDEVICE_STATUS logDevStatus = pLogDevice->GetStatus();

	CString strStatus = pLogicalDeviceStatusString(
		logDevStatus, 
		pLogDevice->GetNdasLogicalUnitError(), 
		pLogDevice->GetMountedAccess());

	CString strType = pLogicalDeviceTypeString(logDevType);

	const NDASUSER_LOGICALDEVICE_INFORMATION* pLogDeviceInfo = pLogDevice->GetLogicalDeviceInfo();

	CString strCapacity = pBlockCapacityString(
		pLogDeviceInfo->SubType.LogicalDiskInformation.Blocks);

	CString strRootNode;
	strRootNode.Format(_T("%s (%s) - %s"), strType, strCapacity, strStatus);

	m_wndLogDeviceTree.DeleteAllItems();

	CTreeItem rootItem = m_wndLogDeviceTree.InsertItem(
		strRootNode, 
		TVI_ROOT, 
		TVI_LAST);

	CString strNodeText;
	CString strLocationCaption;
//	strLocationCaption.LoadString(IDS_LOGDEV_LOCATION);
//	strNodeText.Format(_T("%s %s"), strLocationCaption, strLocation);
//	strNodeText.Format(_T("%s"), strLocation);
//	CTreeItem tiLocation = tiRoot.AddTail(strNodeText, 0);
//	tiLocation.Expand();

	CTreeItem memberItem = rootItem; // .AddTail(_T("Members"), 0);

	//
	// Encryption information
	//
	{
		if (NULL != pLogDeviceInfo && 
			IS_NDAS_LOGICALDEVICE_TYPE_DISK(pLogDevice->GetType()) &&
			0 != pLogDeviceInfo->SubType.LogicalDiskInformation.ContentEncrypt.Revision &&
			NDAS_CONTENT_ENCRYPT_TYPE_NONE != pLogDeviceInfo->SubType.LogicalDiskInformation.ContentEncrypt.Type)
		{
			CString strNode = pNdasLogicalDiskEncryptString(pLogDeviceInfo);
			memberItem.AddTail(strNode, 0);
			// m_wndLogDeviceTree.InsertItem(strNode, TVI_ROOT, TVI_LAST);
		}
	}

	for (DWORD i = 0; i < pLogDevice->GetUnitDeviceInfoCount(); ++i) 
	{

		CString strNode;
		ndas::LogicalDevice::UNITDEVICE_INFO ui = 
			pLogDevice->GetUnitDeviceInfo(i);

		ndas::DevicePtr pMemberDevice;
		if (!ndas::FindDeviceByNdasId(pMemberDevice, ui.DeviceId))
		{
			CString strMissingDeviceId = 
				pDelimitedDeviceIdString2(CString(ui.DeviceId), m_chConcealed);

			if (0 == ui.UnitNo)
			{
				// "[%1!d!] %2!s! (Not registered)"
				strNode.FormatMessage(
					IDS_LOGICALDEVICE_ENTRY_MISSING_0_FMT, 
					ui.Index + 1,
					strMissingDeviceId);
			}
			else
			{
				// "[%1!d!] %2!s!:%3!d! (Not registered)"
				strNode.FormatMessage(
					IDS_LOGICALDEVICE_ENTRY_MISSING_0_FMT, 
					ui.Index + 1,
					strMissingDeviceId,
					ui.UnitNo + 1);
			}
			memberItem.AddTail(strNode, 0);
			continue;
		}

		ndas::UnitDevicePtr pMemberUnitDevice;

		if (!pMemberDevice->FindUnitDevice(pMemberUnitDevice, ui.UnitNo))
		{
			if (0 == ui.UnitNo)
			{
				// "[%1!d!] Unavailable (%2!s!)"
				strNode.FormatMessage(IDS_LOGICALDEVICE_ENTRY_UNAVAILABLE_0_FMT, 
					ui.Index + 1,
					pMemberDevice->GetName());
			}
			else
			{
				// "[%1!d!] Unavailable (%2!s!:%3!d!)"
				strNode.FormatMessage(IDS_LOGICALDEVICE_ENTRY_UNAVAILABLE_FMT, 
					ui.Index + 1,
					pMemberDevice->GetName(), 
					ui.UnitNo + 1);
			}
			memberItem.AddTail(strNode, 0);
			continue;
		}

		if (0 == ui.UnitNo)
		{
			// 	"[%1!d!] %2!s!"
			strNode.FormatMessage(IDS_LOGICALDEVICE_ENTRY_0_FMT, 
				ui.Index + 1, 
				pMemberDevice->GetName());
		}
		else
		{
			// 	"[%1!d!] %2!s!:%3!d! "
			strNode.FormatMessage(IDS_LOGICALDEVICE_ENTRY_FMT, 
				ui.Index + 1, 
				pMemberDevice->GetName(), 
				ui.UnitNo + 1);
		}

		memberItem.AddTail(strNode, 0);
	}

	memberItem.Expand();
	rootItem.Expand();

}
예제 #30
0
void CMainFrame::OnAddMirror(UINT /*wNotifyCode*/, int /*wID*/, HWND /*hwndCtl*/)
{
	ENTER_CRITICAL_SECTION(&m_csThreadRefreshStatus);

	CTreeItem itemSelected = m_view.GetSelectedItem();

	if ( itemSelected.IsNull() )
	{
		LEAVE_CRITICAL_SECTION(&m_csThreadRefreshStatus);
		return;
	}

	CDiskObjectList singleDisks;
	CUnitDiskObjectPtr  sourceDisk;
	sourceDisk = 
		boost::dynamic_pointer_cast<CUnitDiskObject>(
			m_mapObject[m_view.GetItemData(itemSelected)]
			);
	ATLASSERT( sourceDisk.get() != NULL );

	CFindIfVisitor<FALSE> singleDiskFinder;
	singleDisks = singleDiskFinder.FindIf(m_pRoot, IsWritableUnitDisk);
	singleDisks.remove( sourceDisk );
	if ( singleDisks.size() == 0 )
	{
		LEAVE_CRITICAL_SECTION(&m_csThreadRefreshStatus);
		// TODO : No disk is available
		WTL::CString strMsg;
		strMsg.LoadString( IDS_MAINFRAME_NO_DISK_TO_MIRROR );
		WTL::CString strTitle;
		strTitle.LoadString(IDS_APPLICATION);
		MessageBox(
			strMsg,
			strTitle, 
			MB_OK | MB_ICONWARNING
			);
		return;
	}

	DWORD UnitNo = 0;
	CSelectMirDlg dlgSelDisk(IDD_ADDMIR);
	dlgSelDisk.SetSingleDisks( singleDisks );
	dlgSelDisk.SetSourceDisk( sourceDisk );
	if ( dlgSelDisk.DoModal() == IDOK )
	{
		CUnitDiskObjectPtr mirDisk = dlgSelDisk.GetSelectedDisk();

		// Bind & Synchronize 
		NDAS_CONNECTION_INFO ConnectionInfo[2];

		ZeroMemory(&ConnectionInfo[0], sizeof(NDAS_CONNECTION_INFO));

		ConnectionInfo[0].type = NDAS_CONNECTION_INFO_TYPE_MAC_ADDRESS;
		ConnectionInfo[0].UnitNo = sourceDisk->GetLocation()->GetUnitDiskLocation()->UnitNumber;
		ConnectionInfo[0].bWriteAccess = TRUE;
		ConnectionInfo[0].ui64OEMCode = NULL;
		ConnectionInfo[0].protocol = IPPROTO_LPXTCP;
		CopyMemory(ConnectionInfo[0].MacAddress, 
				sourceDisk->GetLocation()->GetUnitDiskLocation()->MACAddr,
			LPXADDR_NODE_LENGTH);

		ZeroMemory(&ConnectionInfo[1], sizeof(NDAS_CONNECTION_INFO));

		ConnectionInfo[1].type = NDAS_CONNECTION_INFO_TYPE_MAC_ADDRESS;
		ConnectionInfo[1].UnitNo = mirDisk->GetLocation()->GetUnitDiskLocation()->UnitNumber;
		ConnectionInfo[1].bWriteAccess = TRUE;
		ConnectionInfo[1].ui64OEMCode = NULL;
		ConnectionInfo[1].protocol = IPPROTO_LPXTCP;
		CopyMemory(ConnectionInfo[1].MacAddress, 
			mirDisk->GetLocation()->GetUnitDiskLocation()->MACAddr,
			LPXADDR_NODE_LENGTH);

		UINT32 BindResult = NdasOpBind(
			2,
			ConnectionInfo,
			NMT_SAFE_RAID1);

		if(2 != BindResult)
		{
	LEAVE_CRITICAL_SECTION(&m_csThreadRefreshStatus);

			WTL :: CString strMsg;

			DWORD dwLastError = ::GetLastError();

			switch(dwLastError)
	{
			case NDASCOMM_ERROR_RW_USER_EXIST:
			case NDASOP_ERROR_ALREADY_USED:
			case NDASOP_ERROR_DEVICE_FAIL:
			case NDASOP_ERROR_NOT_SINGLE_DISK:
			case NDASOP_ERROR_DEVICE_UNSUPPORTED:
				strMsg.FormatMessage(IDS_BIND_FAIL_AT_SINGLE_NDAS_FMT, 
					(BindResult == 0) ? sourceDisk->GetTitle() : mirDisk->GetTitle());
				break;
			default:
				strMsg.LoadString(IDS_BIND_FAIL);
				break;
	}

			ShowErrorMessageBox(strMsg);

		return;
	}

		CNdasHIXChangeNotify HixChangeNotify(pGetNdasHostGuid());
		BOOL bResults = HixChangeNotify.Initialize();
		if(bResults)
		{
			NDAS_UNITDEVICE_ID unitDeviceId;

			CopyMemory(unitDeviceId.DeviceId.Node, 
				sourceDisk->GetLocation()->GetUnitDiskLocation()->MACAddr, 
				sizeof(unitDeviceId.DeviceId.Node));
			unitDeviceId.UnitNo = 
				sourceDisk->GetLocation()->GetUnitDiskLocation()->UnitNumber;
			HixChangeNotify.Notify(unitDeviceId);

			CopyMemory(unitDeviceId.DeviceId.Node, 
				mirDisk->GetLocation()->GetUnitDiskLocation()->MACAddr, 
				sizeof(unitDeviceId.DeviceId.Node));
			unitDeviceId.UnitNo = 
				mirDisk->GetLocation()->GetUnitDiskLocation()->UnitNumber;
			HixChangeNotify.Notify(unitDeviceId);
		}

		CRecoverDlg dlgRecover(TRUE, IDS_LOGDEV_TYPE_DISK_RAID1, IDS_RECOVERDLG_TASK_ADD_MIRROR);

		dlgRecover.SetMemberDevice(mirDisk);
		dlgRecover.DoModal();

		OnRefreshStatus(NULL, NULL, NULL);
	}

	LEAVE_CRITICAL_SECTION(&m_csThreadRefreshStatus);
}