Exemple #1
0
void MainDialog::Init()
{
    m_pCloseBtn = static_cast<CButtonUI*>(m_pm.FindControl(_T("closebtn")));
    m_pMaxBtn = static_cast<CButtonUI*>(m_pm.FindControl(_T("maxbtn")));
    m_pRestoreBtn = static_cast<CButtonUI*>(m_pm.FindControl(_T("restorebtn")));
    m_pMinBtn = static_cast<CButtonUI*>(m_pm.FindControl(_T("minbtn")));
	m_pClose = static_cast<CButtonUI*>(m_pm.FindControl(_T("close")));
	CTreeViewUI* pTree = static_cast<CTreeViewUI*>(m_pm.FindControl(_T("tree")));

	DWORD dwDrvs = GetLogicalDrives();
	for (int i=0; i <26; i++)
	{
		int n = 0x00000001;
		if (dwDrvs & (1 << i))
		{
			TCHAR buff[] = _T("A:\\");
			buff[0] = 'A' + i;
			CTreeNodeUI* pNode = new CTreeNodeUI;
			pNode->SetAttribute(_T("folderattr"),_T("padding=\"0,1,0,0\" width=\"36\" height=\"16\" normalimage=\"file='treeview_b.png' source='0,0,36,16'\" hotimage=\"file='treeview_b.png' source='36,0,72,16'\" selectedimage=\"file='treeview_a.png' source='0,0,36,16' selectedhotimage=\"file='treeview_a.png' source='36,0,72,16'\""));
			pTree->Add(pNode);
			pNode->SetItemText(buff);
			pNode->SetUserData(buff);
			
		}
	}
}
CTreeNodeUI * CWndMoveOrPasteTo::CreateTreeNode( CFileHandle *pFileHandle )
{
	CTreeNodeUI *pRetNode = new CTreeNodeUI;
	pRetNode->SetItemText(pFileHandle->GetFileName().c_str());
	pRetNode->SetAttribute(_T("endellipsis"), _T("true"));
	pRetNode->GetTreeNodeHoriznotal()->SetToolTip(pFileHandle->GetFileName().c_str());
	pRetNode->GetItemButton()->SetFont(6);
	pRetNode->SetFixedHeight(20);

	pRetNode->SetTag((UINT_PTR)pFileHandle);	

	pRetNode->SetAttribute(_T("itemattr"), _T("textpadding=\"2,0,0,0\" textcolor=\"#FF000000\""));
	pRetNode->SetAttribute(_T("checkboxattr"), _T("width=\"20\" height=\"20\" enabled=\"false\" bkimage=\"file='dir_icon_small' dest='4,2,20,18'\""));
	pRetNode->SetAttribute(_T("folderattr"), _T("padding=\"0,5,0,5\" width=\"7\" height=\"1\""));

	pRetNode->GetFolderButton()->SetVisible(false);

	return pRetNode;
}
void CWndMoveOrPasteTo::Init()
{
	CTreeViewUI *pTreeView = static_cast<CTreeViewUI*>(m_PaintManager.FindControl(_T("tree_file")));
	CTreeNodeUI *pRoot = static_cast<CTreeNodeUI*>(pTreeView->GetItemAt(0));

	CFileHandle *pFileRoot = CFileHandleManager::GetSingleInstance()->GetFileHandleTree();
	pRoot->SetAttribute(_T("checkboxattr"), _T("width=\"20\" height=\"20\" enabled=\"false\" bkimage=\"file='dir_icon_small' dest='4,2,20,18'\""));
	pRoot->SetTag((UINT_PTR)pFileRoot);

	EnumFileHandleTreeAddToTree(pRoot);

	pTreeView->ExpandItem(0,false);
}
void CLoginDlg::OnPrepare(TNotifyUI& msg)
{
	__super::OnPrepare(msg);
	CControlUI* pControl = m_PaintManager.FindControl("maxbtn");
	if(pControl) pControl->SetVisible(false);
	
	CCheckBoxUI* pCheckBox = (CCheckBoxUI*)m_PaintManager.FindControl("autologin");
	//pCheckBox->SetCheck(true);
	
	static CMyBrowserEventHandler eventhandle;
	CWebBrowserUI* m_pbrowserSpList = static_cast<CWebBrowserUI*>(m_PaintManager.FindControl(_T("ie")));
	if (m_pbrowserSpList)
	{
		
		m_pbrowserSpList->SetWebBrowserEventHandler(&eventhandle);
		m_pbrowserSpList->Navigate2("about:blank");
		PostMessage(WM_MSG_SET_FOCUS);
	//	m_pbrowserSpList->Navigate2("http://www.baidu.com");
	}
	CWebBrowserUI* m_pbrowserSpList1 = static_cast<CWebBrowserUI*>(m_PaintManager.FindControl(_T("ie2")));
	if (m_pbrowserSpList1)
	{

		m_pbrowserSpList1->SetWebBrowserEventHandler(&eventhandle);
		m_pbrowserSpList1->Navigate2("http://www.baidu.com");
	}

	CListUI *list = static_cast<CListUI*>(m_PaintManager.FindControl(_T("listex"))); 
	list->SetKeyboardEnabled(false);
	//³õʼ»¯Ê÷µÄÏÔʾ 
	CTreeViewUI* pTree = static_cast<CTreeViewUI*>(m_PaintManager.FindControl(_T("tree")));
	if (!pTree)
	{
		return;
	}
	pControl = m_PaintManager.FindControl(_T("drag"));
	pTree->m_pDragingCtrl = pControl;

	CTreeNodeUI* pNodeRoot = new CTreeNodeUI;
	pNodeRoot->SetAttribute(_T("folderattr"),_T("padding=\"0,1,0,0\" width=\"36\" height=\"16\" normalimage=\"file='treeview_b.png' source='0,0,36,16'\" hotimage=\"file='treeview_b.png' source='36,0,72,16'\" selectedimage=\"file='treeview_a.png' source='0,0,36,16' selectedhotimage=\"file='treeview_a.png' source='36,0,72,16'\""));
	pTree->Add(pNodeRoot);
	CDuiString strNode = "";
	strNode.Format("Ö÷»úÁбí");
	pNodeRoot->SetItemText(strNode);
	pNodeRoot->SetExpand(true);
	//m_pNodeRoot = pNodeRoot;
	for (int i = 1; i < 17; i++)
	{
		int nn = pNodeRoot->GetCountChild();
		CTreeNodeUI* pNodeParent = new CTreeNodeUI;
		pNodeRoot->AddChildNode(pNodeParent);
		pNodeParent->SetName(strNode);
		pNodeParent->SetAttribute(_T("folderattr"),_T("padding=\"0,1,0,0\" width=\"36\" height=\"16\" normalimage=\"file='treeview_b.png' source='0,0,36,16'\" hotimage=\"file='treeview_b.png' source='36,0,72,16'\" selectedimage=\"file='treeview_a.png' source='0,0,36,16' selectedhotimage=\"file='treeview_a.png' source='36,0,72,16'\""));
		CDuiString strNode = "";
		strNode.Format("Ŀ¼%d", i);
		pNodeParent->SetItemText(strNode);
		pNodeParent->SetName(strNode);
		if (i % 4 == 0)
		{
			pNodeParent->SetExpand(true);
		}
		for (int j = 1; j< 7; j++)
		{
			CTreeNodeUI* pNodeChild = new CTreeNodeUI(true);	//±íʾÊÇÒ¶×Ó½Úµã 
			CDuiString strNode = "";
			strNode.Format("%d_%d", i, j);
			pNodeChild->SetItemText(strNode);
			pNodeChild->SetName(strNode);
			pNodeParent->AddChildNode(pNodeChild);
		}
	}
}
Exemple #5
0
void MainDialog::Notify(TNotifyUI& msg)
{
	if( msg.sType == _T("windowinit") ) 
		OnPrepare(msg);
	else if( msg.sType == _T("click") ) 
	{
		if( msg.pSender == m_pCloseBtn ) 
		{
			PostQuitMessage(0);
			return; 
		}
		else if( msg.pSender == m_pMinBtn ) 
		{ 
			SendMessage(WM_SYSCOMMAND, SC_MINIMIZE, 0);
			return; 
		}
		else if( msg.pSender == m_pMaxBtn ) 
		{ 
			SendMessage(WM_SYSCOMMAND, SC_MAXIMIZE, 0); return; 
		}
		else if( msg.pSender == m_pRestoreBtn ) 
		{ 
			SendMessage(WM_SYSCOMMAND, SC_RESTORE, 0); return; 
		}
		else if (msg.pSender->GetName() == _T("upload"))
		{
			
			
		}
		else if (msg.pSender == m_pClose)
		{
			
		}
	}

	else if(msg.sType==_T("setfocus"))
	{
		
	}
	else if( msg.sType == _T("itemexpand") ) 
	{
		CTreeNodeUI* pNowNode = static_cast<CTreeNodeUI*>(msg.pSender);
		pNowNode->Select(true);
		
		CTreeViewUI* pTree = static_cast<CTreeViewUI*>(m_pm.FindControl(_T("tree")));
		CListUI* pList = static_cast<CListUI*>(m_pm.FindControl(_T("file_list")));
		g_bUpdateDir = false;
		if (!pNowNode->IsHasChild())
		{
			g_bUpdateDir = true;
		}

		pList->RemoveAll();
	
		WIN32_FIND_DATA FindFileData;
		HANDLE hListFile;
		TCHAR szFilePath[MAX_PATH];



		lstrcpy(szFilePath,pNowNode->GetUserData());
		lstrcat(szFilePath, _T("\\*"));

		hListFile = FindFirstFile(szFilePath,&FindFileData);

		if(hListFile==INVALID_HANDLE_VALUE)
		{
			return;
		}
		else
		{        
			do
			{
				if(lstrcmp(FindFileData.cFileName,TEXT("."))==0||
					lstrcmp(FindFileData.cFileName,TEXT(".."))==0)
				{
					continue;
				}
	


				SYSTEMTIME  st;
				FileTimeToSystemTime(&FindFileData.ftLastWriteTime,&st);
				DWORDLONG dwlSize = (DWORDLONG)(FindFileData.nFileSizeHigh * (MAXDWORD+1)) + FindFileData.nFileSizeLow;
				DWORD dwSize = (DWORD)(dwlSize / 1024);

				if(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
				{	
					if (g_bUpdateDir)
					{
						CTreeNodeUI* pNode = new CTreeNodeUI;
						pNode->SetAttribute(_T("folderattr"),_T("padding=\"0,1,0,0\" width=\"36\" height=\"16\" normalimage=\"file='treeview_b.png' source='0,0,36,16'\" hotimage=\"file='treeview_b.png' source='36,0,72,16'\" selectedimage=\"file='treeview_a.png' source='0,0,36,16' selectedhotimage=\"file='treeview_a.png' source='36,0,72,16'\""));
						pNowNode->AddChildNode(pNode);
						pNode->SetItemText(FindFileData.cFileName);
						CDuiString szUserData = pNowNode->GetUserData() + _T("\\") + pNode->GetItemText();
						pNode->SetUserData(szUserData);
					}
					
				}
				else
				{
					CListTextElementUI* pLine = new CListTextElementUI;
					pList->Add(pLine);
					CDuiString szNewName(FindFileData.cFileName);
					
					int pos = szNewName.ReverseFind('.');
					CDuiString szExt = szNewName.Right(szNewName.GetLength() - pos);
					SHFILEINFO shfi;
					memset(&shfi,0,sizeof(shfi));
					SHGetFileInfo(szExt,
						FILE_ATTRIBUTE_NORMAL,
						&shfi,
						sizeof(shfi),
						SHGFI_ICON|SHGFI_USEFILEATTRIBUTES);

					pLine->SetIcon(0,shfi.hIcon);
				
					pLine->SetText(0,szNewName);

					SYSTEMTIME  st;
					FileTimeToSystemTime(&FindFileData.ftLastWriteTime,&st);
					CDuiString szTime;
					szTime.Format(_T("%04d/%02d/%02d %02d:%02d:%02d"), st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);
					pLine->SetText(1,szTime);

					DWORDLONG dwlSize = (DWORDLONG)(FindFileData.nFileSizeHigh * (MAXDWORD+1)) + FindFileData.nFileSizeLow;
					CDuiString szSize;
					if (dwlSize <1024)
					{
						szSize.Format(_T("%ldB"),dwlSize);
					}
					else
					{
						szSize.Format(_T("%ldK"),dwlSize/1024);
					}

					pLine->SetText(2,szSize);

					CDuiString szArrtib;
					szArrtib.Format(_T("%d"),FindFileData.dwFileAttributes);
					pLine->SetText(3,szArrtib);
					
				}
			}
			while(FindNextFile(hListFile, &FindFileData));
		
		}			
	

	}
	
}