Example #1
0
void CFileView::OnContextMenu(CWnd* pWnd, CPoint point)
{
	CTreeCtrl* pWndTree = (CTreeCtrl*) &m_wndFileView;
	ASSERT_VALID(pWndTree);

	if (pWnd != pWndTree)
	{
		CDockablePane::OnContextMenu(pWnd, point);
		return;
	}

	pWndTree->SetFocus();
	UINT uID = IDR_POPUP_EXPLORER;
	if (point != CPoint(-1, -1))
	{
		// Select clicked item:
		CPoint ptTree = point;
		pWndTree->ScreenToClient(&ptTree);

		UINT flags = 0;
		HTREEITEM hTreeItem = pWndTree->HitTest(ptTree, &flags);
		if (hTreeItem != NULL)
		{
			pWndTree->SelectItem(hTreeItem);
			if (pWndTree->GetItemData(hTreeItem))
			{
				uID = IDR_MENU_GROUP;
			}
			theApp.GetContextMenuManager()->ShowPopupMenu(uID, point.x, point.y, this, TRUE);
		}
	}
}
Example #2
0
void CSiteView::OnAddRecorder()
{
	CTreeCtrl* pWndTree = (CTreeCtrl*)&m_wndSiteView;
	HTREEITEM hTreeItem = pWndTree->GetSelectedItem();
	SITE_T * site = (SITE_T*)pWndTree->GetItemData(hTreeItem);

	RecorderDlg dlg(site->uuid);
	dlg.DoModal();
	FillSiteView();
}
Example #3
0
void CSiteView::OnRemoveSite()
{
	CTreeCtrl* pWndTree = (CTreeCtrl*)&m_wndSiteView;
	HTREEITEM hTreeItem = pWndTree->GetSelectedItem();
	SITE_T * site = (SITE_T*)pWndTree->GetItemData(hTreeItem);

	SiteDAO siteDao;
	siteDao.DeleteSite(site);

	FillSiteView();
}
Example #4
0
void CSiteView::OnRemoveRecorder()
{
	CTreeCtrl* pWndTree = (CTreeCtrl*)&m_wndSiteView;
	HTREEITEM hTreeItem = pWndTree->GetSelectedItem();
	RECORDER_T * recorder = (RECORDER_T*)pWndTree->GetItemData(hTreeItem);

	RecorderDAO recorderDao;
	recorderDao.DeleteRecorder(recorder->parent, recorder);

	FillSiteView();
}
Example #5
0
CTreeItem* CdIpmDoc::GetSelectedTreeItem()
{
	CTreeCtrl* pTree = m_pTreeGD->GetPTree();
	HTREEITEM hItem  = pTree->GetSelectedItem();
	if (hItem) 
	{
		CTreeItem* pItem = (CTreeItem*)pTree->GetItemData(hItem);
		return pItem;
	}
	return NULL;
}
Example #6
0
void CSiteView::OnPlayRelay()
{
	CFrameWnd * pFrame = (CFrameWnd *)(AfxGetApp()->m_pMainWnd);
	CHTRecorderManagerView * videoView = (CHTRecorderManagerView*)pFrame->GetActiveView();
	if (videoView)
	{
		CTreeCtrl* pWndTree = (CTreeCtrl*)&m_wndSiteView;
		HTREEITEM hTreeItem = pWndTree->GetSelectedItem();
		CAMERA_T * camera = (CAMERA_T*)pWndTree->GetItemData(hTreeItem);
		
		videoView->StartRelay(camera->parent->uuid, camera->parent->address, camera->parent->username, camera->parent->pwd, camera->uuid, camera->key, 0);
	}
}
Example #7
0
// @pymethod object|PyCTreeCtrl|GetItemData|Retrieves the application-specific value associated with an item.
PyObject *PyCTreeCtrl_GetItemData( PyObject *self, PyObject *args )
{
	PyObject *obItem;
	if (!PyArg_ParseTuple( args, "O:GetItemData",
	                   &obItem)) // @pyparm HTREEITEM|item||The index of the item whose data is to be retrieved.

		return NULL;
	CTreeCtrl *pList = GetTreeCtrl(self);
	if (!pList) return NULL;
	HTREEITEM item;
	if (!PyWinObject_AsHANDLE(obItem, (HANDLE *)&item))
		return NULL;
	GUI_BGN_SAVE;
	DWORD_PTR rc = pList->GetItemData(item);
	GUI_END_SAVE;
	return PyWinObject_FromDWORD_PTR(rc);
}
Example #8
0
BOOL CTestTreeView::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
	// TODO: Add your specialized code here and/or call the base class

	NMHDR* pNMHDR = (NMHDR*)lParam;
	ASSERT(pNMHDR != NULL);
	switch (pNMHDR->code)
	{
 	case TVN_SELCHANGED:
 		{
 			//OnNotifySelChanged(wParam, lParam, pResult); 
 			//AfxMessageBox(_T("Slect..."));
			//showData->helpDescription;
			//showData->setting = false;
			//showData->property = &((*testIt).property);
			


 			break;
 		}
	case NM_DBLCLK:
		{
			//m_wndFileView.GetItem();
			//OnNotifyDBClick(wParam, lParam, pResult);
			CTreeCtrl* pWndTree = (CTreeCtrl*) &m_wndTestTreeView;

			HTREEITEM ht = pWndTree->GetSelectedItem();
			CTlsData *showData = (CTlsData*)pWndTree->GetItemData(ht);


			CMainFrame* pMainFrame= (CMainFrame*)AfxGetMainWnd();
			pMainFrame->SetPropertiesWnd(showData);
			//AfxMessageBox(_T("Double Clieck..."));
		
			break;
		}
	default:
		break;
	}

	return CDockablePane::OnNotify(wParam, lParam, pResult);
}
Example #9
0
HTREEITEM DLitbookTree::FindItem(CTreeCtrl& tree, HTREEITEM item, DWORD strText,int* findLevel,int* curLevel)
{
	HTREEITEM hFind;	
	if(item == NULL)
		return NULL;

	while(item != NULL)
	{
		if(*findLevel==*curLevel)
		{
			//只有在到达指定深度时,才比较
			DWORD cc=tree.GetItemData(item);
			if(cc == strText)
				return item;
		}

		if(tree.ItemHasChildren(item))
		{
			(*curLevel)++;//深度加一
			item = tree.GetChildItem(item);
			hFind = FindItem(tree, item, strText,findLevel,curLevel);		
			if(hFind)
			{
				return hFind;		
			}
			else
			{
				item= tree.GetNextSiblingItem(tree.GetParentItem(item));
				(*curLevel)--;//深度减一
			}
		}
		else
		{
			item = tree.GetNextSiblingItem(item);
			if(item == NULL)
				return NULL;
		}		
	}

	return item;
}
Example #10
0
void CSiteView::OnContextMenu(CWnd* pWnd, CPoint point)
{
	CTreeCtrl* pWndTree = (CTreeCtrl*)&m_wndSiteView;
	ASSERT_VALID(pWndTree);

	if (pWnd != pWndTree)
	{
		CDockablePane::OnContextMenu(pWnd, point);
		return;
	}

	if (point != CPoint(-1, -1))
	{
		// Select clicked item:
		CPoint ptTree = point;
		pWndTree->ScreenToClient(&ptTree);

		UINT flags = 0;
		HTREEITEM hTreeItem = pWndTree->HitTest(ptTree, &flags);
		if (hTreeItem != NULL)
		{
			pWndTree->SelectItem(hTreeItem);
		}
	}
	HTREEITEM item = pWndTree->GetSelectedItem();
	TREE_T * item_data = (TREE_T*)pWndTree->GetItemData(item);
	pWndTree->SetFocus();

	if (item_data == NULL)
		theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_ROOT, point.x, point.y, this, TRUE);
	else if (item_data->tree_level == TREE_LEVEL_SITE)
		theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_SITES, point.x, point.y, this, TRUE);
	else if (item_data->tree_level == TREE_LEVEL_RECORDER)
		theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_RECORDER, point.x, point.y, this, TRUE);
	else if (item_data->tree_level==TREE_LEVEL_CAMERA)
		theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_CAMERA, point.x, point.y, this, TRUE);

}
Example #11
0
HTREEITEM GetTreeItemFromData(CTreeCtrl& treeCtrl, DWORD dwData, HTREEITEM hStartAtItem /*=NULL*/)
{
	// Traverse from given item (or all items if hFromItem is NULL)
	HTREEITEM hItem;
	if ( hStartAtItem )
		hItem=hStartAtItem;
	else
		hItem = treeCtrl.GetRootItem();

	while ( hItem )
	{
		if ( dwData == (DWORD)treeCtrl.GetItemData( hItem ) )
			return hItem;

		// Get first child node
		HTREEITEM hNextItem = treeCtrl.GetChildItem( hItem );

		if ( !hNextItem )
		{
			// Get next sibling child
			hNextItem = treeCtrl.GetNextSiblingItem( hItem );

			if ( !hNextItem )
			{
				HTREEITEM hParentItem=hItem;
				while ( !hNextItem && hParentItem )
				{
					// No more children: Get next sibling to parent
					hParentItem = treeCtrl.GetParentItem( hParentItem );
					hNextItem = treeCtrl.GetNextSiblingItem( hParentItem );
				}
			}
		}
		hItem = hNextItem;
	}
	return NULL;
}
Example #12
0
void RenameVolumeDialog::OnSelChanged(NMHDR* pnmh, LRESULT* pResult)
{
    CTreeCtrl* pTree = (CTreeCtrl*) GetDlgItem(IDC_RENAMEVOL_TREE);
    HTREEITEM selected;
    CString newText;

    selected = pTree->GetSelectedItem();
    if (selected != NULL) {
        DiskFSTree::TargetData* pTargetData;
        pTargetData = (DiskFSTree::TargetData*) pTree->GetItemData(selected);
        if (pTargetData->selectable) {
            newText = pTargetData->pDiskFS->GetBareVolumeName();
        } else {
            newText = "";
        }
    }
    
    CEdit* pEdit = (CEdit*) GetDlgItem(IDC_RENAMEVOL_NEW);
    ASSERT(pEdit != NULL);
    pEdit->SetWindowText(newText);
    pEdit->SetSel(0, -1);

    *pResult = 0;
}
Example #13
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;
}
Example #14
0
void RenameVolumeDialog::DoDataExchange(CDataExchange* pDX)
{
    CString msg, failed;
    //DiskImgLib::DiskFS*   pDiskFS = fpArchive->GetDiskFS();

    CheckedLoadString(&failed, IDS_MB_APP_NAME);

    /* put fNewName last so it gets the focus after failure */
    DDX_Text(pDX, IDC_RENAMEVOL_NEW, fNewName);

    /* validate the path field */
    if (pDX->m_bSaveAndValidate) {
        /*
         * Make sure they chose a volume that can be modified.
         */
        CTreeCtrl* pTree = (CTreeCtrl*) GetDlgItem(IDC_RENAMEVOL_TREE);
        CString errMsg, appName;
        CheckedLoadString(&appName, IDS_MB_APP_NAME);

        HTREEITEM selected;
        selected = pTree->GetSelectedItem();
        if (selected == NULL) {
            errMsg = "Please select a disk to rename.";
            MessageBox(errMsg, appName, MB_OK);
            pDX->Fail();
            return;
        }

        DiskFSTree::TargetData* pTargetData;
        pTargetData = (DiskFSTree::TargetData*) pTree->GetItemData(selected);
        if (!pTargetData->selectable) {
            errMsg = "You can't rename that volume.";
            MessageBox(errMsg, appName, MB_OK);
            pDX->Fail();
            return;
        }
        ASSERT(pTargetData->kind == DiskFSTree::kTargetDiskFS);

        /*
         * Verify that the new name is okay.  (Do this *after* checking the
         * volume above to avoid spurious complaints about unsupported
         * filesystems.)
         */
        if (fNewName.IsEmpty()) {
            msg = "You must specify a new name.";
            goto fail;
        }
        msg = fpArchive->TestVolumeName(pTargetData->pDiskFS, fNewName);
        if (!msg.IsEmpty())
            goto fail;


        /*
         * Looks good.  Fill in the answer.
         */
        fpChosenDiskFS = pTargetData->pDiskFS;
    }

    return;

fail:
    ASSERT(!msg.IsEmpty());
    MessageBox(msg, failed, MB_OK);
    pDX->Fail();
    return;
}
Example #15
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;
}
Example #16
0
void CuListCtrlLoggedEvent::OnMouseMove(UINT nFlags, CPoint point) 
{
	CPoint p = point;
	ClientToScreen (&p);
	CPoint pDragMove = p;

	if (!m_pEventSettingFrame)
		m_pEventSettingFrame = (CfEventSetting*)GetParentFrame();
	ASSERT (m_pEventSettingFrame);
	if (!m_pEventSettingFrame)
	{
		CuListCtrlVScrollEvent::OnMouseMove(nFlags, point);
		return;
	}
	m_pEventSettingFrame->ScreenToClient(&pDragMove);

	if (!m_bDragging)
	{
		CuListCtrlVScrollEvent::OnMouseMove(nFlags, point);
		return;
	}
	
	ASSERT(m_pImageListDrag != NULL);
	m_pImageListDrag->DragMove(pDragMove);  // move the image
	m_pImageListDrag->DragLeave(/*this*/GetParentFrame());

	//
	// Determine the pane under the mouse pointer:
	CRect rFrame, rLeftTree, rRightTree, rBottomList;
	m_pEventSettingFrame->GetWindowRect (rFrame);

	CvEventSettingLeft*   pLeftView  = m_pEventSettingFrame->GetLeftView();
	CvEventSettingRight*  pRightView = m_pEventSettingFrame->GetRightView();
	CvEventSettingBottom* pBottomView= m_pEventSettingFrame->GetBottomView();
	if (!(pLeftView && pRightView && pBottomView))
	{
		CuListCtrlVScrollEvent::OnMouseMove(nFlags, point);
		return;
	}
	CTreeCtrl* pTreeLeft  = pLeftView->GetTreeCtrl();
	CTreeCtrl* pTreeRight = pRightView->GetTreeCtrl();
	CListCtrl* pListBottom= pBottomView->GetListCtrl();
	if (!(pTreeLeft && pTreeRight && pListBottom))
	{
		CuListCtrlVScrollEvent::OnMouseMove(nFlags, point);
		return;
	}

	pTreeLeft->GetWindowRect  (rLeftTree);
	pTreeRight->GetWindowRect (rRightTree);
	pListBottom->GetWindowRect(rBottomList);
	
	CWnd* pWndTarget = NULL;
	CPoint cursorPos;
	GetCursorPos (&cursorPos);

	int nPane = 0;
	if (rFrame.PtInRect (cursorPos))
	{
		if (rLeftTree.PtInRect (cursorPos))
		{
			pWndTarget = pTreeLeft;
			nPane = 1;
		}
		else
		if (rRightTree.PtInRect (cursorPos))
		{
			pWndTarget = pTreeRight;
			nPane = 2;
		}
		else
		if (rBottomList.PtInRect (cursorPos))
		{
			pWndTarget = pListBottom;
			nPane = 3;
		}
	}

	if (nPane == 1 || nPane == 2)
	{
		CTreeCtrl* pTree = NULL;
		if (nPane == 1)
			pTree = pTreeLeft;
		else
			pTree = pTreeRight;

		UINT flags, nAction = 0;
		HTREEITEM hTreeItemTarget = NULL;
		CaMessageNode* pNodeTarget = NULL;
		CPoint pt = point;
		pt.y += 8;
		ClientToScreen (&pt);

		pTree->ScreenToClient(&pt);
		hTreeItemTarget = pTree->HitTest (pt, &flags);
		if (hTreeItemTarget && (flags&TVHT_ONITEM))
		{
			pTree->SelectItem (hTreeItemTarget);
			pNodeTarget = (CaMessageNode*)pTree->GetItemData (hTreeItemTarget);
			nAction = GetCompatibleSourceTarget(pTree,pNodeTarget->GetNodeInformation());
		}
		TRACE1 ("DD Action = %x\n", nAction);

		if (nAction != 0)
			::SetCursor (theApp.m_hCursorDropCategory);
		else
			::SetCursor (theApp.m_hCursorNoDropCategory);
	}
	else
	{
		::SetCursor (theApp.m_hCursorNoDropCategory);
	}
	m_pImageListDrag->DragEnter(GetParentFrame(), pDragMove);  // lock updates and show drag image

	CuListCtrlVScrollEvent::OnMouseMove(nFlags, point);
}
Example #17
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;
}
Example #18
0
void CIISConfigHelper::PopulateTreeFromFileSystem(CTreeCtrl& cTree, HTREEITEM htParent, const std::set<CStringW>& IgnoreDirNames, int nMaxDepth)
{
	if (htParent == NULL)
		return;	

	// get the item data from the tree item
	IISURIItem* pParentItem = (IISURIItem*) cTree.GetItemData(htParent);
	if (pParentItem == NULL)
	{
		ASSERT(pParentItem != NULL);
		return;
	}

	// if the item is incomplete then we need to get it's file system path
	if (pParentItem->Type == IISURIItem::IncompleteFileSystemPath && pParentItem->sFileSystemPath.GetLength() <= 0)
	{
		// get the grand parent item
		HTREEITEM htGrandParent = cTree.GetParentItem(htParent);
		if (htGrandParent == NULL)
		{
			ASSERT(htGrandParent != NULL);
			return;
		}		

		// get the grand parent item data
		IISURIItem* pGrandParentItem = (IISURIItem*) cTree.GetItemData(htGrandParent);
		if (pGrandParentItem == NULL)
		{
			ASSERT(pGrandParentItem != NULL);
			return;
		}

		// the grand parent MUST not be incomplete
		if (pGrandParentItem->Type == IISURIItem::IncompleteFileSystemPath)
		{
			ASSERT(pGrandParentItem->Type != IISURIItem::IncompleteFileSystemPath);
			return;
		}

		// get the item name
		CStringW sName = CStringW(cTree.GetItemText(htParent));
		if (sName.GetLength() <= 0)
		{
			ASSERT(sName.GetLength() > 0);
			return;
		}

		// make the path to the parent item
		CPathT<CStringW> ItemFileSystemPath(pGrandParentItem->sFileSystemPath);
		ItemFileSystemPath.Append(sName);

		// assign the new file system path and set the type
		pParentItem->sFileSystemPath = (LPCWSTR) ItemFileSystemPath;
		pParentItem->Type = IISURIItem::FileSystem;
	}

	// if the item already has children then we need to build up a list of their names
	std::set<CStringW> KnownDirs;
	if (cTree.ItemHasChildren(htParent) == TRUE)
	{
		// loop through all the children
		HTREEITEM htChild = cTree.GetChildItem(htParent);
		while (htChild != NULL)
		{
			// get the child name
			CStringW sName = CStringW(cTree.GetItemText(htChild));

			// we need lower case so we can compare easier
			sName.MakeLower();

			// add the name to the known list
			KnownDirs.insert(sName);

			// move on to the next child item
			htChild = cTree.GetNextSiblingItem(htChild);
		}
	}

#ifdef _DEBUG
	ATLTRACE2(L"CIISConfigHelper::PopulateTreeFromFileSystem() : searching '%s'\n", pParentItem->sFileSystemPath);
#endif

	// create a search string
	CPathT<CStringW> FileSystemPath(pParentItem->sFileSystemPath);
	FileSystemPath.Append(L"*.*");
	CStringW sSearchPath = (LPCWSTR) FileSystemPath;	

	// start the search
	WIN32_FIND_DATAW FindData;	
	HANDLE hFind = ::FindFirstFileW(sSearchPath, &FindData);
	if (hFind == INVALID_HANDLE_VALUE)
	{
		// TODO: empty
		return;
	}

	CArray<CStringW, LPCWSTR> saDirs;	

	// guess that we will have 32 sub dirs (the array will grow if we have more)
	saDirs.SetSize(32);

	// keep track of the number of dirs we have actually found
	int nDirsFound = 0;

	do
	{		
		if ((FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
			continue;		

		// eliminate . and .. from the search
		if (FindData.cFileName[0] == '.')
		{
			if (FindData.cFileName[1] == '\0')
			{
				continue;
			}
			else if (FindData.cFileName[1] == '.' && FindData.cFileName[2] == '\0')
			{
				continue;
			}
		}		
			
		// convert to lower case
		CStringW sTempFileName = FindData.cFileName;
		sTempFileName.MakeLower();

		// only add to the collection if we don't already know about it
		if (KnownDirs.find(sTempFileName) != KnownDirs.end())
			continue;

		// if it's a known ignore dir name - then ignore it
		if (IgnoreDirNames.find(sTempFileName) != IgnoreDirNames.end())
			continue;
		
#ifdef _DEBUG
		ATLTRACE2(L"CIISConfigHelper::PopulateTreeFromFileSystem() : found '%s'\n", FindData.cFileName);
#endif

		saDirs.SetAtGrow(nDirsFound, FindData.cFileName);		

		// we have found one
		nDirsFound++;
	}
	while (::FindNextFileW(hFind, &FindData) == TRUE);	

	// get rid of the find handle
	::FindClose(hFind);
	hFind = NULL;	
	
	if (nDirsFound <= 0)
	{		
		return;
	}

	if (nMaxDepth <= 0)
	{
		cTree.InsertItem(EmptyNodeString, htParent);
		return;
	}

	for (int i = 0; i < nDirsFound; i++)
	{
		CString sDir(saDirs[i]);
		HTREEITEM htChild = cTree.InsertItem(sDir, htParent);		

		// create the child file system path
		CPathT<CStringW> FileSystemPath(pParentItem->sFileSystemPath);
		FileSystemPath.Append(saDirs[i]);

		// we need an item data for this tree item
		IISURIItem* pChildItem = new IISURIItem;
		pChildItem->Type = IISURIItem::FileSystem;
		pChildItem->sFileSystemPath = (LPCWSTR) FileSystemPath;

		// make the child URI
		CStringW sChildURI = pParentItem->sURI;
		int nChildURILength = sChildURI.GetLength();
		if (nChildURILength > 0 && sChildURI[nChildURILength - 1] != '/')
			sChildURI += '/';

		// append the dir name
		sChildURI += saDirs[i];

		// assign the URI to the item data
		pChildItem->sURI = sChildURI;

		// store the item data
		cTree.SetItemData(htChild, (DWORD_PTR) pChildItem);

		PopulateTreeFromFileSystem(cTree, htChild, IgnoreDirNames, nMaxDepth - 1);
	}
}
Example #19
0
void CuListCtrlLoggedEvent::OnButtonUp(CPoint point)
{
	try
	{
		UINT flags = 0;
		UINT nFlags = 0;
		CPoint p = point;
		ClientToScreen (&p);

		if (!m_bDragging)
			return;
		m_bDragging = FALSE;

		ASSERT(m_pImageListDrag != NULL);
		m_pImageListDrag->DragLeave(GetParentFrame());
		m_pImageListDrag->EndDrag();
		delete m_pImageListDrag;
		m_pImageListDrag = NULL;

		if (m_iItemDrag == -1)
			return;

		//
		// Determine the pane under the mouse pointer:
		CRect rFrame, rLeftTree, rRightTree, rBottomList;
		m_pEventSettingFrame->GetWindowRect (rFrame);

		CvEventSettingLeft*   pLeftView  = m_pEventSettingFrame->GetLeftView();
		CvEventSettingRight*  pRightView = m_pEventSettingFrame->GetRightView();
		CvEventSettingBottom* pBottomView= m_pEventSettingFrame->GetBottomView();
		if (!(pLeftView && pRightView && pBottomView))
			return;
		CTreeCtrl* pTreeLeft  = pLeftView->GetTreeCtrl();
		CTreeCtrl* pTreeRight = pRightView->GetTreeCtrl();
		CListCtrl* pListBottom= pBottomView->GetListCtrl();
		if (!(pTreeLeft && pTreeRight && pListBottom))
			return;

		pTreeLeft->GetWindowRect  (rLeftTree);
		pTreeRight->GetWindowRect (rRightTree);
		pListBottom->GetWindowRect(rBottomList);
		
		CWnd* pWndTarget = NULL;
		CPoint cursorPos;
		GetCursorPos (&cursorPos);

		int nPane = 0;
		if (rFrame.PtInRect (cursorPos))
		{
			if (rLeftTree.PtInRect (cursorPos))
			{
				pWndTarget = pTreeLeft;
				nPane = 1;
			}
			else
			if (rRightTree.PtInRect (cursorPos))
			{
				pWndTarget = pTreeRight;
				nPane = 2;
			}
			else
			if (rBottomList.PtInRect (cursorPos))
			{
				pWndTarget = pListBottom;
				nPane = 3;
			}
		}

		if (nPane == 1 || nPane == 2)
		{
			CTreeCtrl* pTree = NULL;
			CListCtrl* pListCtrl = pListBottom; 

			if (nPane == 1)
				pTree = pTreeLeft;
			else
				pTree = pTreeRight;

			UINT flags, nAction = 0;
			HTREEITEM hTreeItemTarget = NULL;
			CaMessageNode* pNodeTarget = NULL;
			CPoint pt = point;
			pt.y += 8;
			ClientToScreen (&pt);

			pTree->ScreenToClient(&pt);
			hTreeItemTarget = pTree->HitTest (pt, &flags);
			if (hTreeItemTarget && (flags&TVHT_ONITEM))
			{
				pTree->SelectItem (hTreeItemTarget);
				pNodeTarget = (CaMessageNode*)pTree->GetItemData (hTreeItemTarget);

				nAction = GetCompatibleSourceTarget(pTree, pNodeTarget->GetNodeInformation());
				NewUserMessage (nPane, nAction, pTree, pNodeTarget, pListCtrl);
			}
		}
	}
	catch (...)
	{
		TRACE0 ("Internal error(1): CuListCtrlLoggedEvent::OnButtonUp \n");
	}
	::ReleaseCapture();
}