Ejemplo n.º 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);
			
		}
	}
}
Ejemplo n.º 2
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));
		
		}			
	

	}
	
}