Пример #1
0
//
// For sorting files and dirs (dirs go before files)
//
static int CALLBACK
DirFileCompareProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) {
	CTreeCtrl *pTreeCtrl = (CTreeCtrl *) lParamSort;
	HTREEITEM hItem1 = (HTREEITEM) lParam1;
	HTREEITEM hItem2 = (HTREEITEM) lParam2;

	int nImage1, nSelImage1;
	pTreeCtrl->GetItemImage(hItem1, nImage1, nSelImage1);
	int nImage2, nSelImage2;
	pTreeCtrl->GetItemImage(hItem2, nImage2, nSelImage2);

	if (nImage1 == ICON_DIR && nImage2 >= ICON_FILE)
		return -1;
	else if (nImage1 >= ICON_FILE && nImage2 == ICON_DIR)
		return 1;
	else {
		CString strItem1 = pTreeCtrl->GetItemText(hItem1);
		CString strItem2 = pTreeCtrl->GetItemText(hItem2);
		return strItem1.CompareNoCase(strItem2);
	}
}
static int CALLBACK DirThenFileAplhaCB(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
    int retVal = 0;
    CTreeCtrl* pTreeCtrl = (CTreeCtrl*)lParamSort;
    
    if(pTreeCtrl != NULL)
    {
        int img1A, img1B, img2A, img2B;

        FileTreeItemData* ftidItem1 = (FileTreeItemData*)lParam1;
        FileTreeItemData* ftidItem2 = (FileTreeItemData*)lParam2;

        if((ftidItem1 != NULL) && (ftidItem2 != NULL))
        {
            HTREEITEM hItem1 = ftidItem1->hItem;
            HTREEITEM hItem2 = ftidItem2->hItem;

            if((hItem1 != NULL) && (hItem2 != NULL))
            {
                pTreeCtrl->GetItemImage(hItem1, img1A, img1B);
                pTreeCtrl->GetItemImage(hItem2, img2A, img2B);

                int folderImage = GetSysIlIndex(TEXT("\\"));

                CString itemStr1 = pTreeCtrl->GetItemText(hItem1);
                CString itemStr2 = pTreeCtrl->GetItemText(hItem2);

                if(ftidItem1->isDir && ftidItem2->isDir)
                {
                    retVal = itemStr1.CompareNoCase(itemStr2);
                }
                else if(ftidItem1->isDir)
                {
                    retVal = -1;
                }
                else if(ftidItem2->isDir)
                {
                    retVal = 1;
                }
                else
                {
                    retVal = itemStr1.CompareNoCase(itemStr2);
                }   
            }
        }
    }

    return retVal;
}
Пример #3
0
// @pymethod (int,int)|PyCTreeCtrl|GetItemImage|Retrieves the index of an items images.
// @pyparm HTREEITEM|item||The specified item
PyObject *PyCTreeCtrl_GetItemImage( PyObject *self, PyObject *args ) 
{
	PyObject *obItem;
	if (!PyArg_ParseTuple( args, "O:GetItemImage", &obItem))
		return NULL;

	CTreeCtrl *pList = GetTreeCtrl(self);
	if (!pList) return NULL;
	HTREEITEM item;
	if (!PyWinObject_AsHANDLE(obItem, (HANDLE *)&item))
		return NULL;
	int res1, res2;
	GUI_BGN_SAVE;
	BOOL ok = pList->GetItemImage(item, res1, res2);
	GUI_END_SAVE;
	if (!ok)
		RETURN_ERR("GetItemImage failed");
	return Py_BuildValue("ii",res1, res2);
}
Пример #4
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;
}
Пример #5
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;
}
Пример #6
0
static bool IsTreeItemFolder(CTreeCtrl& m_TreeControl, HTREEITEM item)
{
  int image = 0, selected = 0;
  m_TreeControl.GetItemImage(item, image, selected);
  return (image == 1 && selected == 2) ? true : false;
}