Example #1
0
void CMainFrame::FindNode(CTreeItem h_parent, CString str)
{
    _ConnectionPtr tempconn;
    _RecordsetPtr temprecord;
    tempconn.CreateInstance(__uuidof(Connection));
    temprecord.CreateInstance(__uuidof(Recordset));
    tempconn->ConnectionString = m_runsql.m_database->ConnectionString;
    tempconn->Open("", "", "", -1);

    CString sql;
    sql.Format(L"select id, parent_class, class_name from custom_class where parent_class=%s", str);
    temprecord = tempconn->Execute((_bstr_t)sql, 0, adCmdText);
    CString name, parent_class;
    CTreeItem h_temp;
    while (!temprecord->adoEOF)
    {
        parent_class = (LPCTSTR)(_bstr_t)temprecord->GetCollect("id");
        name = (LPCTSTR)(_bstr_t)temprecord->GetCollect("class_name");
        h_temp = m_MenuTree.InsertItem(name, 5, 5, h_parent,NULL);

        FindNode(h_temp, parent_class);

        temprecord->MoveNext();
    }
    h_parent.Expand();
}
Example #2
0
void CTypeLibTreeView::OnTreeItemExpanding(NMHDR* pNMHDR, LRESULT* pResult)
{
	*pResult = 0 ;
	NM_TREEVIEW* pnmtv = (NM_TREEVIEW*)pNMHDR;

	if ((pnmtv->action != TVE_EXPAND && pnmtv->itemNew.lParam) ||
		(pnmtv->itemNew.state & TVIS_EXPANDEDONCE))
		return ;

	CTreeItem*  pItem = (CTreeItem*)pnmtv->itemNew.lParam ;
	if (pItem == NULL)
		return ;
	ASSERT(pItem->IsKindOf(RUNTIME_CLASS(CTreeItem)));

	BeginWaitCursor() ;
	m_tree.SetRedraw( FALSE ) ;

	*pResult = !pItem->Expand(  pnmtv->itemNew.hItem ) ;

	// No children
	if (*pResult == TRUE)
	{
		TV_ITEM item ;
		item.cChildren = 0 ;
		item.mask = TVIF_CHILDREN ;
		item.hItem = pnmtv->itemNew.hItem ;
		m_tree.SetItem( &item ) ;
	}

	m_tree.SetRedraw( TRUE ) ;
	EndWaitCursor() ;
}
Example #3
0
void CMainFrame::InitLeftTreeView(CTreeViewCtrlEx *m_pTreeView)
{
    int nIconIndexNormal = -1, nIconIndexSelected = -1;
    HICON hIcon = NULL;

    // NOTE: Don't Load using the LR_LOADTRANSPARENT bit, because the icon
    //  already properly deals with transparency (setting it causes problems).
    //  We will load this as LR_SHARED so that we don't have to do a DeleteIcon.
    m_LeftTreeImageList.Create(16, 16, ILC_COLOR32 | ILC_MASK, 10, 30);

    hIcon = (HICON)::LoadImage(_Module.GetResourceInstance(),
                               MAKEINTRESOURCE(IDI_ICON1),IMAGE_ICON, 16, 16, LR_SHARED);
    nIconIndexNormal = m_LeftTreeImageList.AddIcon(hIcon);
    nIconIndexSelected = nIconIndexNormal;

    int nIconFolderIndexNormal = -1, nIconFolderIndexSelected = -1;
    hIcon = (HICON)::LoadImage(_Module.GetResourceInstance(),
                               MAKEINTRESOURCE(IDI_ICON2),IMAGE_ICON, 16, 16, LR_SHARED);
    nIconFolderIndexNormal = m_LeftTreeImageList.AddIcon(hIcon);

    hIcon = (HICON)::LoadImage(_Module.GetResourceInstance(),
                               MAKEINTRESOURCE(IDI_ICON3),IMAGE_ICON, 16, 16, LR_SHARED);
    nIconFolderIndexSelected = m_LeftTreeImageList.AddIcon(hIcon);

    hIcon = (HICON)::LoadImage(_Module.GetResourceInstance(),
                               MAKEINTRESOURCE(IDI_ICON4),IMAGE_ICON, 16, 16, LR_SHARED);
    nIconFolderIndexSelected = m_LeftTreeImageList.AddIcon(hIcon);

    hIcon = (HICON)::LoadImage(_Module.GetResourceInstance(),
                               MAKEINTRESOURCE(IDI_ICON5),IMAGE_ICON, 16, 16, LR_SHARED);
    nIconFolderIndexSelected = m_LeftTreeImageList.AddIcon(hIcon);

    hIcon = (HICON)::LoadImage(_Module.GetResourceInstance(),
                               MAKEINTRESOURCE(IDI_ICON6),IMAGE_ICON, 16, 16, LR_SHARED);
    nIconFolderIndexSelected = m_LeftTreeImageList.AddIcon(hIcon);

    // Hook up the image list to the tree view
    m_pTreeView->SetImageList(m_LeftTreeImageList, TVSIL_NORMAL);

    CTreeItem tiRoot = m_pTreeView->InsertItem(_T("专利信息平台"), 0, 0, TVI_ROOT, NULL);

    CTreeItem tiFolder1 = m_pTreeView->InsertItem(_T("正在下载"), 1, 1, tiRoot, NULL);
    CTreeItem tiFolder2 = m_pTreeView->InsertItem(_T("搜索结果"), 2, 2, tiRoot, NULL);
    CTreeItem tiFolder3 = m_pTreeView->InsertItem(_T("全部本地数据"), 3, 3, tiRoot, NULL);
    //	m_pTreeView->InsertItem(_T("今日下载"), nIconIndexNormal, nIconIndexSelected, tiFolder3, NULL);
    //	m_pTreeView->InsertItem(_T("昨日下载"), nIconIndexNormal, nIconIndexSelected, tiFolder3, NULL);
    m_pTreeView->InsertItem(_T("数据查询结果"), 4, 4, tiFolder3, NULL);

    CTreeItem tiFolder4 = m_pTreeView->InsertItem(_T("自定义分类"), 5, 5, tiRoot, NULL);

    FindNode(tiFolder4, "0");

    tiRoot.Expand();
    tiFolder1.Expand();
    tiFolder3.Expand();
    tiFolder4.Expand();
}
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();

}
Example #5
0
void
CGeneralPage::GenerateLogDevTree(
	ndas::UnitDevice* pUnitDevice)
{
	CString strRootNode;

	NDAS_LOGICALDEVICE_ID logDevId = pUnitDevice->GetLogicalDeviceId();

	ndas::LogicalDevice* pLogDev = _pLogDevColl->FindLogicalDevice(logDevId);

	if (NULL == pLogDev) {

		strRootNode.LoadString(IDS_LOGDEV_INFO_UNAVAILABLE);
		CTreeItem tiRoot = m_tvLogDev.InsertItem(
			strRootNode, 
			TVI_ROOT, 
			TVI_LAST);

		return;
	}

	//
	// TODO: To handle errors
	//
	(VOID) pLogDev->UpdateInfo();
	(VOID) pLogDev->UpdateStatus();

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

	CString strType, strLocation, strStatus;

	pLogicalDeviceStatusString(
		strStatus, 
		logDevStatus, 
		pLogDev->GetMountedAccess());

	pLogicalDeviceTypeString(strType, logDevType);

	//	Slot %1!d!, Target ID %2!d!, LUN %3!d!
	//strLocation.FormatMessage(
	//	IDS_LOGDEV_LOCATION_FMT,
	//	pLogDev->GetLogicalDeviceId());

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

	m_tvLogDev.DeleteAllItems();

	CTreeItem tiRoot = m_tvLogDev.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 tiMember = tiRoot; // .AddTail(_T("Members"), 0);

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

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

		ndas::Device* pMemberDevice = 
			_pDeviceColl->FindDevice(ui.DeviceId);

		if (NULL == pMemberDevice) {
			// "[%1!d!] Missing Entry"
			strNode.FormatMessage(
				IDS_LOGICALDEVICE_ENTRY_MISSING_FMT, 
				ui.Index + 1);
			tiMember.AddTail(strNode, 0);
			continue;
		}

		ndas::UnitDevice* pMemberUnitDevice = 
			pMemberDevice->FindUnitDevice(ui.UnitNo);

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

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

		tiMember.AddTail(strNode, 0);
		pMemberUnitDevice->Release();
		pMemberDevice->Release();
	}

	tiMember.Expand();
	tiRoot.Expand();

	pLogDev->Release();
}