diff --git a/CcRemote/.vs/CcRemote/v15/.suo b/CcRemote/.vs/CcRemote/v15/.suo index 7adcafe..f7cab95 100644 Binary files a/CcRemote/.vs/CcRemote/v15/.suo and b/CcRemote/.vs/CcRemote/v15/.suo differ diff --git a/CcRemote/CcRemote/CFileManagerDlg.cpp b/CcRemote/CcRemote/CFileManagerDlg.cpp new file mode 100644 index 0000000..8e4c719 --- /dev/null +++ b/CcRemote/CcRemote/CFileManagerDlg.cpp @@ -0,0 +1,2605 @@ +// CFileManagerDlg.cpp: 实现文件 +// + +#include "pch.h" +#include "CcRemote.h" +#include "PublicStruct.h" +#include "CFileManagerDlg.h" +#include "FileTransferModeDlg.h" +#include "afxdialogex.h" +#include "InputDlg.h" +#include "..\..\common\macros.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +static UINT indicators[] = +{ + ID_SEPARATOR, // status line indicator + ID_SEPARATOR, + ID_SEPARATOR +}; + +typedef struct { + LVITEM* plvi; + CString sCol2; +} lvItem, *plvItem; + +// CFileManagerDlg 对话框 + +IMPLEMENT_DYNAMIC(CFileManagerDlg, CDialog) + +CFileManagerDlg::CFileManagerDlg(CWnd* pParent, CIOCPServer* pIOCPServer, ClientContext *pContext) + : CDialog(IDD_FILE, pParent) +{ + SHFILEINFO sfi; + SHGetFileInfo + ( + "\\\\", + FILE_ATTRIBUTE_NORMAL, + &sfi, + sizeof(SHFILEINFO), + SHGFI_ICON | SHGFI_USEFILEATTRIBUTES + ); + m_hIcon = sfi.hIcon; + HIMAGELIST hImageList; + // 加载系统图标列表 + hImageList = (HIMAGELIST)SHGetFileInfo + ( + NULL, + 0, + &sfi, + sizeof(SHFILEINFO), + SHGFI_LARGEICON | SHGFI_SYSICONINDEX + ); + m_pImageList_Large = CImageList::FromHandle(hImageList); + + // 加载系统图标列表 + hImageList = (HIMAGELIST)SHGetFileInfo + ( + NULL, + 0, + &sfi, + sizeof(SHFILEINFO), + SHGFI_SMALLICON | SHGFI_SYSICONINDEX + ); + m_pImageList_Small = CImageList::FromHandle(hImageList); + + // 初始化应该传输的数据包大小为0 + + m_iocpServer = pIOCPServer; + m_pContext = pContext; + sockaddr_in sockAddr; + memset(&sockAddr, 0, sizeof(sockAddr)); + int nSockAddrLen = sizeof(sockAddr); + //得到连接服务端的IP + BOOL bResult = getpeername(m_pContext->m_Socket, (SOCKADDR*)&sockAddr, &nSockAddrLen); + + m_IPAddress = bResult != INVALID_SOCKET ? inet_ntoa(sockAddr.sin_addr) : ""; + + // 保存远程驱动器列表 + memset(m_bRemoteDriveList, 0, sizeof(m_bRemoteDriveList)); + memcpy(m_bRemoteDriveList, m_pContext->m_DeCompressionBuffer.GetBuffer(1), m_pContext->m_DeCompressionBuffer.GetBufferLen() - 1); + + m_nTransferMode = TRANSFER_MODE_NORMAL; + m_nOperatingFileLength = 0; + m_nCounter = 0; + + m_bIsStop = false; + //这个时候之所以没有处理发送来的信息是因为这个时候控件还没有初始化好 + //我们到oninitdialog看看吧 +} + +CFileManagerDlg::~CFileManagerDlg() +{ +} + +void CFileManagerDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + DDX_Control(pDX, IDC_REMOTE_PATH, m_Remote_Directory_ComboBox); + DDX_Control(pDX, IDC_LOCAL_PATH, m_Local_Directory_ComboBox); + DDX_Control(pDX, IDC_LIST_REMOTE, m_list_remote); + DDX_Control(pDX, IDC_LIST_LOCAL, m_list_local); +} + + + +BEGIN_MESSAGE_MAP(CFileManagerDlg, CDialog) + //{{AFX_MSG_MAP(CFileManagerDlg) + ON_WM_QUERYDRAGICON() + ON_WM_SIZE() + ON_NOTIFY(NM_DBLCLK, IDC_LIST_LOCAL, OnDblclkListLocal) + ON_NOTIFY(LVN_BEGINDRAG, IDC_LIST_LOCAL, OnBegindragListLocal) + ON_NOTIFY(LVN_BEGINDRAG, IDC_LIST_REMOTE, OnBegindragListRemote) + ON_WM_MOUSEMOVE() + ON_WM_LBUTTONUP() + ON_WM_TIMER() + ON_WM_CLOSE() + ON_NOTIFY(NM_DBLCLK, IDC_LIST_REMOTE, OnDblclkListRemote) + ON_COMMAND(IDT_LOCAL_PREV, OnLocalPrev) + ON_COMMAND(IDT_REMOTE_PREV, OnRemotePrev) + ON_COMMAND(IDT_LOCAL_VIEW, OnLocalView) + ON_COMMAND(IDM_LOCAL_LIST, OnLocalList) + ON_COMMAND(IDM_LOCAL_REPORT, OnLocalReport) + ON_COMMAND(IDM_LOCAL_BIGICON, OnLocalBigicon) + ON_COMMAND(IDM_LOCAL_SMALLICON, OnLocalSmallicon) + ON_COMMAND(IDM_REMOTE_BIGICON, OnRemoteBigicon) + ON_COMMAND(IDM_REMOTE_LIST, OnRemoteList) + ON_COMMAND(IDM_REMOTE_REPORT, OnRemoteReport) + ON_COMMAND(IDM_REMOTE_SMALLICON, OnRemoteSmallicon) + ON_COMMAND(IDT_REMOTE_VIEW, OnRemoteView) + ON_UPDATE_COMMAND_UI(IDT_LOCAL_STOP, OnUpdateLocalStop) + ON_UPDATE_COMMAND_UI(IDT_REMOTE_STOP, OnUpdateRemoteStop) + ON_UPDATE_COMMAND_UI(IDT_LOCAL_PREV, OnUpdateLocalPrev) + ON_UPDATE_COMMAND_UI(IDT_REMOTE_PREV, OnUpdateRemotePrev) + ON_UPDATE_COMMAND_UI(IDT_LOCAL_COPY, OnUpdateLocalCopy) + ON_UPDATE_COMMAND_UI(IDT_REMOTE_COPY, OnUpdateRemoteCopy) + ON_UPDATE_COMMAND_UI(IDT_REMOTE_DELETE, OnUpdateRemoteDelete) + ON_UPDATE_COMMAND_UI(IDT_REMOTE_NEWFOLDER, OnUpdateRemoteNewfolder) + ON_UPDATE_COMMAND_UI(IDT_LOCAL_DELETE, OnUpdateLocalDelete) + ON_UPDATE_COMMAND_UI(IDT_LOCAL_NEWFOLDER, OnUpdateLocalNewfolder) + ON_COMMAND(IDT_REMOTE_COPY, OnRemoteCopy) + ON_COMMAND(IDT_LOCAL_COPY, OnLocalCopy) + ON_COMMAND(IDT_LOCAL_DELETE, OnLocalDelete) + ON_COMMAND(IDT_REMOTE_DELETE, OnRemoteDelete) + ON_COMMAND(IDT_REMOTE_STOP, OnRemoteStop) + ON_COMMAND(IDT_LOCAL_STOP, OnLocalStop) + ON_COMMAND(IDT_LOCAL_NEWFOLDER, OnLocalNewfolder) + ON_COMMAND(IDT_REMOTE_NEWFOLDER, OnRemoteNewfolder) + ON_COMMAND(IDM_TRANSFER, OnTransfer) + ON_COMMAND(IDM_RENAME, OnRename) + ON_NOTIFY(LVN_ENDLABELEDIT, IDC_LIST_LOCAL, OnEndlabeleditListLocal) + ON_NOTIFY(LVN_ENDLABELEDIT, IDC_LIST_REMOTE, OnEndlabeleditListRemote) + ON_COMMAND(IDM_DELETE, OnDelete) + ON_COMMAND(IDM_NEWFOLDER, OnNewfolder) + ON_COMMAND(IDM_REFRESH, OnRefresh) + ON_COMMAND(IDM_LOCAL_OPEN, OnLocalOpen) + ON_COMMAND(IDM_REMOTE_OPEN_SHOW, OnRemoteOpenShow) + ON_COMMAND(IDM_REMOTE_OPEN_HIDE, OnRemoteOpenHide) + ON_NOTIFY(NM_RCLICK, IDC_LIST_LOCAL, OnRclickListLocal) + ON_NOTIFY(NM_RCLICK, IDC_LIST_REMOTE, OnRclickListRemote) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + + +// CFileManagerDlg 消息处理程序 + + +int GetIconIndex(LPCTSTR lpFileName, DWORD dwFileAttributes) +{ + SHFILEINFO sfi; + if (dwFileAttributes == INVALID_FILE_ATTRIBUTES) + dwFileAttributes = FILE_ATTRIBUTE_NORMAL; + else + dwFileAttributes |= FILE_ATTRIBUTE_NORMAL; + + SHGetFileInfo + ( + lpFileName, + dwFileAttributes, + &sfi, + sizeof(SHFILEINFO), + SHGFI_SYSICONINDEX | SHGFI_USEFILEATTRIBUTES + ); + + return sfi.iIcon; +} + +BOOL CFileManagerDlg::OnInitDialog() +{ + CDialog::OnInitDialog(); + + // TODO: Add extra initialization here + + // Set the icon for this dialog. The framework does this automatically + // when the application's main window is not a dialog + SetIcon(m_hIcon, TRUE); // Set big icon + SetIcon(m_hIcon, FALSE); // Set small icon + + RECT rect; + GetClientRect(&rect); + + /*为真彩工具条添加的代码*/ + + // 一定要定义工具栏ID,不然RepositionBars会重置工具栏的位置 + // ID 定义在AFX_IDW_CONTROLBAR_FIRST AFX_IDW_CONTROLBAR_LAST + // 本地工具条 CBRS_TOP 会在工具条上产生一条线 + if (!m_wndToolBar_Local.Create(this, WS_CHILD | + WS_VISIBLE | CBRS_ALIGN_ANY | CBRS_TOOLTIPS | CBRS_FLYBY, ID_LOCAL_TOOLBAR) + || !m_wndToolBar_Local.LoadToolBar(IDR_TOOLBAR1)) + { + TRACE0("Failed to create toolbar "); + return -1; //Failed to create + } + m_wndToolBar_Local.ModifyStyle(0, TBSTYLE_FLAT); //Fix for WinXP + m_wndToolBar_Local.LoadTrueColorToolBar + ( + 24, //加载真彩工具条 + IDB_TOOLBAR_ENABLE, + IDB_TOOLBAR_ENABLE, + IDB_TOOLBAR_DISABLE + ); + // 添加下拉按钮 + m_wndToolBar_Local.AddDropDownButton(this, IDT_LOCAL_VIEW, IDR_LOCAL_VIEW); + + + if (!m_wndToolBar_Remote.Create(this, WS_CHILD | + WS_VISIBLE | CBRS_ALIGN_ANY | CBRS_TOOLTIPS | CBRS_FLYBY, ID_REMOTE_TOOLBAR) + || !m_wndToolBar_Remote.LoadToolBar(IDR_TOOLBAR2)) + { + TRACE0("Failed to create toolbar "); + return -1; //Failed to create + } + m_wndToolBar_Remote.ModifyStyle(0, TBSTYLE_FLAT); //Fix for WinXP + m_wndToolBar_Remote.LoadTrueColorToolBar + ( + 24, //加载真彩工具条 + IDB_TOOLBAR_ENABLE, + IDB_TOOLBAR_ENABLE, + IDB_TOOLBAR_DISABLE + ); + // 添加下拉按钮 + m_wndToolBar_Remote.AddDropDownButton(this, IDT_REMOTE_VIEW, IDR_REMOTE_VIEW); + + //显示工具栏 + m_wndToolBar_Local.MoveWindow(268, 0, rect.right - 268, 48); + m_wndToolBar_Remote.MoveWindow(268, rect.bottom / 2 - 10, rect.right - 268, 48); + + + // 设置标题 + CString str; + str.Format("\\\\%s - 文件管理", m_IPAddress); + SetWindowText(str); + + // 为列表视图设置ImageList + m_list_local.SetImageList(m_pImageList_Large, LVSIL_NORMAL); + m_list_local.SetImageList(m_pImageList_Small, LVSIL_SMALL); + // 创建带进度条的状态栏 + if (!m_wndStatusBar.Create(this) || + !m_wndStatusBar.SetIndicators(indicators, + sizeof(indicators) / sizeof(UINT))) + { + TRACE0("Failed to create status bar\n"); + return -1; // fail to create + } + + m_wndStatusBar.SetPaneInfo(0, m_wndStatusBar.GetItemID(0), SBPS_STRETCH, NULL); + m_wndStatusBar.SetPaneInfo(1, m_wndStatusBar.GetItemID(1), SBPS_NORMAL, 120); + m_wndStatusBar.SetPaneInfo(2, m_wndStatusBar.GetItemID(2), SBPS_NORMAL, 50); + RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0); //显示状态栏 + + m_wndStatusBar.GetItemRect(1, &rect); + m_ProgressCtrl = new CProgressCtrl; + m_ProgressCtrl->Create(PBS_SMOOTH | WS_VISIBLE, rect, &m_wndStatusBar, 1); + m_ProgressCtrl->SetRange(0, 100); //设置进度条范围 + m_ProgressCtrl->SetPos(20); //设置进度条当前位置 + + + //这里是初始化本地驱动器列表并将本地驱动器列表显示到列表中 + FixedLocalDriveList(); + //这里是初始化驱动器列表并将服务端传递进来的信息显示到列表中 + FixedRemoteDriveList(); + + //转到FixedRemoteDriveList定义 + ///////////////////////////////////////////// + //// Set up initial variables + m_bDragging = false; + m_nDragIndex = -1; + m_nDropIndex = -1; + CoInitialize(NULL); + SHAutoComplete(GetDlgItem(IDC_LOCAL_PATH)->GetWindow(GW_CHILD)->m_hWnd, SHACF_FILESYSTEM); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void CFileManagerDlg::OnSize(UINT nType, int cx, int cy) +{ + CDialog::OnSize(nType, cx, cy); + + // TODO: Add your message handler code here + // 状态栏还没有创建 + if (m_wndStatusBar.m_hWnd == NULL) + return; + // 定位状态栏 + RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0); //显示工具栏 + RECT rect; + m_wndStatusBar.GetItemRect(1, &rect); + m_ProgressCtrl->MoveWindow(&rect); + + GetDlgItem(IDC_LIST_LOCAL)->MoveWindow(0, 36, cx, (cy - 100) / 2); + GetDlgItem(IDC_LIST_REMOTE)->MoveWindow(0, (cy / 2) + 28, cx, (cy - 100) / 2); + GetDlgItem(IDC_STATIC_REMOTE)->MoveWindow(20, cy / 2, 25, 20); + GetDlgItem(IDC_REMOTE_PATH)->MoveWindow(53, (cy / 2) - 4, 210, 12); + + + GetClientRect(&rect); + //显示工具栏 + m_wndToolBar_Local.MoveWindow(268, 0, rect.right - 268, 48); + m_wndToolBar_Remote.MoveWindow(268, rect.bottom / 2 - 10, rect.right - 268, 48); +} + +void CFileManagerDlg::FixedLocalDriveList() +{ + char DriveString[256]; + char *pDrive = NULL; + m_list_local.DeleteAllItems(); + while (m_list_local.DeleteColumn(0) != 0); + //初始化列表信息 + m_list_local.InsertColumn(0, "名称", LVCFMT_LEFT, 200); + m_list_local.InsertColumn(1, "类型", LVCFMT_LEFT, 100); + m_list_local.InsertColumn(2, "总大小", LVCFMT_LEFT, 100); + m_list_local.InsertColumn(3, "可用空间", LVCFMT_LEFT, 115); + + //这里的api我们用到过了 + GetLogicalDriveStrings(sizeof(DriveString), DriveString); + pDrive = DriveString; + + char FileSystem[MAX_PATH]; + unsigned __int64 HDAmount = 0; + unsigned __int64 HDFreeSpace = 0; + unsigned long AmntMB = 0; // 总大小 + unsigned long FreeMB = 0; // 剩余空间 + //遍历信息显示到列表中 + //下面的信息我们在服务端都看过了,我们看一下这个对话框的资源吧然后我们想想他是如何得到服务端文件信息的 + //应该是仿照资源管理器的双击对吧? 我们要找到那个列表的双击事件。。。 (点击列表控件然后ctrl+w )NM_DBCLICK + for (int i = 0; *pDrive != '\0'; i++, pDrive += lstrlen(pDrive) + 1) + { + // 得到磁盘相关信息 + memset(FileSystem, 0, sizeof(FileSystem)); + // 得到文件系统信息及大小 + GetVolumeInformation(pDrive, NULL, 0, NULL, NULL, NULL, FileSystem, MAX_PATH); + + int nFileSystemLen = lstrlen(FileSystem) + 1; + if (GetDiskFreeSpaceEx(pDrive, (PULARGE_INTEGER)&HDFreeSpace, (PULARGE_INTEGER)&HDAmount, NULL)) + { + AmntMB = HDAmount / 1024 / 1024; + FreeMB = HDFreeSpace / 1024 / 1024; + } + else + { + AmntMB = 0; + FreeMB = 0; + } + + + int nItem = m_list_local.InsertItem(i, pDrive, GetIconIndex(pDrive, GetFileAttributes(pDrive))); + m_list_local.SetItemData(nItem, 1); + if (lstrlen(FileSystem) == 0) + { + SHFILEINFO sfi; + SHGetFileInfo(pDrive, FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(SHFILEINFO), SHGFI_TYPENAME | SHGFI_USEFILEATTRIBUTES); + m_list_local.SetItemText(nItem, 1, sfi.szTypeName); + } + else + { + m_list_local.SetItemText(nItem, 1, FileSystem); + } + CString str; + str.Format("%10.1f GB", (float)AmntMB / 1024); + m_list_local.SetItemText(nItem, 2, str); + str.Format("%10.1f GB", (float)FreeMB / 1024); + m_list_local.SetItemText(nItem, 3, str); + } + // 重置本地当前路径 + m_Local_Path = ""; + m_Local_Directory_ComboBox.ResetContent(); + + ShowMessage("本地:装载目录 %s 完成", m_Local_Path); +} + +void CFileManagerDlg::OnDblclkListLocal(NMHDR* pNMHDR, LRESULT* pResult) +{ + // TODO: Add your control notification handler code here + if (m_list_local.GetSelectedCount() == 0 || m_list_local.GetItemData(m_list_local.GetSelectionMark()) != 1) + return; + FixedLocalFileList(); + *pResult = 0; +} + +void CFileManagerDlg::FixedLocalFileList(CString directory) +{ + if (directory.GetLength() == 0) + { + int nItem = m_list_local.GetSelectionMark(); + + // 如果有选中的,是目录 + if (nItem != -1) + { + if (m_list_local.GetItemData(nItem) == 1) + { + directory = m_list_local.GetItemText(nItem, 0); + } + } + // 从组合框里得到路径 + else + { + m_Local_Directory_ComboBox.GetWindowText(m_Local_Path); + } + } + + + + + // 得到父目录 + if (directory == "..") + { + m_Local_Path = GetParentDirectory(m_Local_Path); + } + // 刷新当前用 + else if (directory != ".") + { + m_Local_Path += directory; + if (m_Local_Path.Right(1) != "\\") + m_Local_Path += "\\"; + } + + + // 是驱动器的根目录,返回磁盘列表 + if (m_Local_Path.GetLength() == 0) + { + FixedLocalDriveList(); + return; + } + + m_Local_Directory_ComboBox.InsertString(0, m_Local_Path); + m_Local_Directory_ComboBox.SetCurSel(0); + + // 重建标题 + m_list_local.DeleteAllItems(); + while (m_list_local.DeleteColumn(0) != 0); + m_list_local.InsertColumn(0, "名称", LVCFMT_LEFT, 200); + m_list_local.InsertColumn(1, "大小", LVCFMT_LEFT, 100); + m_list_local.InsertColumn(2, "类型", LVCFMT_LEFT, 100); + m_list_local.InsertColumn(3, "修改日期", LVCFMT_LEFT, 115); + + int nItemIndex = 0; + m_list_local.SetItemData + ( + m_list_local.InsertItem(nItemIndex++, "..", GetIconIndex(NULL, FILE_ATTRIBUTE_DIRECTORY)), + 1 + ); + + // i 为 0 时列目录,i 为 1时列文件 + for (int i = 0; i < 2; i++) + { + CFileFind file; + BOOL bContinue; + bContinue = file.FindFile(m_Local_Path + "*.*"); + while (bContinue) + { + bContinue = file.FindNextFile(); + if (file.IsDots()) + continue; + bool bIsInsert = !file.IsDirectory() == i; + + if (!bIsInsert) + continue; + + int nItem = m_list_local.InsertItem(nItemIndex++, file.GetFileName(), + GetIconIndex(file.GetFileName(), GetFileAttributes(file.GetFilePath()))); + m_list_local.SetItemData(nItem, file.IsDirectory()); + SHFILEINFO sfi; + SHGetFileInfo(file.GetFileName(), FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(SHFILEINFO), SHGFI_TYPENAME | SHGFI_USEFILEATTRIBUTES); + m_list_local.SetItemText(nItem, 2, sfi.szTypeName); + + CString str; + str.Format("%10d KB", file.GetLength() / 1024 + (file.GetLength() % 1024 ? 1 : 0)); + m_list_local.SetItemText(nItem, 1, str); + CTime time; + file.GetLastWriteTime(time); + m_list_local.SetItemText(nItem, 3, time.Format("%Y-%m-%d %H:%M")); + } + } + + ShowMessage("本地:装载目录 %s 完成", m_Local_Path); +} + +void CFileManagerDlg::DropItemOnList(CListCtrl* pDragList, CListCtrl* pDropList) +{ + //This routine performs the actual drop of the item dragged. + //It simply grabs the info from the Drag list (pDragList) + // and puts that info into the list dropped on (pDropList). + //Send: pDragList = pointer to CListCtrl we dragged from, + // pDropList = pointer to CListCtrl we are dropping on. + //Return: nothing. + + ////Variables + // Unhilight the drop target + + if (pDragList == pDropList) //we are return + { + return; + } //EO if(pDragList... + + + pDropList->SetItemState(m_nDropIndex, 0, LVIS_DROPHILITED); + + if ((CWnd *)pDropList == &m_list_local) + { + OnRemoteCopy(); + } + else if ((CWnd *)pDropList == &m_list_remote) + { + OnLocalCopy(); + } + else + { + // 见鬼了 + return; + } + // 重置 + m_nDropIndex = -1; + // 靠,下面的代码不要了,复制文件了 + // if(pDragList->GetSelectedCount() == 1) + // { + // char szLabel[MAX_PATH]; + // LVITEM lviT; + // ZeroMemory(&lviT, sizeof (LVITEM)); //allocate and clear memory space for LV_ITEM + // lviT.iItem = m_nDragIndex; + // lviT.mask = LVIF_IMAGE | LVIF_TEXT; + // lviT.pszText = szLabel; + // lviT.cchTextMax = MAX_PATH; + // pDragList->GetItem (&lviT); + // + // // Select the new item we just inserted + // int iItem = (m_nDropIndex == -1) ? pDropList->GetItemCount () : m_nDropIndex; + // + // pDropList->InsertItem(iItem, szLabel, lviT.iImage); + // + // pDropList->SetItemState (iItem, LVIS_SELECTED, LVIS_SELECTED); + // } + // else //more than 1 item is being dropped + // { + // POSITION pos = pDragList->GetFirstSelectedItemPosition(); //iterator for the CListCtrl + // while(pos) //so long as we have a valid POSITION, we keep iterating + // { + // m_nDragIndex = pDragList->GetNextSelectedItem(pos); + // m_nDropIndex = (m_nDropIndex == -1) ? pDropList->GetItemCount() : m_nDropIndex; + // + // char szLabel[MAX_PATH]; + // LVITEM lviT; + // ZeroMemory(&lviT, sizeof (LVITEM)); //allocate and clear memory space for LV_ITEM + // lviT.iItem = m_nDragIndex; + // lviT.mask = LVIF_IMAGE | LVIF_TEXT; + // lviT.pszText = szLabel; + // lviT.cchTextMax = MAX_PATH; + // pDragList->GetItem (&lviT); + // + // pDropList->InsertItem(m_nDropIndex, szLabel, lviT.iImage); + // pDropList->SetItemState(m_nDropIndex, LVIS_SELECTED, LVIS_SELECTED); + // m_nDropIndex ++; + // //Save the pointer to the new item in our CList + // } //EO while(pos) -- at this point we have deleted the moving items and stored them in memory + // } +} + +// The system calls this to obtain the cursor to display while the user drags +// the minimized window. +HCURSOR CFileManagerDlg::OnQueryDragIcon() +{ + return (HCURSOR)m_hIcon; +} + +void CFileManagerDlg::OnBegindragListLocal(NMHDR* pNMHDR, LRESULT* pResult) +{ + NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR; + // TODO: Add your control notification handler code here + //// Save the index of the item being dragged in m_nDragIndex + //// This will be used later for retrieving the info dragged + m_nDragIndex = pNMListView->iItem; + + if (!m_list_local.GetItemText(m_nDragIndex, 0).Compare("..")) + return; + + //We will call delete later (in LButtonUp) to clean this up + + if (m_list_local.GetSelectedCount() > 1) //more than 1 item in list is selected + m_hCursor = AfxGetApp()->LoadCursor(IDC_MUTI_DRAG); + else + m_hCursor = AfxGetApp()->LoadCursor(IDC_DRAG); + + ASSERT(m_hCursor); //make sure it was created + //// Change the cursor to the drag image + //// (still must perform DragMove() in OnMouseMove() to show it moving) + + //// Set dragging flag and others + m_bDragging = TRUE; //we are in a drag and drop operation + m_nDropIndex = -1; //we don't have a drop index yet + m_pDragList = &m_list_local; //make note of which list we are dragging from + m_pDropWnd = &m_list_local; //at present the drag list is the drop list + + //// Capture all mouse messages + SetCapture(); + *pResult = 0; +} + +void CFileManagerDlg::OnBegindragListRemote(NMHDR* pNMHDR, LRESULT* pResult) +{ + NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR; + // TODO: Add your control notification handler code here + //// Save the index of the item being dragged in m_nDragIndex + //// This will be used later for retrieving the info dragged + m_nDragIndex = pNMListView->iItem; + if (!m_list_local.GetItemText(m_nDragIndex, 0).Compare("..")) + return; + + + //We will call delete later (in LButtonUp) to clean this up + + if (m_list_remote.GetSelectedCount() > 1) //more than 1 item in list is selected + m_hCursor = AfxGetApp()->LoadCursor(IDC_MUTI_DRAG); + else + m_hCursor = AfxGetApp()->LoadCursor(IDC_DRAG); + + ASSERT(m_hCursor); //make sure it was created + //// Change the cursor to the drag image + //// (still must perform DragMove() in OnMouseMove() to show it moving) + + //// Set dragging flag and others + m_bDragging = TRUE; //we are in a drag and drop operation + m_nDropIndex = -1; //we don't have a drop index yet + m_pDragList = &m_list_remote; //make note of which list we are dragging from + m_pDropWnd = &m_list_remote; //at present the drag list is the drop list + + //// Capture all mouse messages + SetCapture(); + *pResult = 0; +} + +void CFileManagerDlg::OnMouseMove(UINT nFlags, CPoint point) +{ + // TODO: Add your message handler code here and/or call default + //While the mouse is moving, this routine is called. + //This routine will redraw the drag image at the present + // mouse location to display the dragging. + //Also, while over a CListCtrl, this routine will highlight + // the item we are hovering over. + + //// If we are in a drag/drop procedure (m_bDragging is true) + if (m_bDragging) + { + //SetClassLong(m_list_local.m_hWnd, GCL_HCURSOR, (LONG)AfxGetApp()->LoadCursor(IDC_DRAG)); + + //// Move the drag image + CPoint pt(point); //get our current mouse coordinates + ClientToScreen(&pt); //convert to screen coordinates + + //// Get the CWnd pointer of the window that is under the mouse cursor + CWnd* pDropWnd = WindowFromPoint(pt); + + ASSERT(pDropWnd); //make sure we have a window + + //// If we drag outside current window we need to adjust the highlights displayed + if (pDropWnd != m_pDropWnd) + { + if (m_nDropIndex != -1) //If we drag over the CListCtrl header, turn off the hover highlight + { + TRACE("m_nDropIndex is -1\n"); + CListCtrl* pList = (CListCtrl*)m_pDropWnd; + VERIFY(pList->SetItemState(m_nDropIndex, 0, LVIS_DROPHILITED)); + // redraw item + VERIFY(pList->RedrawItems(m_nDropIndex, m_nDropIndex)); + pList->UpdateWindow(); + m_nDropIndex = -1; + } + } + + // Save current window pointer as the CListCtrl we are dropping onto + m_pDropWnd = pDropWnd; + + // Convert from screen coordinates to drop target client coordinates + pDropWnd->ScreenToClient(&pt); + + //If we are hovering over a CListCtrl we need to adjust the highlights + if (pDropWnd->IsKindOf(RUNTIME_CLASS(CListCtrl))) + { + //Note that we can drop here + SetCursor(m_hCursor); + + if (m_pDropWnd->m_hWnd == m_pDragList->m_hWnd) + return; + + UINT uFlags; + CListCtrl* pList = (CListCtrl*)pDropWnd; + + // Turn off hilight for previous drop target + pList->SetItemState(m_nDropIndex, 0, LVIS_DROPHILITED); + // Redraw previous item + pList->RedrawItems(m_nDropIndex, m_nDropIndex); + + // Get the item that is below cursor + m_nDropIndex = ((CListCtrl*)pDropWnd)->HitTest(pt, &uFlags); + if (m_nDropIndex != -1) + { + // Highlight it + pList->SetItemState(m_nDropIndex, LVIS_DROPHILITED, LVIS_DROPHILITED); + // Redraw item + pList->RedrawItems(m_nDropIndex, m_nDropIndex); + pList->UpdateWindow(); + } + } + else + { + //If we are not hovering over a CListCtrl, change the cursor + // to note that we cannot drop here + SetCursor(LoadCursor(NULL, IDC_NO)); + } + } + CDialog::OnMouseMove(nFlags, point); +} + +void CFileManagerDlg::OnLButtonUp(UINT nFlags, CPoint point) +{ + // TODO: Add your message handler code here and/or call default + //This routine is the end of the drag/drop operation. + //When the button is released, we are to drop the item. + //There are a few things we need to do to clean up and + // finalize the drop: + // 1) Release the mouse capture + // 2) Set m_bDragging to false to signify we are not dragging + // 3) Actually drop the item (we call a separate function to do that) + + //If we are in a drag and drop operation (otherwise we don't do anything) + if (m_bDragging) + { + // Release mouse capture, so that other controls can get control/messages + ReleaseCapture(); + + // Note that we are NOT in a drag operation + m_bDragging = FALSE; + + CPoint pt(point); //Get current mouse coordinates + ClientToScreen(&pt); //Convert to screen coordinates + // Get the CWnd pointer of the window that is under the mouse cursor + CWnd* pDropWnd = WindowFromPoint(pt); + ASSERT(pDropWnd); //make sure we have a window pointer + // If window is CListCtrl, we perform the drop + if (pDropWnd->IsKindOf(RUNTIME_CLASS(CListCtrl))) + { + m_pDropList = (CListCtrl*)pDropWnd; //Set pointer to the list we are dropping on + DropItemOnList(m_pDragList, m_pDropList); //Call routine to perform the actual drop + } + } + CDialog::OnLButtonUp(nFlags, point); +} + +BOOL CFileManagerDlg::PreTranslateMessage(MSG* pMsg) +{ + // TODO: Add your specialized code here and/or call the base class + if (pMsg->message == WM_KEYDOWN) + { + if (pMsg->wParam == VK_ESCAPE) + return true; + if (pMsg->wParam == VK_RETURN) + { + if ( + pMsg->hwnd == m_list_local.m_hWnd || + pMsg->hwnd == ((CEdit*)m_Local_Directory_ComboBox.GetWindow(GW_CHILD))->m_hWnd + ) + { + FixedLocalFileList(); + } + else if + ( + pMsg->hwnd == m_list_remote.m_hWnd || + pMsg->hwnd == ((CEdit*)m_Remote_Directory_ComboBox.GetWindow(GW_CHILD))->m_hWnd + ) + { + GetRemoteFileList(); + } + return TRUE; + } + + } + // 单击除了窗口标题栏以外的区域使窗口移动 + if (pMsg->message == WM_LBUTTONDOWN && pMsg->hwnd == m_hWnd) + { + pMsg->message = WM_NCLBUTTONDOWN; + pMsg->wParam = HTCAPTION; + } + /* + UINT CFileManagerDlg::OnNcHitTest (Cpoint point ) + { + UINT nHitTest =Cdialog: : OnNcHitTest (point ) + return (nHitTest = =HTCLIENT)? HTCAPTION : nHitTest + } + + 上述技术有两点不利之处, + 其一是在窗口的客户区域双击时,窗口将极大; + 其二, 它不适合包含几个视窗的主框窗口。 + */ + + + if (m_wndToolBar_Local.IsWindowVisible()) + { + CWnd* pWndParent = m_wndToolBar_Local.GetParent(); + m_wndToolBar_Local.OnUpdateCmdUI((CFrameWnd*)this, TRUE); + } + if (m_wndToolBar_Remote.IsWindowVisible()) + { + CWnd* pWndParent = m_wndToolBar_Remote.GetParent(); + m_wndToolBar_Remote.OnUpdateCmdUI((CFrameWnd*)this, TRUE); + } + + return CDialog::PreTranslateMessage(pMsg); +} +void CFileManagerDlg::OnTimer(UINT nIDEvent) +{ + // TODO: Add your message handler code here and/or call default + m_ProgressCtrl->StepIt(); + CDialog::OnTimer(nIDEvent); +} + +void CFileManagerDlg::FixedRemoteDriveList() +{ + // 加载系统统图标列表 设置驱动器图标列表 + HIMAGELIST hImageListLarge = NULL; + HIMAGELIST hImageListSmall = NULL; + Shell_GetImageLists(&hImageListLarge, &hImageListSmall); + ListView_SetImageList(m_list_remote.m_hWnd, hImageListLarge, LVSIL_NORMAL); + ListView_SetImageList(m_list_remote.m_hWnd, hImageListSmall, LVSIL_SMALL); + + m_list_remote.DeleteAllItems(); + // 重建Column + while (m_list_remote.DeleteColumn(0) != 0); + m_list_remote.InsertColumn(0, "名称", LVCFMT_LEFT, 200); + m_list_remote.InsertColumn(1, "类型", LVCFMT_LEFT, 100); + m_list_remote.InsertColumn(2, "总大小", LVCFMT_LEFT, 100); + m_list_remote.InsertColumn(3, "可用空间", LVCFMT_LEFT, 115); + + + char *pDrive = NULL; + pDrive = (char *)m_bRemoteDriveList; + + unsigned long AmntMB = 0; // 总大小 + unsigned long FreeMB = 0; // 剩余空间 + char VolName[MAX_PATH]; + char FileSystem[MAX_PATH]; + + /* + 6 DRIVE_FLOPPY + 7 DRIVE_REMOVABLE + 8 DRIVE_FIXED + 9 DRIVE_REMOTE + 10 DRIVE_REMOTE_DISCONNECT + 11 DRIVE_CDROM + */ + int nIconIndex = -1; + //用一个循环遍历所有发送来的信息,先是到列表中 + for (int i = 0; pDrive[i] != '\0';) + { + //由驱动器名判断图标的索引 + if (pDrive[i] == 'A' || pDrive[i] == 'B') + { + nIconIndex = 6; + } + else + { + switch (pDrive[i + 1]) + { + case DRIVE_REMOVABLE: + nIconIndex = 7; + break; + case DRIVE_FIXED: + nIconIndex = 8; + break; + case DRIVE_REMOTE: + nIconIndex = 9; + break; + case DRIVE_CDROM: + nIconIndex = 11; + break; + default: + nIconIndex = 8; + break; + } + } + //显示驱动器名 + CString str; + str.Format("%c:\\", pDrive[i]); + int nItem = m_list_remote.InsertItem(i, str, nIconIndex); + m_list_remote.SetItemData(nItem, 1); + //显示驱动器大小 + memcpy(&AmntMB, pDrive + i + 2, 4); + memcpy(&FreeMB, pDrive + i + 6, 4); + str.Format("%10.1f GB", (float)AmntMB / 1024); + m_list_remote.SetItemText(nItem, 2, str); + str.Format("%10.1f GB", (float)FreeMB / 1024); + m_list_remote.SetItemText(nItem, 3, str); + + i += 10; + + char *lpFileSystemName = NULL; + char *lpTypeName = NULL; + + lpTypeName = pDrive + i; + i += lstrlen(pDrive + i) + 1; + lpFileSystemName = pDrive + i; + + // 磁盘类型, 为空就显示磁盘名称 + if (lstrlen(lpFileSystemName) == 0) + { + m_list_remote.SetItemText(nItem, 1, lpTypeName); + } + else + { + m_list_remote.SetItemText(nItem, 1, lpFileSystemName); + } + + + i += lstrlen(pDrive + i) + 1; + } + // 重置远程当前路径 + m_Remote_Path = ""; + m_Remote_Directory_ComboBox.ResetContent(); + + ShowMessage("远程:装载目录 %s 完成", m_Remote_Path); + + //返回OnInitDialog中查看FixedLocalDriveList +} + +void CFileManagerDlg::OnClose() +{ + // TODO: Add your message handler code here and/or call default + CoUninitialize(); + m_pContext->m_Dialog[0] = 0; + closesocket(m_pContext->m_Socket); + + CDialog::OnClose(); +} + +CString CFileManagerDlg::GetParentDirectory(CString strPath) +{ + CString strCurPath = strPath; + int Index = strCurPath.ReverseFind('\\'); + if (Index == -1) + { + return strCurPath; + } + CString str = strCurPath.Left(Index); + Index = str.ReverseFind('\\'); + if (Index == -1) + { + strCurPath = ""; + return strCurPath; + } + strCurPath = str.Left(Index); + + if (strCurPath.Right(1) != "\\") + strCurPath += "\\"; + return strCurPath; +} +void CFileManagerDlg::OnReceiveComplete() +{ + switch (m_pContext->m_DeCompressionBuffer.GetBuffer(0)[0]) + { + case TOKEN_FILE_LIST: // 文件列表 转到定义 + FixedRemoteFileList + ( + m_pContext->m_DeCompressionBuffer.GetBuffer(0), + m_pContext->m_DeCompressionBuffer.GetBufferLen() - 1 + ); + break; + case TOKEN_FILE_SIZE: // 传输文件时的第一个数据包,文件大小,及文件名 + CreateLocalRecvFile(); + break; + case TOKEN_FILE_DATA: // 文件内容 + WriteLocalRecvFile(); + break; + case TOKEN_TRANSFER_FINISH: // 传输完成 + EndLocalRecvFile(); + break; + case TOKEN_CREATEFOLDER_FINISH: + GetRemoteFileList("."); + break; + case TOKEN_DELETE_FINISH: + EndRemoteDeleteFile(); + break; + case TOKEN_GET_TRANSFER_MODE: + SendTransferMode(); + break; + case TOKEN_DATA_CONTINUE: + SendFileData(); + break; + case TOKEN_RENAME_FINISH: + // 刷新远程文件列表 + GetRemoteFileList("."); + break; + default: + SendException(); + break; + } +} + +void CFileManagerDlg::GetRemoteFileList(CString directory) +{ + if (directory.GetLength() == 0) + { + int nItem = m_list_remote.GetSelectionMark(); + + // 如果有选中的,是目录 + if (nItem != -1) + { + if (m_list_remote.GetItemData(nItem) == 1) + { + directory = m_list_remote.GetItemText(nItem, 0); + } + } + // 从组合框里得到路径 + else + { + m_Remote_Directory_ComboBox.GetWindowText(m_Remote_Path); + } + } + // 得到父目录 + if (directory == "..") + { + m_Remote_Path = GetParentDirectory(m_Remote_Path); + } + else if (directory != ".") + { + m_Remote_Path += directory; + if (m_Remote_Path.Right(1) != "\\") + m_Remote_Path += "\\"; + } + + // 是驱动器的根目录,返回磁盘列表 + if (m_Remote_Path.GetLength() == 0) + { + FixedRemoteDriveList(); + return; + } + + // 发送数据前清空缓冲区 + + int PacketSize = m_Remote_Path.GetLength() + 2; + BYTE *bPacket = (BYTE *)LocalAlloc(LPTR, PacketSize); + //将COMMAND_LIST_FILES 发送到服务端,我们到服务端搜索 + bPacket[0] = COMMAND_LIST_FILES; + memcpy(bPacket + 1, m_Remote_Path.GetBuffer(0), PacketSize - 1); + m_iocpServer->Send(m_pContext, bPacket, PacketSize); + LocalFree(bPacket); + + m_Remote_Directory_ComboBox.InsertString(0, m_Remote_Path); + m_Remote_Directory_ComboBox.SetCurSel(0); + + // 得到返回数据前禁窗口 + m_list_remote.EnableWindow(FALSE); + m_ProgressCtrl->SetPos(0); +} +void CFileManagerDlg::OnDblclkListRemote(NMHDR* pNMHDR, LRESULT* pResult) +{ + if (m_list_remote.GetSelectedCount() == 0 || m_list_remote.GetItemData(m_list_remote.GetSelectionMark()) != 1) + return; + // TODO: Add your control notification handler code here + //这里得到服务端文件信息,我们转到GetRemoteFileList + GetRemoteFileList(); + *pResult = 0; +} + +void CFileManagerDlg::FixedRemoteFileList(BYTE *pbBuffer, DWORD dwBufferLen) +{ + // 重新设置ImageList + SHFILEINFO sfi; + HIMAGELIST hImageListLarge = (HIMAGELIST)SHGetFileInfo(NULL, 0, &sfi, sizeof(SHFILEINFO), SHGFI_SYSICONINDEX | SHGFI_LARGEICON); + HIMAGELIST hImageListSmall = (HIMAGELIST)SHGetFileInfo(NULL, 0, &sfi, sizeof(SHFILEINFO), SHGFI_SYSICONINDEX | SHGFI_SMALLICON); + ListView_SetImageList(m_list_remote.m_hWnd, hImageListLarge, LVSIL_NORMAL); + ListView_SetImageList(m_list_remote.m_hWnd, hImageListSmall, LVSIL_SMALL); + + // 重建标题 + m_list_remote.DeleteAllItems(); + while (m_list_remote.DeleteColumn(0) != 0); + m_list_remote.InsertColumn(0, "名称", LVCFMT_LEFT, 200); + m_list_remote.InsertColumn(1, "大小", LVCFMT_LEFT, 100); + m_list_remote.InsertColumn(2, "类型", LVCFMT_LEFT, 100); + m_list_remote.InsertColumn(3, "修改日期", LVCFMT_LEFT, 115); + + + int nItemIndex = 0; + m_list_remote.SetItemData + ( + m_list_remote.InsertItem(nItemIndex++, "..", GetIconIndex(NULL, FILE_ATTRIBUTE_DIRECTORY)), + 1 + ); + /* + ListView 消除闪烁 + 更新数据前用SetRedraw(FALSE) + 更新后调用SetRedraw(TRUE) + */ + m_list_remote.SetRedraw(FALSE); + + if (dwBufferLen != 0) + { + // 遍历发送来的数据显示到列表中 + for (int i = 0; i < 2; i++) + { + // 跳过Token,共5字节 + char *pList = (char *)(pbBuffer + 1); + for (char *pBase = pList; pList - pBase < dwBufferLen - 1;) + { + char *pszFileName = NULL; + DWORD dwFileSizeHigh = 0; // 文件高字节大小 + DWORD dwFileSizeLow = 0; // 文件低字节大小 + int nItem = 0; + bool bIsInsert = false; + FILETIME ftm_strReceiveLocalFileTime; + + int nType = *pList ? FILE_ATTRIBUTE_DIRECTORY : FILE_ATTRIBUTE_NORMAL; + // i 为 0 时,列目录,i为1时列文件 + bIsInsert = !(nType == FILE_ATTRIBUTE_DIRECTORY) == i; + pszFileName = ++pList; + + if (bIsInsert) + { + nItem = m_list_remote.InsertItem(nItemIndex++, pszFileName, GetIconIndex(pszFileName, nType)); + m_list_remote.SetItemData(nItem, nType == FILE_ATTRIBUTE_DIRECTORY); + SHFILEINFO sfi; + SHGetFileInfo(pszFileName, FILE_ATTRIBUTE_NORMAL | nType, &sfi, sizeof(SHFILEINFO), SHGFI_TYPENAME | SHGFI_USEFILEATTRIBUTES); + m_list_remote.SetItemText(nItem, 2, sfi.szTypeName); + } + + // 得到文件大小 + pList += lstrlen(pszFileName) + 1; + if (bIsInsert) + { + memcpy(&dwFileSizeHigh, pList, 4); + memcpy(&dwFileSizeLow, pList + 4, 4); + CString strSize; + strSize.Format("%10d KB", (dwFileSizeHigh * (MAXDWORD + 1)) / 1024 + dwFileSizeLow / 1024 + (dwFileSizeLow % 1024 ? 1 : 0)); + m_list_remote.SetItemText(nItem, 1, strSize); + memcpy(&ftm_strReceiveLocalFileTime, pList + 8, sizeof(FILETIME)); + CTime time(ftm_strReceiveLocalFileTime); + m_list_remote.SetItemText(nItem, 3, time.Format("%Y-%m-%d %H:%M")); + } + pList += 16; + } + } + } + + m_list_remote.SetRedraw(TRUE); + // 恢复窗口 + m_list_remote.EnableWindow(TRUE); + + + //文件的删除 创建,更名 的功能我们在第二节中已经讲解了 + ShowMessage("远程:装载目录 %s 完成", m_Remote_Path); +} + +void CFileManagerDlg::ShowMessage(char *lpFmt, ...) +{ + /*char buff[1024]; + va_list arglist; + va_start( arglist, lpFmt ); + + memset(buff, 0, sizeof(buff)); + + vsprintf(buff, lpFmt, arglist); + m_wndStatusBar.SetPaneText(0, buff); + va_end( arglist );*/ +} + +void CFileManagerDlg::OnLocalPrev() +{ + // TODO: Add your command handler code here + FixedLocalFileList(".."); +} + +void CFileManagerDlg::OnRemotePrev() +{ + // TODO: Add your command handler code here + GetRemoteFileList(".."); +} + +void CFileManagerDlg::OnLocalView() +{ + // TODO: Add your command handler code here + m_list_local.ModifyStyle(LVS_TYPEMASK, LVS_ICON); +} + +// 在工具栏上显示ToolTip +BOOL CFileManagerDlg::OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESULT* pResult) +{ + ASSERT(pNMHDR->code == TTN_NEEDTEXTA || pNMHDR->code == TTN_NEEDTEXTW); + //让上一层的边框窗口优先处理该消息 + if (GetRoutingFrame() != NULL) + return FALSE; + + + //分ANSI and UNICODE两个处理版本 + TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR; + TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR; + TCHAR szFullText[256]; + + CString strTipText; + UINT nID = pNMHDR->idFrom; + + //如果idFrom是一个子窗口,则得到其ID。 + + if ( + pNMHDR->code == TTN_NEEDTEXTA + && (pTTTA->uFlags & TTF_IDISHWND) + || pNMHDR->code == TTN_NEEDTEXTW + && (pTTTW->uFlags & TTF_IDISHWND) + ) + { + //idFrom是工具条的句柄 + nID = ::GetDlgCtrlID((HWND)nID); + } + + if (nID != 0) //若是0,为一分隔栏,不是按钮 + { + //得到nID对应的字符串 + AfxLoadString(nID, szFullText); + //从上面得到的字符串中取出Tooltip使用的文本 + AfxExtractSubString(strTipText, szFullText, 1, '\n'); + } + + //复制分离出的文本 +#ifndef _UNICODE + if (pNMHDR->code == TTN_NEEDTEXTA) + lstrcpyn(pTTTA->szText, strTipText, sizeof(pTTTA->szText)); + else + _mbstowcsz(pTTTW->szText, strTipText, sizeof(pTTTW->szText)); +#else + if (pNMHDR->code == TTN_NEEDTEXTA) + _wcstombsz(pTTTA->szText, strTipText, sizeof(pTTTA->szText)); + else + lstrcpyn(pTTTW->szText, strTipText, sizeof(pTTTW->szText)); +#endif + *pResult = 0; + //显示Tooltip窗口 + ::SetWindowPos(pNMHDR->hwndFrom, HWND_TOP, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE); + return TRUE; //消息处理完毕 +} + +//////////////////////////////////以下为工具栏响应处理////////////////////////////////////////// +void CFileManagerDlg::OnLocalList() +{ + // TODO: Add your command handler code here + m_list_local.ModifyStyle(LVS_TYPEMASK, LVS_LIST); +} + +void CFileManagerDlg::OnLocalReport() +{ + // TODO: Add your command handler code here + m_list_local.ModifyStyle(LVS_TYPEMASK, LVS_REPORT); +} + +void CFileManagerDlg::OnLocalBigicon() +{ + // TODO: Add your command handler code here + m_list_local.ModifyStyle(LVS_TYPEMASK, LVS_ICON); +} + +void CFileManagerDlg::OnLocalSmallicon() +{ + // TODO: Add your command handler code here + m_list_local.ModifyStyle(LVS_TYPEMASK, LVS_SMALLICON); +} + +void CFileManagerDlg::OnRemoteList() +{ + // TODO: Add your command handler code here + m_list_remote.ModifyStyle(LVS_TYPEMASK, LVS_LIST); +} + +void CFileManagerDlg::OnRemoteReport() +{ + // TODO: Add your command handler code here + m_list_remote.ModifyStyle(LVS_TYPEMASK, LVS_REPORT); +} + +void CFileManagerDlg::OnRemoteBigicon() +{ + // TODO: Add your command handler code here + m_list_remote.ModifyStyle(LVS_TYPEMASK, LVS_ICON); +} + +void CFileManagerDlg::OnRemoteSmallicon() +{ + // TODO: Add your command handler code here + m_list_remote.ModifyStyle(LVS_TYPEMASK, LVS_SMALLICON); +} + +void CFileManagerDlg::OnRemoteView() +{ + // TODO: Add your command handler code here + m_list_remote.ModifyStyle(LVS_TYPEMASK, LVS_ICON); +} + + +// 为根目录时禁用向上按钮 +void CFileManagerDlg::OnUpdateLocalPrev(CCmdUI* pCmdUI) +{ + // TODO: Add your command update UI handler code here + pCmdUI->Enable(m_Local_Path.GetLength() && m_list_local.IsWindowEnabled()); +} + +void CFileManagerDlg::OnUpdateLocalDelete(CCmdUI* pCmdUI) +{ + // TODO: Add your command update UI handler code here + // 不是根目录,并且选择项目大于0 + pCmdUI->Enable(m_Local_Path.GetLength() && m_list_local.GetSelectedCount() && m_list_local.IsWindowEnabled()); +} + +void CFileManagerDlg::OnUpdateLocalNewfolder(CCmdUI* pCmdUI) +{ + // TODO: Add your command update UI handler code here + pCmdUI->Enable(m_Local_Path.GetLength() && m_list_local.IsWindowEnabled()); +} + +void CFileManagerDlg::OnUpdateLocalCopy(CCmdUI* pCmdUI) +{ + // TODO: Add your command update UI handler code here + + pCmdUI->Enable + ( + m_list_local.IsWindowEnabled() + && (m_Remote_Path.GetLength() || m_list_remote.GetSelectedCount()) // 远程路径为空,或者有选择 + && m_list_local.GetSelectedCount()// 本地路径为空,或者有选择 + ); +} + + +void CFileManagerDlg::OnUpdateLocalStop(CCmdUI* pCmdUI) +{ + // TODO: Add your command update UI handler code here + pCmdUI->Enable(!m_list_local.IsWindowEnabled() && m_bIsUpload); + +} + +void CFileManagerDlg::OnUpdateRemotePrev(CCmdUI* pCmdUI) +{ + // TODO: Add your command update UI handler code here + pCmdUI->Enable(m_Remote_Path.GetLength() && m_list_remote.IsWindowEnabled()); +} + +void CFileManagerDlg::OnUpdateRemoteCopy(CCmdUI* pCmdUI) +{ + // TODO: Add your command update UI handler code here + // 不是根目录,并且选择项目大于0 + pCmdUI->Enable + ( + m_list_remote.IsWindowEnabled() + && (m_Local_Path.GetLength() || m_list_local.GetSelectedCount()) // 本地路径为空,或者有选择 + && m_list_remote.GetSelectedCount() // 远程路径为空,或者有选择 + ); +} + +void CFileManagerDlg::OnUpdateRemoteDelete(CCmdUI* pCmdUI) +{ + // TODO: Add your command update UI handler code here + // 不是根目录,并且选择项目大于0 + pCmdUI->Enable(m_Remote_Path.GetLength() && m_list_remote.GetSelectedCount() && m_list_remote.IsWindowEnabled()); +} + +void CFileManagerDlg::OnUpdateRemoteNewfolder(CCmdUI* pCmdUI) +{ + // TODO: Add your command update UI handler code here + pCmdUI->Enable(m_Remote_Path.GetLength() && m_list_remote.IsWindowEnabled()); +} + +void CFileManagerDlg::OnUpdateRemoteStop(CCmdUI* pCmdUI) +{ + // TODO: Add your command update UI handler code here + pCmdUI->Enable(!m_list_remote.IsWindowEnabled() && !m_bIsUpload); +} +bool CFileManagerDlg::FixedUploadDirectory(LPCTSTR lpPathName) +{ + char lpszFilter[MAX_PATH]; + char *lpszSlash = NULL; + memset(lpszFilter, 0, sizeof(lpszFilter)); + + if (lpPathName[lstrlen(lpPathName) - 1] != '\\') + lpszSlash = "\\"; + else + lpszSlash = ""; + + wsprintf(lpszFilter, "%s%s*.*", lpPathName, lpszSlash); + + + WIN32_FIND_DATA wfd; + HANDLE hFind = FindFirstFile(lpszFilter, &wfd); + if (hFind == INVALID_HANDLE_VALUE) // 如果没有找到或查找失败 + return FALSE; + + do + { + if (wfd.cFileName[0] == '.') + continue; // 过滤这两个目录 + if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) + { + char strDirectory[MAX_PATH]; + wsprintf(strDirectory, "%s%s%s", lpPathName, lpszSlash, wfd.cFileName); + FixedUploadDirectory(strDirectory); // 如果找到的是目录,则进入此目录进行递归 + } + else + { + CString file; + file.Format("%s%s%s", lpPathName, lpszSlash, wfd.cFileName); + //printf("send file %s\n",strFile); + m_Remote_Upload_Job.AddTail(file); + // 对文件进行操作 + } + } while (FindNextFile(hFind, &wfd)); + FindClose(hFind); // 关闭查找句柄 + return true; +} + +void CFileManagerDlg::EnableControl(BOOL bEnable) +{ + m_list_local.EnableWindow(bEnable); + m_list_remote.EnableWindow(bEnable); + m_Local_Directory_ComboBox.EnableWindow(bEnable); + m_Remote_Directory_ComboBox.EnableWindow(bEnable); +} +void CFileManagerDlg::OnLocalCopy() +{ + m_bIsUpload = true; + // TODO: Add your command handler code here + + // TODO: Add your command handler code here + // 如果Drag的,找到Drop到了哪个文件夹 + if (m_nDropIndex != -1 && m_pDropList->GetItemData(m_nDropIndex)) + m_hCopyDestFolder = m_pDropList->GetItemText(m_nDropIndex, 0); + // 重置上传任务列表 + m_Remote_Upload_Job.RemoveAll(); + POSITION pos = m_list_local.GetFirstSelectedItemPosition(); //iterator for the CListCtrl + while (pos) //so long as we have a valid POSITION, we keep iterating + { + int nItem = m_list_local.GetNextSelectedItem(pos); + CString file = m_Local_Path + m_list_local.GetItemText(nItem, 0); + // 如果是目录 + if (m_list_local.GetItemData(nItem)) + { + file += '\\'; + FixedUploadDirectory(file.GetBuffer(0)); + } + else + { + // 添加到上传任务列表中去 + m_Remote_Upload_Job.AddTail(file); + } + + } //EO while(pos) -- at this point we have deleted the moving items and stored them in memory + if (m_Remote_Upload_Job.IsEmpty()) + { + ::MessageBox(m_hWnd, "文件夹为空", "警告", MB_OK | MB_ICONWARNING); + return; + } + EnableControl(FALSE); + SendUploadJob(); +} + +//////////////// 文件传输操作 //////////////// +// 只管发出了下载的文件 +// 一个一个发,接收到下载完成时,下载第二个文件 ... +void CFileManagerDlg::OnRemoteCopy() +{ + m_bIsUpload = false; + // 禁用文件管理窗口 + EnableControl(FALSE); + + // TODO: Add your command handler code here + // 如果Drag的,找到Drop到了哪个文件夹 + if (m_nDropIndex != -1 && m_pDropList->GetItemData(m_nDropIndex)) + m_hCopyDestFolder = m_pDropList->GetItemText(m_nDropIndex, 0); + + // 重置下载任务列表 添加到下载任务列表中去 + m_Remote_Download_Job.RemoveAll(); + POSITION pos = m_list_remote.GetFirstSelectedItemPosition(); //iterator for the CListCtrl + //得到远程文件名 + while (pos) //so long as we have a valid POSITION, we keep iterating + { + int nItem = m_list_remote.GetNextSelectedItem(pos); + CString file = m_Remote_Path + m_list_remote.GetItemText(nItem, 0); + // 如果是目录 + if (m_list_remote.GetItemData(nItem)) + file += '\\'; + // 添加到下载任务列表中去 + m_Remote_Download_Job.AddTail(file); + } //EO while(pos) -- at this point we have deleted the moving items and stored them in memory + + // 发送第一个下载任务 + SendDownloadJob(); +} + +// 发出一个下载任务 +BOOL CFileManagerDlg::SendDownloadJob() +{ + + if (m_Remote_Download_Job.IsEmpty()) + return FALSE; + + // 发出第一个下载任务命令 + CString file = m_Remote_Download_Job.GetHead(); + int nPacketSize = file.GetLength() + 2; + BYTE *bPacket = (BYTE *)LocalAlloc(LPTR, nPacketSize); + bPacket[0] = COMMAND_DOWN_FILES; + // 文件偏移,续传时用 + memcpy(bPacket + 1, file.GetBuffer(0), file.GetLength() + 1); + m_iocpServer->Send(m_pContext, bPacket, nPacketSize); + + LocalFree(bPacket); + // 从下载任务列表中删除自己 + m_Remote_Download_Job.RemoveHead(); + //服务端搜索COMMAND_DOWN_FILES + return TRUE; +} + +// 发出一个上传任务 +BOOL CFileManagerDlg::SendUploadJob() +{ + if (m_Remote_Upload_Job.IsEmpty()) + return FALSE; + + CString strDestDirectory = m_Remote_Path; + // 如果远程也有选择,当做目标文件夹 + int nItem = m_list_remote.GetSelectionMark(); + + // 是文件夹 + if (nItem != -1 && m_list_remote.GetItemData(nItem) == 1) + { + strDestDirectory += m_list_remote.GetItemText(nItem, 0) + "\\"; + } + + if (!m_hCopyDestFolder.IsEmpty()) + { + strDestDirectory += m_hCopyDestFolder + "\\"; + } + + // 发出第一个下载任务命令 + m_strOperatingFile = m_Remote_Upload_Job.GetHead(); + + DWORD dwSizeHigh; + DWORD dwSizeLow; + // 1 字节token, 8字节大小, 文件名称, '\0' + HANDLE hFile; + CString fileRemote = m_strOperatingFile; // 远程文件 + // 得到要保存到的远程的文件路径 + fileRemote.Replace(m_Local_Path, strDestDirectory); + m_strUploadRemoteFile = fileRemote; + hFile = CreateFile(m_strOperatingFile.GetBuffer(0), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); + if (hFile == INVALID_HANDLE_VALUE) + return FALSE; + dwSizeLow = GetFileSize(hFile, &dwSizeHigh); + m_nOperatingFileLength = (dwSizeHigh * (MAXDWORD + 1)) + dwSizeLow; + + CloseHandle(hFile); + // 构造数据包,发送文件长度 + int nPacketSize = fileRemote.GetLength() + 10; + BYTE *bPacket = (BYTE *)LocalAlloc(LPTR, nPacketSize); + memset(bPacket, 0, nPacketSize); + + bPacket[0] = COMMAND_FILE_SIZE; + memcpy(bPacket + 1, &dwSizeHigh, sizeof(DWORD)); + memcpy(bPacket + 5, &dwSizeLow, sizeof(DWORD)); + memcpy(bPacket + 9, fileRemote.GetBuffer(0), fileRemote.GetLength() + 1); + + m_iocpServer->Send(m_pContext, bPacket, nPacketSize); + + LocalFree(bPacket); + + // 从下载任务列表中删除自己 + m_Remote_Upload_Job.RemoveHead(); + return TRUE; +} + +// 发出一个删除任务 +BOOL CFileManagerDlg::SendDeleteJob() +{ + if (m_Remote_Delete_Job.IsEmpty()) + return FALSE; + // 发出第一个下载任务命令 + CString file = m_Remote_Delete_Job.GetHead(); + int nPacketSize = file.GetLength() + 2; + BYTE *bPacket = (BYTE *)LocalAlloc(LPTR, nPacketSize); + + if (file.GetAt(file.GetLength() - 1) == '\\') + { + ShowMessage("远程:删除目录 %s\*.* 完成", file); + bPacket[0] = COMMAND_DELETE_DIRECTORY; + } + else + { + ShowMessage("远程:删除文件 %s 完成", file); + bPacket[0] = COMMAND_DELETE_FILE; + } + // 文件偏移,续传时用 + memcpy(bPacket + 1, file.GetBuffer(0), nPacketSize - 1); + m_iocpServer->Send(m_pContext, bPacket, nPacketSize); + + LocalFree(bPacket); + // 从下载任务列表中删除自己 + m_Remote_Delete_Job.RemoveHead(); + return TRUE; +} + +void CFileManagerDlg::CreateLocalRecvFile() +{ + // 重置计数器 + m_nCounter = 0; + + CString strDestDirectory = m_Local_Path; + // 如果本地也有选择,当做目标文件夹 + int nItem = m_list_local.GetSelectionMark(); + + // 是文件夹 + if (nItem != -1 && m_list_local.GetItemData(nItem) == 1) + { + strDestDirectory += m_list_local.GetItemText(nItem, 0) + "\\"; + } + + if (!m_hCopyDestFolder.IsEmpty()) + { + strDestDirectory += m_hCopyDestFolder + "\\"; + } + + FILESIZE *pFileSize = (FILESIZE *)(m_pContext->m_DeCompressionBuffer.GetBuffer(1)); + DWORD dwSizeHigh = pFileSize->dwSizeHigh; + DWORD dwSizeLow = pFileSize->dwSizeLow; + + m_nOperatingFileLength = (dwSizeHigh * (MAXDWORD + 1)) + dwSizeLow; + + // 当前正操作的文件名 + m_strOperatingFile = m_pContext->m_DeCompressionBuffer.GetBuffer(9); + + m_strReceiveLocalFile = m_strOperatingFile; + + // 得到要保存到的本地的文件路径 + m_strReceiveLocalFile.Replace(m_Remote_Path, strDestDirectory); + + // 创建多层目录 + MakeSureDirectoryPathExists(m_strReceiveLocalFile.GetBuffer(0)); + + + WIN32_FIND_DATA FindFileData; + HANDLE hFind = FindFirstFile(m_strReceiveLocalFile.GetBuffer(0), &FindFileData); + + //判断文件是否存在 ,传输的任务是什么 + if (hFind != INVALID_HANDLE_VALUE + && m_nTransferMode != TRANSFER_MODE_OVERWRITE_ALL + && m_nTransferMode != TRANSFER_MODE_ADDITION_ALL + && m_nTransferMode != TRANSFER_MODE_JUMP_ALL + ) + { + + CFileTransferModeDlg dlg(this); + dlg.m_strFileName = m_strReceiveLocalFile; + //如果本地存在该同名文件时的处理 + switch (dlg.DoModal()) + { + case IDC_OVERWRITE: + m_nTransferMode = TRANSFER_MODE_OVERWRITE; + break; + case IDC_OVERWRITE_ALL: + m_nTransferMode = TRANSFER_MODE_OVERWRITE_ALL; + break; + case IDC_ADDITION: + m_nTransferMode = TRANSFER_MODE_ADDITION; + break; + case IDC_ADDITION_ALL: + m_nTransferMode = TRANSFER_MODE_ADDITION_ALL; + break; + case IDC_JUMP: + m_nTransferMode = TRANSFER_MODE_JUMP; + break; + case IDC_JUMP_ALL: + m_nTransferMode = TRANSFER_MODE_JUMP_ALL; + break; + case IDC_CANCEL: + m_nTransferMode = TRANSFER_MODE_CANCEL; + break; + } + } + + if (m_nTransferMode == TRANSFER_MODE_CANCEL) + { + // 取消传送 + m_bIsStop = true; + SendStop(); + return; + } + int nTransferMode; + switch (m_nTransferMode) + { + case TRANSFER_MODE_OVERWRITE_ALL: + nTransferMode = TRANSFER_MODE_OVERWRITE; + break; + case TRANSFER_MODE_ADDITION_ALL: + nTransferMode = TRANSFER_MODE_ADDITION; + break; + case TRANSFER_MODE_JUMP_ALL: + nTransferMode = TRANSFER_MODE_JUMP; + break; + default: + nTransferMode = m_nTransferMode; + } + + //得到文件大小 + // 1字节Token,四字节偏移高四位,四字节偏移低四位 + BYTE bToken[9]; + DWORD dwCreationDisposition; // 文件打开方式 + memset(bToken, 0, sizeof(bToken)); + bToken[0] = COMMAND_CONTINUE; //要发送的数据头 + + // 文件已经存在 + if (hFind != INVALID_HANDLE_VALUE) + { + // 提示点什么 + // 如果是续传 + if (nTransferMode == TRANSFER_MODE_ADDITION) + { + memcpy(bToken + 1, &FindFileData.nFileSizeHigh, 4); + memcpy(bToken + 5, &FindFileData.nFileSizeLow, 4); + // 接收的长度递增 + m_nCounter += FindFileData.nFileSizeHigh * (MAXDWORD + 1); + m_nCounter += FindFileData.nFileSizeLow; + + dwCreationDisposition = OPEN_EXISTING; + } + // 覆盖 + else if (nTransferMode == TRANSFER_MODE_OVERWRITE) + { + // 偏移置0 + memset(bToken + 1, 0, 8); + // 重新创建 + dwCreationDisposition = CREATE_ALWAYS; + + } + // 跳过,指针移到-1 + else if (nTransferMode == TRANSFER_MODE_JUMP) + { + m_ProgressCtrl->SetPos(100); + DWORD dwOffset = -1; + memcpy(bToken + 5, &dwOffset, 4); + dwCreationDisposition = OPEN_EXISTING; + } + } + else + { + // 偏移置0 + memset(bToken + 1, 0, 8); + // 重新创建 + dwCreationDisposition = CREATE_ALWAYS; + } + FindClose(hFind); + + //创建文件 + HANDLE hFile = + CreateFile + ( + m_strReceiveLocalFile.GetBuffer(0), + GENERIC_WRITE, + FILE_SHARE_WRITE, + NULL, + dwCreationDisposition, + FILE_ATTRIBUTE_NORMAL, + 0 + ); + // 需要错误处理 + if (hFile == INVALID_HANDLE_VALUE) + { + m_nOperatingFileLength = 0; + m_nCounter = 0; + ::MessageBox(m_hWnd, m_strReceiveLocalFile + " 文件创建失败", "警告", MB_OK | MB_ICONWARNING); + return; + } + CloseHandle(hFile); + + ShowProgress(); + if (m_bIsStop) + SendStop(); + else + { + // 发送继续传输文件的token,包含文件续传的偏移 服务端搜索COMMAND_CONTINUE + m_iocpServer->Send(m_pContext, bToken, sizeof(bToken)); + } +} +// 写入文件内容 + +void CFileManagerDlg::WriteLocalRecvFile() +{ + + // 传输完毕 + BYTE *pData; + DWORD dwBytesToWrite; + DWORD dwBytesWrite; + int nHeadLength = 9; // 1 + 4 + 4 数据包头部大小,为固定的9 + FILESIZE *pFileSize; + // 得到数据的偏移 + pData = m_pContext->m_DeCompressionBuffer.GetBuffer(nHeadLength); + + pFileSize = (FILESIZE *)m_pContext->m_DeCompressionBuffer.GetBuffer(1); + // 得到数据在文件中的偏移, 赋值给计数器 + m_nCounter = MAKEINT64(pFileSize->dwSizeLow, pFileSize->dwSizeHigh); + + LONG dwOffsetHigh = pFileSize->dwSizeHigh; + LONG dwOffsetLow = pFileSize->dwSizeLow; + + + dwBytesToWrite = m_pContext->m_DeCompressionBuffer.GetBufferLen() - nHeadLength; + + //打开文件 + HANDLE hFile = + CreateFile + ( + m_strReceiveLocalFile.GetBuffer(0), + GENERIC_WRITE, + FILE_SHARE_WRITE, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + 0 + ); + + //指向文件偏移 ,这个偏移是每次数据大小的累加 + SetFilePointer(hFile, dwOffsetLow, &dwOffsetHigh, FILE_BEGIN); + + int nRet = 0; + int i; + //写入文件 + for (i = 0; i < MAX_WRITE_RETRY; i++) + { + // 写入文件 + nRet = WriteFile + ( + hFile, + pData, + dwBytesToWrite, + &dwBytesWrite, + NULL + ); + if (nRet > 0) + { + break; + } + } + + if (i == MAX_WRITE_RETRY && nRet <= 0) + { + ::MessageBox(m_hWnd, m_strReceiveLocalFile + " 文件写入失败", "警告", MB_OK | MB_ICONWARNING); + } + CloseHandle(hFile); + // 为了比较,计数器递增 + m_nCounter += dwBytesWrite; + ShowProgress(); + if (m_bIsStop) + SendStop(); + else + { + BYTE bToken[9]; + bToken[0] = COMMAND_CONTINUE; + dwOffsetLow += dwBytesWrite; //这里就是文件指针的那个偏移度了,每次递加 + memcpy(bToken + 1, &dwOffsetHigh, sizeof(dwOffsetHigh)); + memcpy(bToken + 5, &dwOffsetLow, sizeof(dwOffsetLow)); + m_iocpServer->Send(m_pContext, bToken, sizeof(bToken)); + } + + //文件管理就这样草草的分析到这里吧 ,剩下的我们边做变理解。。。。。。。。 +} + +void CFileManagerDlg::EndLocalRecvFile() +{ + m_nCounter = 0; + m_strOperatingFile = ""; + m_nOperatingFileLength = 0; + + if (m_Remote_Download_Job.IsEmpty() || m_bIsStop) + { + m_Remote_Download_Job.RemoveAll(); + m_bIsStop = false; + // 重置传输方式 + m_nTransferMode = TRANSFER_MODE_NORMAL; + EnableControl(TRUE); + FixedLocalFileList("."); + ShowMessage("本地:装载目录 %s\*.* 完成", m_Local_Path); + } + else + { + // 我靠,不sleep下会出错,服了可能以前的数据还没send出去 + Sleep(5); + SendDownloadJob(); + } + return; +} + +void CFileManagerDlg::EndLocalUploadFile() +{ + + m_nCounter = 0; + m_strOperatingFile = ""; + m_nOperatingFileLength = 0; + + if (m_Remote_Upload_Job.IsEmpty() || m_bIsStop) + { + m_Remote_Upload_Job.RemoveAll(); + m_bIsStop = false; + EnableControl(TRUE); + GetRemoteFileList("."); + ShowMessage("远程:装载目录 %s\*.* 完成", m_Remote_Path); + } + else + { + // 我靠,不sleep下会出错,服了可能以前的数据还没send出去 + Sleep(5); + SendUploadJob(); + } + return; +} +void CFileManagerDlg::EndRemoteDeleteFile() +{ + if (m_Remote_Delete_Job.IsEmpty() || m_bIsStop) + { + m_bIsStop = false; + EnableControl(TRUE); + GetRemoteFileList("."); + ShowMessage("远程:装载目录 %s\*.* 完成", m_Remote_Path); + } + else + { + // 我靠,不sleep下会出错,服了可能以前的数据还没send出去 + Sleep(5); + SendDeleteJob(); + } + return; +} + + +void CFileManagerDlg::SendException() +{ + BYTE bBuff = COMMAND_EXCEPTION; + m_iocpServer->Send(m_pContext, &bBuff, 1); +} + +void CFileManagerDlg::SendContinue() +{ + BYTE bBuff = COMMAND_CONTINUE; + m_iocpServer->Send(m_pContext, &bBuff, 1); +} + +void CFileManagerDlg::SendStop() +{ + BYTE bBuff = COMMAND_STOP; + m_iocpServer->Send(m_pContext, &bBuff, 1); +} + +void CFileManagerDlg::ShowProgress() +{ + char *lpDirection = NULL; + if (m_bIsUpload) + lpDirection = "传送文件"; + else + lpDirection = "接收文件"; + + + if ((int)m_nCounter == -1) + { + m_nCounter = m_nOperatingFileLength; + } + + int progress = (float)(m_nCounter * 100) / m_nOperatingFileLength; + ShowMessage("%s %s %dKB (%d%%)", lpDirection, m_strOperatingFile, (int)(m_nCounter / 1024), progress); + m_ProgressCtrl->SetPos(progress); + + if (m_nCounter == m_nOperatingFileLength) + { + m_nCounter = m_nOperatingFileLength = 0; + // 关闭文件句柄 + } +} + +void CFileManagerDlg::OnLocalDelete() +{ + m_bIsUpload = true; + CString str; + if (m_list_local.GetSelectedCount() > 1) + str.Format("确定要将这 %d 项删除吗?", m_list_local.GetSelectedCount()); + else + { + CString file = m_list_local.GetItemText(m_list_local.GetSelectionMark(), 0); + if (m_list_local.GetItemData(m_list_local.GetSelectionMark()) == 1) + str.Format("确实要删除文件夹“%s”并将所有内容删除吗?", file); + else + str.Format("确实要把“%s”删除吗?", file); + } + if (::MessageBox(m_hWnd, str, "确认删除", MB_YESNO | MB_ICONQUESTION) == IDNO) + return; + + EnableControl(FALSE); + + POSITION pos = m_list_local.GetFirstSelectedItemPosition(); //iterator for the CListCtrl + while (pos) //so long as we have a valid POSITION, we keep iterating + { + int nItem = m_list_local.GetNextSelectedItem(pos); + CString file = m_Local_Path + m_list_local.GetItemText(nItem, 0); + // 如果是目录 + if (m_list_local.GetItemData(nItem)) + { + file += '\\'; + DeleteDirectory(file); + } + else + { + DeleteFile(file); + } + } //EO while(pos) -- at this point we have deleted the moving items and stored them in memory + // 禁用文件管理窗口 + EnableControl(TRUE); + + FixedLocalFileList("."); +} + +void CFileManagerDlg::OnRemoteDelete() +{ + m_bIsUpload = false; + // TODO: Add your command handler code here + CString str; + if (m_list_remote.GetSelectedCount() > 1) + str.Format("确定要将这 %d 项删除吗?", m_list_remote.GetSelectedCount()); + else + { + CString file = m_list_remote.GetItemText(m_list_remote.GetSelectionMark(), 0); + if (m_list_remote.GetItemData(m_list_remote.GetSelectionMark()) == 1) + str.Format("确实要删除文件夹“%s”并将所有内容删除吗?", file); + else + str.Format("确实要把“%s”删除吗?", file); + } + if (::MessageBox(m_hWnd, str, "确认删除", MB_YESNO | MB_ICONQUESTION) == IDNO) + return; + m_Remote_Delete_Job.RemoveAll(); + POSITION pos = m_list_remote.GetFirstSelectedItemPosition(); //iterator for the CListCtrl + while (pos) //so long as we have a valid POSITION, we keep iterating + { + int nItem = m_list_remote.GetNextSelectedItem(pos); + CString file = m_Remote_Path + m_list_remote.GetItemText(nItem, 0); + // 如果是目录 + if (m_list_remote.GetItemData(nItem)) + file += '\\'; + + m_Remote_Delete_Job.AddTail(file); + } //EO while(pos) -- at this point we have deleted the moving items and stored them in memory + + EnableControl(FALSE); + // 发送第一个下载任务 + SendDeleteJob(); +} + +void CFileManagerDlg::OnRemoteStop() +{ + // TODO: Add your command handler code here + m_bIsStop = true; +} + +void CFileManagerDlg::OnLocalStop() +{ + // TODO: Add your command handler code here + m_bIsStop = true; +} + +void CFileManagerDlg::PostNcDestroy() +{ + // TODO: Add your specialized code here and/or call the base class + delete this; + CDialog::PostNcDestroy(); +} + +void CFileManagerDlg::SendTransferMode() +{ + CFileTransferModeDlg dlg(this); + dlg.m_strFileName = m_strUploadRemoteFile; + switch (dlg.DoModal()) + { + case IDC_OVERWRITE: + m_nTransferMode = TRANSFER_MODE_OVERWRITE; + break; + case IDC_OVERWRITE_ALL: + m_nTransferMode = TRANSFER_MODE_OVERWRITE_ALL; + break; + case IDC_ADDITION: + m_nTransferMode = TRANSFER_MODE_ADDITION; + break; + case IDC_ADDITION_ALL: + m_nTransferMode = TRANSFER_MODE_ADDITION_ALL; + break; + case IDC_JUMP: + m_nTransferMode = TRANSFER_MODE_JUMP; + break; + case IDC_JUMP_ALL: + m_nTransferMode = TRANSFER_MODE_JUMP_ALL; + break; + case IDC_CANCEL: + m_nTransferMode = TRANSFER_MODE_CANCEL; + break; + } + if (m_nTransferMode == TRANSFER_MODE_CANCEL) + { + m_bIsStop = true; + EndLocalUploadFile(); + return; + } + + BYTE bToken[5]; + bToken[0] = COMMAND_SET_TRANSFER_MODE; + memcpy(bToken + 1, &m_nTransferMode, sizeof(m_nTransferMode)); + m_iocpServer->Send(m_pContext, (unsigned char *)&bToken, sizeof(bToken)); +} + +void CFileManagerDlg::SendFileData() +{ + FILESIZE *pFileSize = (FILESIZE *)(m_pContext->m_DeCompressionBuffer.GetBuffer(1)); + LONG dwOffsetHigh = pFileSize->dwSizeHigh; + LONG dwOffsetLow = pFileSize->dwSizeLow; + + m_nCounter = MAKEINT64(pFileSize->dwSizeLow, pFileSize->dwSizeHigh); + + ShowProgress(); + + + if (m_nCounter == m_nOperatingFileLength || pFileSize->dwSizeLow == -1 || m_bIsStop) + { + EndLocalUploadFile(); + return; + } + + + HANDLE hFile; + hFile = CreateFile(m_strOperatingFile.GetBuffer(0), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); + if (hFile == INVALID_HANDLE_VALUE) + { + return; + } + + SetFilePointer(hFile, dwOffsetLow, &dwOffsetHigh, FILE_BEGIN); + + int nHeadLength = 9; // 1 + 4 + 4 数据包头部大小,为固定的9 + + DWORD nNumberOfBytesToRead = MAX_SEND_BUFFER - nHeadLength; + DWORD nNumberOfBytesRead = 0; + BYTE *lpBuffer = (BYTE *)LocalAlloc(LPTR, MAX_SEND_BUFFER); + // Token, 大小,偏移,数据 + lpBuffer[0] = COMMAND_FILE_DATA; + memcpy(lpBuffer + 1, &dwOffsetHigh, sizeof(dwOffsetHigh)); + memcpy(lpBuffer + 5, &dwOffsetLow, sizeof(dwOffsetLow)); + // 返回值 + bool bRet = true; + ReadFile(hFile, lpBuffer + nHeadLength, nNumberOfBytesToRead, &nNumberOfBytesRead, NULL); + CloseHandle(hFile); + + + if (nNumberOfBytesRead > 0) + { + int nPacketSize = nNumberOfBytesRead + nHeadLength; + m_iocpServer->Send(m_pContext, lpBuffer, nPacketSize); + } + LocalFree(lpBuffer); +} + + +bool CFileManagerDlg::DeleteDirectory(LPCTSTR lpszDirectory) +{ + WIN32_FIND_DATA wfd; + char lpszFilter[MAX_PATH]; + + wsprintf(lpszFilter, "%s\\*.*", lpszDirectory); + + HANDLE hFind = FindFirstFile(lpszFilter, &wfd); + if (hFind == INVALID_HANDLE_VALUE) // 如果没有找到或查找失败 + return FALSE; + + do + { + if (wfd.cFileName[0] != '.') + { + if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) + { + char strDirectory[MAX_PATH]; + wsprintf(strDirectory, "%s\\%s", lpszDirectory, wfd.cFileName); + DeleteDirectory(strDirectory); + } + else + { + char strFile[MAX_PATH]; + wsprintf(strFile, "%s\\%s", lpszDirectory, wfd.cFileName); + DeleteFile(strFile); + } + } + } while (FindNextFile(hFind, &wfd)); + + FindClose(hFind); // 关闭查找句柄 + + if (!RemoveDirectory(lpszDirectory)) + { + return FALSE; + } + return true; +} + +void CFileManagerDlg::OnLocalNewfolder() +{ + if (m_Local_Path == "") + return; + // TODO: Add your command handler code here + + CInputDialog dlg; + dlg.Init(_T("新建目录"), _T("请输入目录名称:"), this); + + if (dlg.DoModal() == IDOK && dlg.m_str.GetLength()) + { + // 创建多层目录 + MakeSureDirectoryPathExists(m_Local_Path + dlg.m_str + "\\"); + FixedLocalFileList("."); + } +} + +void CFileManagerDlg::OnRemoteNewfolder() +{ + if (m_Remote_Path == "") + return; + // TODO: Add your command handler code here + // TODO: Add your command handler code here + CInputDialog dlg; + dlg.Init(_T("新建目录"), _T("请输入目录名称:"), this); + + if (dlg.DoModal() == IDOK && dlg.m_str.GetLength()) + { + CString file = m_Remote_Path + dlg.m_str + "\\"; + UINT nPacketSize = file.GetLength() + 2; + // 创建多层目录 + LPBYTE lpBuffer = (LPBYTE)LocalAlloc(LPTR, file.GetLength() + 2); + lpBuffer[0] = COMMAND_CREATE_FOLDER; + memcpy(lpBuffer + 1, file.GetBuffer(0), nPacketSize - 1); + m_iocpServer->Send(m_pContext, lpBuffer, nPacketSize); + } +} + +void CFileManagerDlg::OnTransfer() +{ + // TODO: Add your command handler code here + POINT pt; + GetCursorPos(&pt); + if (GetFocus()->m_hWnd == m_list_local.m_hWnd) + { + OnLocalCopy(); + } + else + { + OnRemoteCopy(); //从远程传输到本地我们来分析一下啊转到 他的定义 + } +} + +void CFileManagerDlg::OnRename() +{ + // TODO: Add your command handler code here + POINT pt; + GetCursorPos(&pt); + if (GetFocus()->m_hWnd == m_list_local.m_hWnd) + { + m_list_local.EditLabel(m_list_local.GetSelectionMark()); + } + else + { + m_list_remote.EditLabel(m_list_remote.GetSelectionMark()); + } +} + +void CFileManagerDlg::OnEndlabeleditListLocal(NMHDR* pNMHDR, LRESULT* pResult) +{ + LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR; + // TODO: Add your control notification handler code here + + + CString str, strExistingFileName, strNewFileName; + m_list_local.GetEditControl()->GetWindowText(str); + + strExistingFileName = m_Local_Path + m_list_local.GetItemText(pDispInfo->item.iItem, 0); + strNewFileName = m_Local_Path + str; + *pResult = ::MoveFile(strExistingFileName.GetBuffer(0), strNewFileName.GetBuffer(0)); +} + +void CFileManagerDlg::OnEndlabeleditListRemote(NMHDR* pNMHDR, LRESULT* pResult) +{ + LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR; + // TODO: Add your control notification handler code here + CString str, strExistingFileName, strNewFileName; + m_list_remote.GetEditControl()->GetWindowText(str); + + strExistingFileName = m_Remote_Path + m_list_remote.GetItemText(pDispInfo->item.iItem, 0); + strNewFileName = m_Remote_Path + str; + + if (strExistingFileName != strNewFileName) + { + UINT nPacketSize = strExistingFileName.GetLength() + strNewFileName.GetLength() + 3; + LPBYTE lpBuffer = (LPBYTE)LocalAlloc(LPTR, nPacketSize); + lpBuffer[0] = COMMAND_RENAME_FILE; + memcpy(lpBuffer + 1, strExistingFileName.GetBuffer(0), strExistingFileName.GetLength() + 1); + memcpy(lpBuffer + 2 + strExistingFileName.GetLength(), + strNewFileName.GetBuffer(0), strNewFileName.GetLength() + 1); + m_iocpServer->Send(m_pContext, lpBuffer, nPacketSize); + LocalFree(lpBuffer); + } + *pResult = 1; +} + +void CFileManagerDlg::OnDelete() +{ + // TODO: Add your command handler code here + POINT pt; + GetCursorPos(&pt); + if (GetFocus()->m_hWnd == m_list_local.m_hWnd) + { + OnLocalDelete(); + } + else + { + OnRemoteDelete(); + } +} + +void CFileManagerDlg::OnNewfolder() +{ + // TODO: Add your command handler code here + POINT pt; + GetCursorPos(&pt); + if (GetFocus()->m_hWnd == m_list_local.m_hWnd) + { + OnLocalNewfolder(); + } + else + { + OnRemoteNewfolder(); + } +} + +void CFileManagerDlg::OnRefresh() +{ + // TODO: Add your command handler code here + POINT pt; + GetCursorPos(&pt); + if (GetFocus()->m_hWnd == m_list_local.m_hWnd) + { + FixedLocalFileList("."); + } + else + { + GetRemoteFileList("."); + } +} + +void CFileManagerDlg::OnLocalOpen() +{ + // TODO: Add your command handler code here + CString str; + str = m_Local_Path + m_list_local.GetItemText(m_list_local.GetSelectionMark(), 0); + ShellExecute(NULL, "open", str, NULL, NULL, SW_SHOW); +} + +void CFileManagerDlg::OnRemoteOpenShow() +{ + // TODO: Add your command handler code here + CString str; + str = m_Remote_Path + m_list_remote.GetItemText(m_list_remote.GetSelectionMark(), 0); + + int nPacketLength = str.GetLength() + 2; + BYTE lPacket[MAX_PATH + 10];// = (LPBYTE)LocalAlloc(LPTR, nPacketLength); + lPacket[0] = COMMAND_OPEN_FILE_SHOW; + memcpy(lPacket + 1, str.GetBuffer(0), nPacketLength - 1); + m_iocpServer->Send(m_pContext, lPacket, nPacketLength); + + //这里需要注释掉,不然会造成崩溃 + //delete [] lpPacket; +} + +void CFileManagerDlg::OnRemoteOpenHide() +{ + // TODO: Add your command handler code here + CString str; + str = m_Remote_Path + m_list_remote.GetItemText(m_list_remote.GetSelectionMark(), 0); + + int nPacketLength = str.GetLength() + 2; + BYTE lPacket[MAX_PATH + 10]; + lPacket[0] = COMMAND_OPEN_FILE_HIDE; + memcpy(lPacket + 1, str.GetBuffer(0), nPacketLength - 1); + m_iocpServer->Send(m_pContext, lPacket, nPacketLength); + + //这里需要注释掉,不然会造成崩溃 + //delete[] lpPacket; +} + +void CFileManagerDlg::OnRclickListLocal(NMHDR* pNMHDR, LRESULT* pResult) +{ + // TODO: Add your control notification handler code here + CListCtrl *pListCtrl = &m_list_local; + CMenu popup; + popup.LoadMenu(IDR_FILEMANAGER); + CMenu* pM = popup.GetSubMenu(0); + CPoint p; + GetCursorPos(&p); + pM->DeleteMenu(6, MF_BYPOSITION); + if (pListCtrl->GetSelectedCount() == 0) + { + int count = pM->GetMenuItemCount(); + for (int i = 0; i < count; i++) + { + pM->EnableMenuItem(i, MF_BYPOSITION | MF_GRAYED); + } + } + if (pListCtrl->GetSelectedCount() <= 1) + { + pM->EnableMenuItem(IDM_NEWFOLDER, MF_BYCOMMAND | MF_ENABLED); + } + if (pListCtrl->GetSelectedCount() == 1) + { + // 是文件夹 + if (pListCtrl->GetItemData(pListCtrl->GetSelectionMark()) == 1) + pM->EnableMenuItem(IDM_LOCAL_OPEN, MF_BYCOMMAND | MF_GRAYED); + else + pM->EnableMenuItem(IDM_LOCAL_OPEN, MF_BYCOMMAND | MF_ENABLED); + } + else + pM->EnableMenuItem(IDM_LOCAL_OPEN, MF_BYCOMMAND | MF_GRAYED); + + + pM->EnableMenuItem(IDM_REFRESH, MF_BYCOMMAND | MF_ENABLED); + pM->TrackPopupMenu(TPM_LEFTALIGN, p.x, p.y, this); + *pResult = 0; +} + +void CFileManagerDlg::OnRclickListRemote(NMHDR* pNMHDR, LRESULT* pResult) +{ + // TODO: Add your control notification handler code here + int nRemoteOpenMenuIndex = 5; + CListCtrl *pListCtrl = &m_list_remote; + CMenu popup; + popup.LoadMenu(IDR_FILEMANAGER); + CMenu* pM = popup.GetSubMenu(0); + CPoint p; + GetCursorPos(&p); + pM->DeleteMenu(IDM_LOCAL_OPEN, MF_BYCOMMAND); + if (pListCtrl->GetSelectedCount() == 0) + { + int count = pM->GetMenuItemCount(); + for (int i = 0; i < count; i++) + { + pM->EnableMenuItem(i, MF_BYPOSITION | MF_GRAYED); + } + } + if (pListCtrl->GetSelectedCount() <= 1) + { + pM->EnableMenuItem(IDM_NEWFOLDER, MF_BYCOMMAND | MF_ENABLED); + } + if (pListCtrl->GetSelectedCount() == 1) + { + // 是文件夹 + if (pListCtrl->GetItemData(pListCtrl->GetSelectionMark()) == 1) + pM->EnableMenuItem(nRemoteOpenMenuIndex, MF_BYPOSITION | MF_GRAYED); + else + pM->EnableMenuItem(nRemoteOpenMenuIndex, MF_BYPOSITION | MF_ENABLED); + } + else + pM->EnableMenuItem(nRemoteOpenMenuIndex, MF_BYPOSITION | MF_GRAYED); + + + pM->EnableMenuItem(IDM_REFRESH, MF_BYCOMMAND | MF_ENABLED); + pM->TrackPopupMenu(TPM_LEFTALIGN, p.x, p.y, this); + *pResult = 0; +} + +bool CFileManagerDlg::MakeSureDirectoryPathExists(LPCTSTR pszDirPath) +{ + LPTSTR p, pszDirCopy; + DWORD dwAttributes; + + // Make a copy of the string for editing. + + __try + { + pszDirCopy = (LPTSTR)malloc(sizeof(TCHAR) * (lstrlen(pszDirPath) + 1)); + + if (pszDirCopy == NULL) + return FALSE; + + lstrcpy(pszDirCopy, pszDirPath); + + p = pszDirCopy; + + // If the second character in the path is "\", then this is a UNC + // path, and we should skip forward until we reach the 2nd \ in the path. + + if ((*p == TEXT('\\')) && (*(p + 1) == TEXT('\\'))) + { + p++; // Skip over the first \ in the name. + p++; // Skip over the second \ in the name. + + // Skip until we hit the first "\" (\\Server\). + + while (*p && *p != TEXT('\\')) + { + p = CharNext(p); + } + + // Advance over it. + + if (*p) + { + p++; + } + + // Skip until we hit the second "\" (\\Server\Share\). + + while (*p && *p != TEXT('\\')) + { + p = CharNext(p); + } + + // Advance over it also. + + if (*p) + { + p++; + } + + } + else if (*(p + 1) == TEXT(':')) // Not a UNC. See if it's : + { + p++; + p++; + + // If it exists, skip over the root specifier + + if (*p && (*p == TEXT('\\'))) + { + p++; + } + } + + while (*p) + { + if (*p == TEXT('\\')) + { + *p = TEXT('\0'); + dwAttributes = GetFileAttributes(pszDirCopy); + + // Nothing exists with this name. Try to make the directory name and error if unable to. + if (dwAttributes == 0xffffffff) + { + if (!CreateDirectory(pszDirCopy, NULL)) + { + if (GetLastError() != ERROR_ALREADY_EXISTS) + { + free(pszDirCopy); + return FALSE; + } + } + } + else + { + if ((dwAttributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY) + { + // Something exists with this name, but it's not a directory... Error + free(pszDirCopy); + return FALSE; + } + } + + *p = TEXT('\\'); + } + + p = CharNext(p); + } + } + __except (EXCEPTION_EXECUTE_HANDLER) + { + // SetLastError(GetExceptionCode()); + free(pszDirCopy); + return FALSE; + } + + free(pszDirCopy); + return TRUE; +} diff --git a/CcRemote/CcRemote/CFileManagerDlg.h b/CcRemote/CcRemote/CFileManagerDlg.h new file mode 100644 index 0000000..90f2643 --- /dev/null +++ b/CcRemote/CcRemote/CFileManagerDlg.h @@ -0,0 +1,156 @@ +#pragma once +#include "TrueColorToolBar.h" +#include "include/IOCPServer.h" +#include "resource.h" + + +typedef CList strList; +// CFileManagerDlg 对话框 + +class CFileManagerDlg : public CDialog +{ + DECLARE_DYNAMIC(CFileManagerDlg) + +public: + CFileManagerDlg(CWnd* pParent = NULL, CIOCPServer* pIOCPServer = NULL, ClientContext *pContext = NULL); // 标准构造函数 + virtual ~CFileManagerDlg(); + bool m_bIsStop; + CString m_strReceiveLocalFile; + CString m_strUploadRemoteFile; + void ShowProgress(); + void SendStop(); + int m_nTransferMode; + CString m_hCopyDestFolder; + void SendContinue(); + void SendException(); + void EndLocalRecvFile(); + void EndRemoteDeleteFile(); + CString m_strOperatingFile; // 文件名 + __int64 m_nOperatingFileLength; // 文件总大小 + __int64 m_nCounter;// 计数器 + void WriteLocalRecvFile(); + void CreateLocalRecvFile(); + BOOL SendDownloadJob(); + BOOL SendUploadJob(); + BOOL SendDeleteJob(); + + strList m_Remote_Download_Job; + strList m_Remote_Upload_Job; + strList m_Remote_Delete_Job; + CTrueColorToolBar m_wndToolBar_Local; + CTrueColorToolBar m_wndToolBar_Remote; + void ShowMessage(char *lpFmt, ...); + CString m_Remote_Path; + BYTE m_bRemoteDriveList[1024]; + CString GetParentDirectory(CString strPath); + void OnReceiveComplete(); + + CImageList* m_pImageList_Large; + CImageList* m_pImageList_Small; + + int m_nNewIconBaseIndex; // 新加的ICON + + ClientContext* m_pContext; + CIOCPServer* m_iocpServer; + CString m_IPAddress; + + CProgressCtrl* m_ProgressCtrl; + HCURSOR m_hCursor; + CString m_Local_Path; + bool FixedUploadDirectory(LPCTSTR lpPathName); + void FixedLocalDriveList(); + void FixedRemoteDriveList(); + void FixedLocalFileList(CString directory = ""); + void GetRemoteFileList(CString directory = ""); + void FixedRemoteFileList(BYTE *pbBuffer, DWORD dwBufferLen); + + HICON m_hIcon; + CStatusBar m_wndStatusBar; + + CComboBox m_Remote_Directory_ComboBox; + CComboBox m_Local_Directory_ComboBox; + CListCtrl m_list_remote; + CListCtrl m_list_local; +// 对话框数据 +#ifdef AFX_DESIGN_TIME + enum { IDD = IDD_FILE }; +#endif + virtual BOOL PreTranslateMessage(MSG* pMsg); +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 + virtual void PostNcDestroy(); + virtual BOOL OnInitDialog(); + afx_msg HCURSOR OnQueryDragIcon(); + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg void OnDblclkListLocal(NMHDR* pNMHDR, LRESULT* pResult); + afx_msg void OnBegindragListLocal(NMHDR* pNMHDR, LRESULT* pResult); + afx_msg void OnBegindragListRemote(NMHDR* pNMHDR, LRESULT* pResult); + afx_msg BOOL OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESULT* pResult); + afx_msg void OnMouseMove(UINT nFlags, CPoint point); + afx_msg void OnLButtonUp(UINT nFlags, CPoint point); + afx_msg void OnTimer(UINT nIDEvent); + afx_msg void OnClose(); + afx_msg void OnDblclkListRemote(NMHDR* pNMHDR, LRESULT* pResult); + afx_msg void OnLocalPrev(); + afx_msg void OnRemotePrev(); + afx_msg void OnLocalView(); + afx_msg void OnLocalList(); + afx_msg void OnLocalReport(); + afx_msg void OnLocalBigicon(); + afx_msg void OnLocalSmallicon(); + afx_msg void OnRemoteBigicon(); + afx_msg void OnRemoteList(); + afx_msg void OnRemoteReport(); + afx_msg void OnRemoteSmallicon(); + afx_msg void OnRemoteView(); + afx_msg void OnUpdateLocalStop(CCmdUI* pCmdUI); + afx_msg void OnUpdateRemoteStop(CCmdUI* pCmdUI); + afx_msg void OnUpdateLocalPrev(CCmdUI* pCmdUI); + afx_msg void OnUpdateRemotePrev(CCmdUI* pCmdUI); + afx_msg void OnUpdateLocalCopy(CCmdUI* pCmdUI); + afx_msg void OnUpdateRemoteCopy(CCmdUI* pCmdUI); + afx_msg void OnUpdateRemoteDelete(CCmdUI* pCmdUI); + afx_msg void OnUpdateRemoteNewfolder(CCmdUI* pCmdUI); + afx_msg void OnUpdateLocalDelete(CCmdUI* pCmdUI); + afx_msg void OnUpdateLocalNewfolder(CCmdUI* pCmdUI); + afx_msg void OnRemoteCopy(); + afx_msg void OnLocalCopy(); + afx_msg void OnLocalDelete(); + afx_msg void OnRemoteDelete(); + afx_msg void OnRemoteStop(); + afx_msg void OnLocalStop(); + afx_msg void OnLocalNewfolder(); + afx_msg void OnRemoteNewfolder(); + afx_msg void OnTransfer(); + afx_msg void OnRename(); + afx_msg void OnEndlabeleditListLocal(NMHDR* pNMHDR, LRESULT* pResult); + afx_msg void OnEndlabeleditListRemote(NMHDR* pNMHDR, LRESULT* pResult); + afx_msg void OnDelete(); + afx_msg void OnNewfolder(); + afx_msg void OnRefresh(); + afx_msg void OnLocalOpen(); + afx_msg void OnRemoteOpenShow(); + afx_msg void OnRemoteOpenHide(); + afx_msg void OnRclickListLocal(NMHDR* pNMHDR, LRESULT* pResult); + afx_msg void OnRclickListRemote(NMHDR* pNMHDR, LRESULT* pResult); + DECLARE_MESSAGE_MAP() + + +protected: + CListCtrl* m_pDragList; //Which ListCtrl we are dragging FROM + CListCtrl* m_pDropList; //Which ListCtrl we are dropping ON + BOOL m_bDragging; //T during a drag operation + int m_nDragIndex; //Index of selected item in the List we are dragging FROM + int m_nDropIndex; //Index at which to drop item in the List we are dropping ON + CWnd* m_pDropWnd; //Pointer to window we are dropping on (will be cast to CListCtrl* type) + + void DropItemOnList(CListCtrl* pDragList, CListCtrl* pDropList); +private: + bool m_bIsUpload; // 是否是把本地主机传到远程上,标志方向位 + bool MakeSureDirectoryPathExists(LPCTSTR pszDirPath); + void SendTransferMode(); + void SendFileData(); + void EndLocalUploadFile(); + bool DeleteDirectory(LPCTSTR lpszDirectory); + void EnableControl(BOOL bEnable = TRUE); +}; diff --git a/CcRemote/CcRemote/CcRemote.rc b/CcRemote/CcRemote/CcRemote.rc index 5f95181..3b7f2cc 100644 Binary files a/CcRemote/CcRemote/CcRemote.rc and b/CcRemote/CcRemote/CcRemote.rc differ diff --git a/CcRemote/CcRemote/CcRemote.vcxproj b/CcRemote/CcRemote/CcRemote.vcxproj index 091c162..9f89f74 100644 --- a/CcRemote/CcRemote/CcRemote.vcxproj +++ b/CcRemote/CcRemote/CcRemote.vcxproj @@ -205,6 +205,8 @@ + + @@ -215,6 +217,7 @@ + @@ -225,6 +228,8 @@ + + @@ -244,6 +249,7 @@ Use Use + Create Create @@ -257,15 +263,23 @@ + + + + + + + + diff --git a/CcRemote/CcRemote/CcRemote.vcxproj.filters b/CcRemote/CcRemote/CcRemote.vcxproj.filters index a424807..f5f9489 100644 --- a/CcRemote/CcRemote/CcRemote.vcxproj.filters +++ b/CcRemote/CcRemote/CcRemote.vcxproj.filters @@ -78,6 +78,15 @@ 头文件 + + 头文件 + + + 头文件 + + + 源文件 + @@ -119,6 +128,15 @@ 源文件 + + 源文件 + + + 源文件 + + + 源文件 + @@ -132,6 +150,18 @@ 资源文件 + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + @@ -152,5 +182,17 @@ 资源文件 + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + \ No newline at end of file diff --git a/CcRemote/CcRemote/CcRemoteDlg.cpp b/CcRemote/CcRemote/CcRemoteDlg.cpp index c9582ef..2ba3043 100644 --- a/CcRemote/CcRemote/CcRemoteDlg.cpp +++ b/CcRemote/CcRemote/CcRemoteDlg.cpp @@ -84,8 +84,8 @@ BEGIN_MESSAGE_MAP(CCcRemoteDlg, CDialogEx) ON_MESSAGE(WM_OPENSHELLDIALOG, OnOpenShellDialog) ON_MESSAGE(WM_OPENPSLISTDIALOG, OnOpenSystemDialog) ON_MESSAGE(WM_OPENSCREENSPYDIALOG, OnOpenScreenSpyDialog) + ON_MESSAGE(WM_OPENMANAGERDIALOG, OnOpenManagerDialog) - //-------------系统------------- ON_WM_SYSCOMMAND() ON_WM_PAINT() @@ -294,6 +294,8 @@ void CCcRemoteDlg::OnSize(UINT nType, int cx, int cy) if (SIZE_MINIMIZED == nType)//当窗口最小化避免大小为0造成崩溃直接返回 return; + + if (m_CList_Online.m_hWnd != NULL) { CRect rc; @@ -310,6 +312,12 @@ void CCcRemoteDlg::OnSize(UINT nType, int cx, int cy) int lenth = dd; //转换为int 类型 m_CList_Online.SetColumnWidth(i, (lenth)); //设置当前的宽度 } + //TCHAR szBuffer[_MAX_PATH]; + //VERIFY(::GetModuleFileName(AfxGetInstanceHandle(), szBuffer, _MAX_PATH)); + //CString sPath = (CString)szBuffer; sPath = sPath.Left(sPath.ReverseFind('\\') + 1); + CString sPath = "F:\\myapp\\CcRemote\\CcRemote\\CcRemote\\res\\background_list_online.bmp"; + m_CList_Online.SetBkImage(sPath.GetBuffer(sPath.GetLength()), TRUE); // 定义:CListCtrl m_controllist1; + sPath.ReleaseBuffer(); } if (m_CList_Message.m_hWnd != NULL) { @@ -327,6 +335,9 @@ void CCcRemoteDlg::OnSize(UINT nType, int cx, int cy) int lenth = dd; //转换为int 类型 m_CList_Message.SetColumnWidth(i, (lenth)); //设置当前的宽度 } + CString sPath = "F:\\myapp\\CcRemote\\CcRemote\\CcRemote\\res\\background_list_online.bmp"; + m_CList_Message.SetBkImage(sPath.GetBuffer(sPath.GetLength()), TRUE); // 定义:CListCtrl m_controllist1; + sPath.ReleaseBuffer(); } if (m_wndStatusBar.m_hWnd != NULL) { //当对话框大小改变时 状态条大小也随之改变 @@ -375,15 +386,15 @@ int CCcRemoteDlg::InitMyMenu() int CCcRemoteDlg::InitList() { - //m_CList_Online.SetTextBkColor(CLR_NONE); - //m_CList_Online.SetBkColor(CLR_NONE); - //m_CList_Online.SetTextColor(RGB(255, 0, 0)); - //TCHAR szBuffer[_MAX_PATH]; - //VERIFY(::GetModuleFileName(AfxGetInstanceHandle(), szBuffer, _MAX_PATH)); - ////CString sPath = (CString)szBuffer; sPath = sPath.Left(sPath.ReverseFind('\\') + 1); - //CString sPath = "F:\myapp\\CcRemote\\CcRemote\\CcRemote\\background_picture.bmp"; - //m_CList_Online.SetBkImage(sPath.GetBuffer(sPath.GetLength()), TRUE); // 定义:CListCtrl m_controllist1; - //sPath.ReleaseBuffer(); + + // CLR_NONE没有背景色。图像是透明的。 + m_CList_Online.SetTextBkColor(CLR_NONE); + m_CList_Online.SetBkColor(CLR_NONE); + m_CList_Online.SetTextColor(RGB(255, 0, 0)); + + m_CList_Message.SetTextBkColor(CLR_NONE); + m_CList_Message.SetBkColor(CLR_NONE); + //m_CList_Message.SetTextColor(RGB(255, 0, 0)); //设置list可选中 m_CList_Online.SetExtendedStyle(LVS_EX_FULLROWSELECT); @@ -451,12 +462,13 @@ void CCcRemoteDlg::ShowMessage(bool bIsOK, CString strMsg) m_OnlineCount = (m_OnlineCount <= 0 ? 0 : m_OnlineCount); //防止iCount 有-1的情况 strStatusMsg.Format("已连接: %d", m_OnlineCount); m_wndStatusBar.SetPaneText(0, strStatusMsg); //在状态条上显示文字 - + } void CCcRemoteDlg::Test() { + ShowMessage(true, "软件初始化成功..."); //AddList("192.168.0.1", "本机局域网", "CHANG", "Windows7", "2.2GHZ", "有", "123232"); //AddList("192.168.10.1", "本机局域网", "WANG", "Windows10", "2.2GHZ", "无", "111111"); @@ -520,6 +532,8 @@ void CCcRemoteDlg::OnOnlineDesktop() void CCcRemoteDlg::OnOnlineFile() { // TODO: 在此添加命令处理程序代码 + BYTE bToken = COMMAND_LIST_DRIVE; //在服务端中搜索COMMAND_LIST_DRIVE + SendSelectCommand(&bToken, sizeof(BYTE)); } @@ -709,6 +723,8 @@ void CCcRemoteDlg::OnClose() { // TODO: 在此添加消息处理程序代码和/或调用默认值 Shell_NotifyIcon(NIM_DELETE, &nid); //销毁图标 + m_CList_Message.SetBkImage("relese", TRUE); + m_CList_Online.SetBkImage("relese", TRUE); CDialogEx::OnClose(); } @@ -766,9 +782,9 @@ void CCcRemoteDlg::ProcessReceiveComplete(ClientContext *pContext) { switch (pContext->m_Dialog[0]) { - //case FILEMANAGER_DLG: - // ((CFileManagerDlg *)dlg)->OnReceiveComplete(); - // break; + case FILEMANAGER_DLG: + ((CFileManagerDlg *)dlg)->OnReceiveComplete(); + break; case SCREENSPY_DLG: ((CScreenSpyDlg *)dlg)->OnReceiveComplete(); break; @@ -824,11 +840,7 @@ void CCcRemoteDlg::ProcessReceiveComplete(ClientContext *pContext) } break; - /*case TOKEN_DRIVE_LIST: // 驱动器列表 - // 指接调用public函数非模态对话框会失去反应, 不知道怎么回事,太菜 - g_pCcRemoteDlg->PostMessage(WM_OPENMANAGERDIALOG, 0, (LPARAM)pContext); - break; - + /* case TOKEN_WEBCAM_BITMAPINFO: // 摄像头 g_pCcRemoteDlg->PostMessage(WM_OPENWEBCAMDIALOG, 0, (LPARAM)pContext); break; @@ -838,6 +850,10 @@ void CCcRemoteDlg::ProcessReceiveComplete(ClientContext *pContext) case TOKEN_KEYBOARD_START: g_pCcRemoteDlg->PostMessage(WM_OPENKEYBOARDDIALOG, 0, (LPARAM)pContext); break;*/ + case TOKEN_DRIVE_LIST: // 驱动器列表 + // 指接调用public函数非模态对话框会失去反应, 不知道怎么回事,太菜 + g_pCcRemoteDlg->PostMessage(WM_OPENMANAGERDIALOG, 0, (LPARAM)pContext); + break; case TOKEN_BITMAPINFO: // // 指接调用public函数非模态对话框会失去反应, 不知道怎么回事 g_pCcRemoteDlg->PostMessage(WM_OPENSCREENSPYDIALOG, 0, (LPARAM)pContext); @@ -1029,23 +1045,41 @@ LRESULT CCcRemoteDlg::OnOpenScreenSpyDialog(WPARAM wParam, LPARAM lParam) return 0; } +//打开文件管理窗口 +LRESULT CCcRemoteDlg::OnOpenManagerDialog(WPARAM wParam, LPARAM lParam) +{ + + ClientContext *pContext = (ClientContext *)lParam; + + //转到CFileManagerDlg 构造函数 + CFileManagerDlg *dlg = new CFileManagerDlg(this, m_iocpServer, pContext); + // 设置父窗口为桌面 + dlg->Create(IDD_FILE, GetDesktopWindow()); + dlg->ShowWindow(SW_SHOW); + + pContext->m_Dialog[0] = FILEMANAGER_DLG; + pContext->m_Dialog[1] = (int)dlg; + + return 0; +} //绘制背景图片 BOOL CCcRemoteDlg::OnEraseBkgnd(CDC* pDC) { // TODO: 在此添加消息处理程序代码和/或调用默认值 - CDC MemDC; MemDC.CreateCompatibleDC(pDC); - CBitmap Cbp; - Cbp.LoadBitmap(IDB_BACKGROUND_CCREMOTE); - MemDC.SelectObject(&Cbp); - BITMAP Bp; - Cbp.GetBitmap(&Bp); - CRect rect; - GetClientRect(&rect); - pDC->StretchBlt(0, 0, rect.Width(), rect.Height(), &MemDC, 0, 0, Bp.bmWidth, Bp.bmHeight, SRCCOPY); - MemDC.DeleteDC(); + //CDC MemDC; MemDC.CreateCompatibleDC(pDC); + //CBitmap Cbp; + //Cbp.LoadBitmap(IDB_BACKGROUND_CCREMOTE); + //MemDC.SelectObject(&Cbp); + //BITMAP Bp; + //Cbp.GetBitmap(&Bp); + //CRect rect; + //GetClientRect(&rect); + //pDC->StretchBlt(0, 0, rect.Width(), rect.Height(), &MemDC, 0, 0, Bp.bmWidth, Bp.bmHeight, SRCCOPY); + //MemDC.DeleteDC(); + return TRUE; - //return CDialogEx::OnEraseBkgnd(pDC); + return CDialogEx::OnEraseBkgnd(pDC); } diff --git a/CcRemote/CcRemote/CcRemoteDlg.h b/CcRemote/CcRemote/CcRemoteDlg.h index f8f0682..1c1d74a 100644 --- a/CcRemote/CcRemote/CcRemoteDlg.h +++ b/CcRemote/CcRemote/CcRemoteDlg.h @@ -8,6 +8,7 @@ #include "CShellDlg.h" #include "CSystemDlg.h" #include "CScreenSpyDlg.h" +#include "CFileManagerDlg.h" #pragma once @@ -101,6 +102,7 @@ public: afx_msg LRESULT OnOpenShellDialog(WPARAM, LPARAM); afx_msg LRESULT OnOpenSystemDialog(WPARAM, LPARAM); afx_msg LRESULT OnOpenScreenSpyDialog(WPARAM, LPARAM); + afx_msg LRESULT OnOpenManagerDialog(WPARAM, LPARAM); //-------------系统消息处理------------- afx_msg void OnNMRClickOnline(NMHDR *pNMHDR, LRESULT *pResult); diff --git a/CcRemote/CcRemote/Debug/CcRemote.Build.CppClean.log b/CcRemote/CcRemote/Debug/CcRemote.Build.CppClean.log index 3dc0e77..671f96f 100644 --- a/CcRemote/CcRemote/Debug/CcRemote.Build.CppClean.log +++ b/CcRemote/CcRemote/Debug/CcRemote.Build.CppClean.log @@ -10,21 +10,7 @@ f:\myapp\ccremote\ccremote\ccremote\debug\csystemdlg.obj f:\myapp\ccremote\ccremote\ccremote\debug\cshelldlg.obj f:\myapp\ccremote\ccremote\ccremote\debug\csettingdlg.obj f:\myapp\ccremote\ccremote\ccremote\debug\cscreenspydlg.obj -f:\myapp\ccremote\ccremote\ccremote\debug\ccremotedlg.obj -f:\myapp\ccremote\ccremote\ccremote\debug\ccremote.obj -f:\myapp\ccremote\ccremote\ccremote\debug\iocpserver.obj -f:\myapp\ccremote\ccremote\ccremote\debug\buffer.obj -f:\myapp\ccremote\bin\ccremote.ilk -f:\myapp\ccremote\bin\ccremote.exe -f:\myapp\ccremote\bin\ccremote.pdb -f:\myapp\ccremote\ccremote\ccremote\debug\ccremote.res -f:\myapp\ccremote\ccremote\ccremote\..\..\bin\ccremote.exe +f:\myapp\ccremote\ccremote\ccremote\debug\filetransfermodedlg.obj f:\myapp\ccremote\ccremote\ccremote\debug\ccremote.tlog\cl.command.1.tlog f:\myapp\ccremote\ccremote\ccremote\debug\ccremote.tlog\cl.read.1.tlog f:\myapp\ccremote\ccremote\ccremote\debug\ccremote.tlog\cl.write.1.tlog -f:\myapp\ccremote\ccremote\ccremote\debug\ccremote.tlog\link.command.1.tlog -f:\myapp\ccremote\ccremote\ccremote\debug\ccremote.tlog\link.read.1.tlog -f:\myapp\ccremote\ccremote\ccremote\debug\ccremote.tlog\link.write.1.tlog -f:\myapp\ccremote\ccremote\ccremote\debug\ccremote.tlog\rc.command.1.tlog -f:\myapp\ccremote\ccremote\ccremote\debug\ccremote.tlog\rc.read.1.tlog -f:\myapp\ccremote\ccremote\ccremote\debug\ccremote.tlog\rc.write.1.tlog diff --git a/CcRemote/CcRemote/Debug/CcRemote.log b/CcRemote/CcRemote/Debug/CcRemote.log index ff9d65e..1de6781 100644 --- a/CcRemote/CcRemote/Debug/CcRemote.log +++ b/CcRemote/CcRemote/Debug/CcRemote.log @@ -1,45 +1,2 @@ C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.CppBuild.targets(377,5): warning MSB8004: Output 目录未以斜杠结尾。 此生成实例将添加斜杠,因为必须有这个斜杠才能正确计算 Output 目录。 - pch.cpp - CcRemote.cpp - CcRemoteDlg.cpp -f:\myapp\ccremote\ccremote\ccremote\ccremotedlg.cpp(164): warning C4996: 'gethostbyname': Use getaddrinfo() or GetAddrInfoW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings - d:\windows kits\10\include\10.0.17763.0\um\winsock2.h(2219): note: 参见“gethostbyname”的声明 -f:\myapp\ccremote\ccremote\ccremote\ccremotedlg.cpp(169): warning C4996: 'inet_ntoa': Use inet_ntop() or InetNtop() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings - d:\windows kits\10\include\10.0.17763.0\um\winsock2.h(1849): note: 参见“inet_ntoa”的声明 -f:\myapp\ccremote\ccremote\ccremote\ccremotedlg.cpp(310): warning C4244: “初始化”: 从“double”转换到“int”,可能丢失数据 -f:\myapp\ccremote\ccremote\ccremote\ccremotedlg.cpp(327): warning C4244: “初始化”: 从“double”转换到“int”,可能丢失数据 -f:\myapp\ccremote\ccremote\ccremote\ccremotedlg.cpp(812): warning C4018: “<=”: 有符号/无符号不匹配 -f:\myapp\ccremote\ccremote\ccremote\ccremotedlg.cpp(894): warning C4996: 'inet_ntoa': Use inet_ntop() or InetNtop() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings - d:\windows kits\10\include\10.0.17763.0\um\winsock2.h(1849): note: 参见“inet_ntoa”的声明 - CScreenSpyDlg.cpp -f:\myapp\ccremote\ccremote\ccremote\cscreenspydlg.cpp(54): warning C4996: 'inet_ntoa': Use inet_ntop() or InetNtop() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings - d:\windows kits\10\include\10.0.17763.0\um\winsock2.h(1849): note: 参见“inet_ntoa”的声明 -f:\myapp\ccremote\ccremote\ccremote\cscreenspydlg.cpp(607): warning C4554: “<<”: 检查运算符优先级是否存在的可能的错误;使用括号阐明优先级 -f:\myapp\ccremote\ccremote\ccremote\cscreenspydlg.cpp(621): warning C4554: “<<”: 检查运算符优先级是否存在的可能的错误;使用括号阐明优先级 - CSettingDlg.cpp - CShellDlg.cpp -f:\myapp\ccremote\ccremote\ccremote\cshelldlg.cpp(95): warning C4996: 'inet_ntoa': Use inet_ntop() or InetNtop() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings - d:\windows kits\10\include\10.0.17763.0\um\winsock2.h(1849): note: 参见“inet_ntoa”的声明 -f:\myapp\ccremote\ccremote\ccremote\cshelldlg.cpp(122): warning C4018: “<”: 有符号/无符号不匹配 -f:\myapp\ccremote\ccremote\ccremote\cshelldlg.cpp(208): warning C4018: “<=”: 有符号/无符号不匹配 -f:\myapp\ccremote\ccremote\ccremote\cshelldlg.cpp(218): warning C4018: “<”: 有符号/无符号不匹配 - CSystemDlg.cpp -f:\myapp\ccremote\ccremote\ccremote\csystemdlg.cpp(114): warning C4996: 'inet_ntoa': Use inet_ntop() or InetNtop() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings - d:\windows kits\10\include\10.0.17763.0\um\winsock2.h(1849): note: 参见“inet_ntoa”的声明 - CpuUsage.cpp - IniFile.cpp -f:\myapp\ccremote\ccremote\ccremote\inifile.cpp(33): warning C4996: 'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. - d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(90): note: 参见“strcat”的声明 - SEU_QQwry.cpp - TrueColorToolBar.cpp - 正在生成代码... - Buffer.cpp - IOCPServer.cpp -f:\myapp\ccremote\ccremote\ccremote\include\iocpserver.cpp(133): warning C4996: 'WSASocketA': Use WSASocketW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings - d:\windows kits\10\include\10.0.17763.0\um\winsock2.h(3416): note: 参见“WSASocketA”的声明 -f:\myapp\ccremote\ccremote\ccremote\include\iocpserver.cpp(725): warning C4996: 'inet_ntoa': Use inet_ntop() or InetNtop() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings - d:\windows kits\10\include\10.0.17763.0\um\winsock2.h(1849): note: 参见“inet_ntoa”的声明 -f:\myapp\ccremote\ccremote\ccremote\include\iocpserver.cpp(774): warning C4244: “初始化”: 从“double”转换到“unsigned long”,可能丢失数据 -f:\myapp\ccremote\ccremote\ccremote\include\iocpserver.cpp(920): warning C4018: “>=”: 有符号/无符号不匹配 - 正在生成代码... CcRemote.vcxproj -> F:\myapp\CcRemote\CcRemote\CcRemote\..\..\bin\CcRemote.exe diff --git a/CcRemote/CcRemote/Debug/CcRemote.res b/CcRemote/CcRemote/Debug/CcRemote.res index 5a512f0..1688125 100644 Binary files a/CcRemote/CcRemote/Debug/CcRemote.res and b/CcRemote/CcRemote/Debug/CcRemote.res differ diff --git a/CcRemote/CcRemote/Debug/cfilemanagerdlg.obj.enc b/CcRemote/CcRemote/Debug/cfilemanagerdlg.obj.enc new file mode 100644 index 0000000..8c57a5f Binary files /dev/null and b/CcRemote/CcRemote/Debug/cfilemanagerdlg.obj.enc differ diff --git a/CcRemote/CcRemote/FileTransferModeDlg.cpp b/CcRemote/CcRemote/FileTransferModeDlg.cpp new file mode 100644 index 0000000..d047823 --- /dev/null +++ b/CcRemote/CcRemote/FileTransferModeDlg.cpp @@ -0,0 +1,63 @@ +// CInputDlg.cpp: 实现文件 +// + +#include "pch.h" +#include "CcRemote.h" +#include "FileTransferModeDlg.h" +#include "afxdialogex.h" + + +// CFileTransferModeDlg 对话框 + +IMPLEMENT_DYNAMIC(CFileTransferModeDlg, CDialog) + +CFileTransferModeDlg::CFileTransferModeDlg(CWnd* pParent /*=nullptr*/) + : CDialog(IDD_TRANSFERMODE_DLG, pParent) +{ + +} + +CFileTransferModeDlg::~CFileTransferModeDlg() +{ +} + +void CFileTransferModeDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); +} + + +BEGIN_MESSAGE_MAP(CFileTransferModeDlg, CDialog) + ON_CONTROL_RANGE(BN_CLICKED, IDC_OVERWRITE, IDC_CANCEL, OnEndDialog) +END_MESSAGE_MAP() + + +// CFileTransferModeDlg 消息处理程序 + + +BOOL CFileTransferModeDlg::OnInitDialog() +{ + CDialog::OnInitDialog(); + + // TODO: 在此添加额外的初始化 + CString str; + str.Format("此文件夹已包含一个名为“%s”的文件", m_strFileName); + + for (int i = 0; i < str.GetLength(); i += 120) + { + str.Insert(i, "\n"); + i += 1; + } + + SetDlgItemText(IDC_TIPS, str); + return TRUE; // return TRUE unless you set the focus to a control + // 异常: OCX 属性页应返回 FALSE +} + + +//重写这个函数是因为让继承他的子类能够重载这个函数来判断id吧 +void CFileTransferModeDlg::OnEndDialog(UINT id) +{ + // TODO: Add your control notification handler code here + EndDialog(id); +} \ No newline at end of file diff --git a/CcRemote/CcRemote/FileTransferModeDlg.h b/CcRemote/CcRemote/FileTransferModeDlg.h new file mode 100644 index 0000000..f5f9e62 --- /dev/null +++ b/CcRemote/CcRemote/FileTransferModeDlg.h @@ -0,0 +1,27 @@ +#pragma once + +#include "resource.h" +// CFileTransferModeDlg 对话框 + +class CFileTransferModeDlg : public CDialog +{ + DECLARE_DYNAMIC(CFileTransferModeDlg) + +public: + CString m_strFileName; + CFileTransferModeDlg(CWnd* pParent = nullptr); // 标准构造函数 + virtual ~CFileTransferModeDlg(); + +// 对话框数据 +#ifdef AFX_DESIGN_TIME + enum { IDD = IDD_TRANSFERMODE_DLG }; +#endif + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 + afx_msg void OnEndDialog(UINT id); + virtual BOOL OnInitDialog(); + DECLARE_MESSAGE_MAP() +public: + +}; diff --git a/CcRemote/CcRemote/InputDlg.cpp b/CcRemote/CcRemote/InputDlg.cpp new file mode 100644 index 0000000..44d96e4 --- /dev/null +++ b/CcRemote/CcRemote/InputDlg.cpp @@ -0,0 +1,228 @@ +//////////////////////////////////////////////////////////////// +// MSDN Magazine -- June 2005 +// If this code works, it was written by Paul DiLascia. +// If not, I don't know who wrote it. +// Compiles with Visual Studio .NET 2003 (V7.1) on Windows XP. Tab size=3. +// +#include "pch.h" +#include "InputDlg.h" +#include "PublicStruct.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +////////////////// +// Note: Make sure nBufLen is big enough to hold your entire dialog template! +// +CDlgTemplateBuilder::CDlgTemplateBuilder(UINT nBufLen) +{ + m_pBuffer = new WORD[nBufLen]; + m_pNext = m_pBuffer; + m_pEndBuf = m_pNext + nBufLen; +} + +CDlgTemplateBuilder::~CDlgTemplateBuilder() +{ + delete [] m_pBuffer; +} + +////////////////// +// Create template (DLGTEMPLATE) +// +DLGTEMPLATE* CDlgTemplateBuilder::Begin(DWORD dwStyle, const CRect& rc, + LPCTSTR text, DWORD dwStyleEx) +{ + ASSERT(m_pBuffer==m_pNext); // call Begin first and only once! + + DLGTEMPLATE* hdr = (DLGTEMPLATE*)m_pBuffer; + hdr->style = dwStyle; // copy style.. + hdr->dwExtendedStyle = dwStyleEx; // ..and extended, too + hdr->cdit = 0; // number of items: zero + + // Set dialog rectangle. + CRect rcDlg = rc; + hdr->x = (short)rcDlg.left; + hdr->y = (short)rcDlg.top; + hdr->cx = (short)rcDlg.Width(); + hdr->cy = (short)rcDlg.Height(); + + // Append trailing items: menu, class, caption. I only use caption. + m_pNext = (WORD*)(hdr+1); + *m_pNext++ = 0; // menu (none) + *m_pNext++ = 0; // dialog class (use standard) + m_pNext = AddText(m_pNext, text); // append dialog caption + + ASSERT(m_pNext < m_pEndBuf); + return hdr; +} + +////////////////// +// Add dialog item (control). +// +void CDlgTemplateBuilder::AddItemTemplate(WORD wType, DWORD dwStyle, + const CRect& rc, WORD nID, DWORD dwStyleEx) +{ + ASSERT(m_pNext < m_pEndBuf); + + // initialize DLGITEMTEMPLATE + DLGITEMTEMPLATE& it = *((DLGITEMTEMPLATE*)AlignDWORD(m_pNext)); + it.style = dwStyle; + it.dwExtendedStyle = dwStyleEx; + + CRect rcDlg = rc; + it.x = (short)rcDlg.left; + it.y = (short)rcDlg.top; + it.cx = (short)rcDlg.Width(); + it.cy = (short)rcDlg.Height(); + it.id = nID; + + // add class (none) + m_pNext = (WORD*)(&it+1); + *m_pNext++ = 0xFFFF; // next WORD is atom + *m_pNext++ = wType; // ..atom identifier + ASSERT(m_pNext < m_pEndBuf); // check not out of range + + // increment control/item count + DLGTEMPLATE* hdr = (DLGTEMPLATE*)m_pBuffer; + hdr->cdit++; +} + +////////////////// +// Add dialog item (control). +// +void CDlgTemplateBuilder::AddItem(WORD wType, DWORD dwStyle, + const CRect& rc, LPCTSTR text, WORD nID, DWORD dwStyleEx) +{ + AddItemTemplate(wType, dwStyle, rc, nID, dwStyleEx); + m_pNext = AddText(m_pNext, text); // append title + *m_pNext++ = 0; // no creation data + ASSERT(m_pNext < m_pEndBuf); +} + +////////////////// +// Add dialog item (control). +// +void CDlgTemplateBuilder::AddItem(WORD wType, DWORD dwStyle, + const CRect& rc, WORD wResID, WORD nID, DWORD dwStyleEx) +{ + AddItemTemplate(wType, dwStyle, rc, nID, dwStyleEx); + *m_pNext++ = 0xFFFF; // next is resource id + *m_pNext++ = wResID; // ..here it is + *m_pNext++ = 0; // no extra stuff + ASSERT(m_pNext < m_pEndBuf); +} + +////////////////// +// Append text to buffer. Convert to Unicode if necessary. +// Return pointer to next character after terminating NULL. +// +WORD* CDlgTemplateBuilder::AddText(WORD* buf, LPCTSTR text) +{ + if (text) { + USES_CONVERSION; + wcscpy((WCHAR*)buf, T2W((LPTSTR)text)); + buf += wcslen((WCHAR*)buf)+1; + } else { + *buf++ = 0; + } + return buf; +} + +////////////////// +// Create string dialog. If no icon specified, use IDI_QUESTION. Note that +// the order in which the controls are added is the TAB order. +// +BOOL CInputDialog::Init(LPCTSTR caption, LPCTSTR prompt, CWnd* pParent, WORD nIDIcon) +{ + const int CXDIALOG = 200; // dialog width + const int DLGMARGIN = 7; // margins all around + const int CYSTATIC = 8; // height of static text + const int CYEDIT = 12; // height of edit control + const int CYSPACE = 5; // vertical space between controls + const int CXBUTTON = 40; // button width... + const int CYBUTTON = 15; // ..and height + + CDlgTemplateBuilder& dtb = m_dtb; + CRect rc( + CPoint(0,0), + CSize(CXDIALOG, CYSTATIC + CYEDIT + CYBUTTON + 2*DLGMARGIN + 2*CYSPACE)); + + // create dialog header + DLGTEMPLATE* pTempl = dtb.Begin(WS_POPUPWINDOW|DS_MODALFRAME|WS_DLGFRAME,rc,caption); + + // shrink main rect by margins + rc.DeflateRect(CSize(DLGMARGIN,DLGMARGIN)); + + // create icon if needed + if (nIDIcon) { + if (nIDIcon >= (WORD)IDI_APPLICATION) { + // if using a system icon, I load it here and set it in OnInitDialog + // because can't specify system icon in template, only icons from + // application resource file. + m_hIcon = ::LoadIcon(NULL, MAKEINTRESOURCE(nIDIcon)); + nIDIcon = 0; + } else { + m_hIcon = NULL; + } + + // The size is calculated in pixels, but it seems to work OK--??? + CSize sz(GetSystemMetrics(SM_CXICON),GetSystemMetrics(SM_CYICON)); + CRect rcIcon(rc.TopLeft(), sz); + dtb.AddItem(CDlgTemplateBuilder::STATIC, // add icon + WS_VISIBLE|WS_CHILD|SS_LEFT|SS_ICON, rc, nIDIcon, IDICON); + rc.left += sz.cx; // shrink main rect by width of icon + } + + // add prompt + rc.bottom = rc.top + CYSTATIC; // height = height of static + dtb.AddItem(CDlgTemplateBuilder::STATIC, // add it + WS_VISIBLE|WS_CHILD|SS_LEFT, rc, prompt); + + // add edit control + rc += CPoint(0, rc.Height() + CYSPACE); // move below static + rc.bottom = rc.top + CYEDIT; // height = height of edit control + dtb.AddItem(CDlgTemplateBuilder::EDIT, // add it ES_AUTOHSCROLL must be add + WS_VISIBLE|WS_CHILD|WS_BORDER|WS_TABSTOP|ES_AUTOHSCROLL, rc, m_str, IDEDIT); + + // add OK button + rc += CPoint(0, rc.Height() + CYSPACE); // move below edit control + rc.bottom = rc.top + CYBUTTON; // height = button height + rc.left = rc.right - CXBUTTON; // width = button width + rc -= CPoint(CXBUTTON + DLGMARGIN,0); // move left one button width + dtb.AddItem(CDlgTemplateBuilder::BUTTON, // add it + WS_VISIBLE|WS_CHILD|WS_TABSTOP|BS_DEFPUSHBUTTON, rc, _T("&OK"), IDOK); + + // add Cancel button + rc += CPoint(CXBUTTON + DLGMARGIN,0); // move right again + dtb.AddItem(CDlgTemplateBuilder::BUTTON, // add Cancel button + WS_VISIBLE|WS_CHILD|WS_TABSTOP, rc, _T("&Cancel"), IDCANCEL); + + return InitModalIndirect(pTempl, pParent); +} + +////////////////// +// Initialize dialog: if I loaded a system icon, set it in static control. +// +BOOL CInputDialog::OnInitDialog() +{ + if (m_hIcon) { + CStatic* pStatic = (CStatic*)GetDlgItem(IDICON); + ASSERT(pStatic); + pStatic->SetIcon(m_hIcon); + } + return CDialog::OnInitDialog(); +} + +///////////////// +// User pressed OK: check for empty string if required flag is set. +// +void CInputDialog::OnOK() +{ + UpdateData(TRUE); + if (m_bRequired && m_str.IsEmpty()) { + MessageBeep(0); + return; // don't quit dialog! + } + CDialog::OnOK(); +} diff --git a/CcRemote/CcRemote/InputDlg.h b/CcRemote/CcRemote/InputDlg.h new file mode 100644 index 0000000..dede969 --- /dev/null +++ b/CcRemote/CcRemote/InputDlg.h @@ -0,0 +1,83 @@ +//////////////////////////////////////////////////////////////// +// PixieLib(TM) Copyright 1997-2005 Paul DiLascia +// If this code works, it was written by Paul DiLascia. +// If not, I don't know who wrote it. +// Compiles with Visual Studio.NET 7.1 or greater. Set tabsize=3. +// + +////////////////// +// Helper class to build a dialog template in memory. Only supports what's +// needed for CStringDialog. +// +class CDlgTemplateBuilder { +protected: + WORD* m_pBuffer; // internal buffer holds dialog template + WORD* m_pNext; // next WORD to copy stuff + WORD* m_pEndBuf; // end of buffer + + // align ptr to nearest DWORD + WORD* AlignDWORD(WORD* ptr) { + ptr++; // round up to nearest DWORD + LPARAM lp = (LPARAM)ptr; // convert to long + lp &= 0xFFFFFFFC; // make sure on DWORD boundary + return (WORD*)lp; + } + + void AddItemTemplate(WORD wType, DWORD dwStyle, const CRect& rc, + WORD nID, DWORD dwStyleEx); + +public: + // Windows predefined atom names + enum { BUTTON=0x0080, EDIT, STATIC, LISTBOX, SCROLLBAR, COMBOBOX }; + + CDlgTemplateBuilder(UINT nBufLen=1024); + ~CDlgTemplateBuilder(); + + DLGTEMPLATE* GetTemplate() { return (DLGTEMPLATE*)m_pBuffer; } + + // functions to build the template + DLGTEMPLATE* Begin(DWORD dwStyle, const CRect& rc, LPCTSTR caption, DWORD dwStyleEx=0); + WORD* AddText(WORD* buf, LPCTSTR text); + void AddItem(WORD wType, DWORD dwStyle, const CRect& rc, + LPCTSTR text, WORD nID=-1, DWORD dwStyleEx=0); + void AddItem(WORD wType, DWORD dwStyle, const CRect& rc, + WORD nResID, WORD nID=-1, DWORD dwStyleEx=0); +}; + +////////////////// +// Class to implement a simple string input dialog. Kind of like MessageBox +// but it accepts a single string input from user. You provide the prompt. To +// use: +// +// CStringDialog dlg; // string dialog +// dlg.m_bRequired = m_bRequired; // if string is required +// dlg.Init(_T("Title"), _T("Enter a string:"), this, IDI_QUESTION); +// dlg.DoModal(); // run dialog +// CString result = dlg.m_str; // whatever the user typed +// +class CInputDialog : public CDialog { +public: + CString m_str; // the string returned [in,out] + BOOL m_bRequired; // string required? + HICON m_hIcon; // icon if not supplied + + CInputDialog() { } + ~CInputDialog() { } + + // Call this to create the template with given caption and prompt. + BOOL Init(LPCTSTR caption, LPCTSTR prompt, CWnd* pParent=NULL, + WORD nIDIcon=(WORD)IDI_QUESTION); + +protected: + CDlgTemplateBuilder m_dtb; // place to build/hold the dialog template + enum { IDICON=1, IDEDIT }; // control IDs + + // MFC virtual overrides + virtual BOOL OnInitDialog(); + virtual void OnOK(); + virtual void DoDataExchange(CDataExchange* pDX) + { + DDX_Text(pDX, IDEDIT, m_str); + } +}; + diff --git a/CcRemote/CcRemote/PublicStruct.h b/CcRemote/CcRemote/PublicStruct.h index c2ef9bb..049e7ea 100644 --- a/CcRemote/CcRemote/PublicStruct.h +++ b/CcRemote/CcRemote/PublicStruct.h @@ -66,3 +66,19 @@ typedef struct DWORD dwSpeed; // }LOGININFO; +typedef struct +{ + DWORD dwSizeHigh; + DWORD dwSizeLow; +}FILESIZE; + +#define MAKEINT64(low, high) ((unsigned __int64)(((DWORD)(low)) | ((unsigned __int64)((DWORD)(high))) << 32)) +#ifdef _UNICODE +#if defined _M_IX86 +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") +#elif defined _M_X64 +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") +#else +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") +#endif +#endif diff --git a/CcRemote/CcRemote/Release/CcRemote.log b/CcRemote/CcRemote/Release/CcRemote.log index 49bb15a..31154ca 100644 --- a/CcRemote/CcRemote/Release/CcRemote.log +++ b/CcRemote/CcRemote/Release/CcRemote.log @@ -1,46 +1,46 @@ -G:\VS2017\Common7\IDE\VC\VCTargets\Microsoft.CppBuild.targets(377,5): warning MSB8004: Output 目录未以斜杠结尾。 此生成实例将添加斜杠,因为必须有这个斜杠才能正确计算 Output 目录。 +C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.CppBuild.targets(377,5): warning MSB8004: Output 目录未以斜杠结尾。 此生成实例将添加斜杠,因为必须有这个斜杠才能正确计算 Output 目录。 pch.cpp CcRemote.cpp CcRemoteDlg.cpp -g:\ccremote\ccremote\ccremote\ccremote\ccremotedlg.cpp(162): warning C4996: 'gethostbyname': Use getaddrinfo() or GetAddrInfoW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings - g:\windows kits\10\include\10.0.17763.0\um\winsock2.h(2219): note: 参见“gethostbyname”的声明 -g:\ccremote\ccremote\ccremote\ccremote\ccremotedlg.cpp(167): warning C4996: 'inet_ntoa': Use inet_ntop() or InetNtop() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings - g:\windows kits\10\include\10.0.17763.0\um\winsock2.h(1849): note: 参见“inet_ntoa”的声明 -g:\ccremote\ccremote\ccremote\ccremote\ccremotedlg.cpp(308): warning C4244: “初始化”: 从“double”转换到“int”,可能丢失数据 -g:\ccremote\ccremote\ccremote\ccremote\ccremotedlg.cpp(325): warning C4244: “初始化”: 从“double”转换到“int”,可能丢失数据 -g:\ccremote\ccremote\ccremote\ccremote\ccremotedlg.cpp(798): warning C4018: “<=”: 有符号/无符号不匹配 -g:\ccremote\ccremote\ccremote\ccremote\ccremotedlg.cpp(880): warning C4996: 'inet_ntoa': Use inet_ntop() or InetNtop() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings - g:\windows kits\10\include\10.0.17763.0\um\winsock2.h(1849): note: 参见“inet_ntoa”的声明 +f:\myapp\ccremote\ccremote\ccremote\ccremotedlg.cpp(164): warning C4996: 'gethostbyname': Use getaddrinfo() or GetAddrInfoW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings + d:\windows kits\10\include\10.0.17763.0\um\winsock2.h(2219): note: 参见“gethostbyname”的声明 +f:\myapp\ccremote\ccremote\ccremote\ccremotedlg.cpp(169): warning C4996: 'inet_ntoa': Use inet_ntop() or InetNtop() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings + d:\windows kits\10\include\10.0.17763.0\um\winsock2.h(1849): note: 参见“inet_ntoa”的声明 +f:\myapp\ccremote\ccremote\ccremote\ccremotedlg.cpp(312): warning C4244: “初始化”: 从“double”转换到“int”,可能丢失数据 +f:\myapp\ccremote\ccremote\ccremote\ccremotedlg.cpp(335): warning C4244: “初始化”: 从“double”转换到“int”,可能丢失数据 +f:\myapp\ccremote\ccremote\ccremote\ccremotedlg.cpp(826): warning C4018: “<=”: 有符号/无符号不匹配 +f:\myapp\ccremote\ccremote\ccremote\ccremotedlg.cpp(908): warning C4996: 'inet_ntoa': Use inet_ntop() or InetNtop() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings + d:\windows kits\10\include\10.0.17763.0\um\winsock2.h(1849): note: 参见“inet_ntoa”的声明 CScreenSpyDlg.cpp -g:\ccremote\ccremote\ccremote\ccremote\cscreenspydlg.cpp(54): warning C4996: 'inet_ntoa': Use inet_ntop() or InetNtop() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings - g:\windows kits\10\include\10.0.17763.0\um\winsock2.h(1849): note: 参见“inet_ntoa”的声明 -g:\ccremote\ccremote\ccremote\ccremote\cscreenspydlg.cpp(607): warning C4554: “<<”: 检查运算符优先级是否存在的可能的错误;使用括号阐明优先级 -g:\ccremote\ccremote\ccremote\ccremote\cscreenspydlg.cpp(621): warning C4554: “<<”: 检查运算符优先级是否存在的可能的错误;使用括号阐明优先级 +f:\myapp\ccremote\ccremote\ccremote\cscreenspydlg.cpp(54): warning C4996: 'inet_ntoa': Use inet_ntop() or InetNtop() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings + d:\windows kits\10\include\10.0.17763.0\um\winsock2.h(1849): note: 参见“inet_ntoa”的声明 +f:\myapp\ccremote\ccremote\ccremote\cscreenspydlg.cpp(607): warning C4554: “<<”: 检查运算符优先级是否存在的可能的错误;使用括号阐明优先级 +f:\myapp\ccremote\ccremote\ccremote\cscreenspydlg.cpp(621): warning C4554: “<<”: 检查运算符优先级是否存在的可能的错误;使用括号阐明优先级 CSettingDlg.cpp CShellDlg.cpp -g:\ccremote\ccremote\ccremote\ccremote\cshelldlg.cpp(95): warning C4996: 'inet_ntoa': Use inet_ntop() or InetNtop() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings - g:\windows kits\10\include\10.0.17763.0\um\winsock2.h(1849): note: 参见“inet_ntoa”的声明 -g:\ccremote\ccremote\ccremote\ccremote\cshelldlg.cpp(122): warning C4018: “<”: 有符号/无符号不匹配 -g:\ccremote\ccremote\ccremote\ccremote\cshelldlg.cpp(208): warning C4018: “<=”: 有符号/无符号不匹配 -g:\ccremote\ccremote\ccremote\ccremote\cshelldlg.cpp(218): warning C4018: “<”: 有符号/无符号不匹配 +f:\myapp\ccremote\ccremote\ccremote\cshelldlg.cpp(95): warning C4996: 'inet_ntoa': Use inet_ntop() or InetNtop() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings + d:\windows kits\10\include\10.0.17763.0\um\winsock2.h(1849): note: 参见“inet_ntoa”的声明 +f:\myapp\ccremote\ccremote\ccremote\cshelldlg.cpp(122): warning C4018: “<”: 有符号/无符号不匹配 +f:\myapp\ccremote\ccremote\ccremote\cshelldlg.cpp(208): warning C4018: “<=”: 有符号/无符号不匹配 +f:\myapp\ccremote\ccremote\ccremote\cshelldlg.cpp(218): warning C4018: “<”: 有符号/无符号不匹配 CSystemDlg.cpp -g:\ccremote\ccremote\ccremote\ccremote\csystemdlg.cpp(114): warning C4996: 'inet_ntoa': Use inet_ntop() or InetNtop() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings - g:\windows kits\10\include\10.0.17763.0\um\winsock2.h(1849): note: 参见“inet_ntoa”的声明 +f:\myapp\ccremote\ccremote\ccremote\csystemdlg.cpp(114): warning C4996: 'inet_ntoa': Use inet_ntop() or InetNtop() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings + d:\windows kits\10\include\10.0.17763.0\um\winsock2.h(1849): note: 参见“inet_ntoa”的声明 CpuUsage.cpp IniFile.cpp -g:\ccremote\ccremote\ccremote\ccremote\inifile.cpp(33): warning C4996: 'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. - g:\windows kits\10\include\10.0.17763.0\ucrt\string.h(90): note: 参见“strcat”的声明 +f:\myapp\ccremote\ccremote\ccremote\inifile.cpp(33): warning C4996: 'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. + d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(90): note: 参见“strcat”的声明 SEU_QQwry.cpp TrueColorToolBar.cpp Buffer.cpp IOCPServer.cpp -g:\ccremote\ccremote\ccremote\ccremote\include\iocpserver.cpp(133): warning C4996: 'WSASocketA': Use WSASocketW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings - g:\windows kits\10\include\10.0.17763.0\um\winsock2.h(3416): note: 参见“WSASocketA”的声明 -g:\ccremote\ccremote\ccremote\ccremote\include\iocpserver.cpp(725): warning C4996: 'inet_ntoa': Use inet_ntop() or InetNtop() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings - g:\windows kits\10\include\10.0.17763.0\um\winsock2.h(1849): note: 参见“inet_ntoa”的声明 -g:\ccremote\ccremote\ccremote\ccremote\include\iocpserver.cpp(774): warning C4244: “初始化”: 从“double”转换到“unsigned long”,可能丢失数据 -g:\ccremote\ccremote\ccremote\ccremote\include\iocpserver.cpp(920): warning C4018: “>=”: 有符号/无符号不匹配 +f:\myapp\ccremote\ccremote\ccremote\include\iocpserver.cpp(133): warning C4996: 'WSASocketA': Use WSASocketW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings + d:\windows kits\10\include\10.0.17763.0\um\winsock2.h(3416): note: 参见“WSASocketA”的声明 +f:\myapp\ccremote\ccremote\ccremote\include\iocpserver.cpp(725): warning C4996: 'inet_ntoa': Use inet_ntop() or InetNtop() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings + d:\windows kits\10\include\10.0.17763.0\um\winsock2.h(1849): note: 参见“inet_ntoa”的声明 +f:\myapp\ccremote\ccremote\ccremote\include\iocpserver.cpp(774): warning C4244: “初始化”: 从“double”转换到“unsigned long”,可能丢失数据 +f:\myapp\ccremote\ccremote\ccremote\include\iocpserver.cpp(920): warning C4018: “>=”: 有符号/无符号不匹配 正在生成代码 - All 520 functions were compiled because no usable IPDB/IOBJ from previous compilation was found. + All 523 functions were compiled because no usable IPDB/IOBJ from previous compilation was found. 已完成代码的生成 - CcRemote.vcxproj -> G:\CcRemote\CcRemote\CcRemote\CcRemote\..\..\bin\CcRemote.exe + CcRemote.vcxproj -> F:\myapp\CcRemote\CcRemote\CcRemote\..\..\bin\CcRemote.exe diff --git a/CcRemote/CcRemote/Release/CcRemote.res b/CcRemote/CcRemote/Release/CcRemote.res index 414c6aa..ddad07b 100644 Binary files a/CcRemote/CcRemote/Release/CcRemote.res and b/CcRemote/CcRemote/Release/CcRemote.res differ diff --git a/CcRemote/CcRemote/Release/CcRemote.tlog/CcRemote.lastbuildstate b/CcRemote/CcRemote/Release/CcRemote.tlog/CcRemote.lastbuildstate index cb3e57d..346638a 100644 --- a/CcRemote/CcRemote/Release/CcRemote.tlog/CcRemote.lastbuildstate +++ b/CcRemote/CcRemote/Release/CcRemote.tlog/CcRemote.lastbuildstate @@ -1,2 +1,2 @@ #TargetFrameworkVersion=v4.0:PlatformToolSet=v141:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0.17763.0 -Release|Win32|G:\CcRemote\CcRemote\CcRemote\| +Release|Win32|F:\myapp\CcRemote\CcRemote\| diff --git a/CcRemote/CcRemote/pch.h b/CcRemote/CcRemote/pch.h index 68c7844..03094a0 100644 --- a/CcRemote/CcRemote/pch.h +++ b/CcRemote/CcRemote/pch.h @@ -15,6 +15,8 @@ #include #include #include +#include +#include #endif //PCH_H diff --git a/CcRemote/CcRemote/res/1.cur b/CcRemote/CcRemote/res/1.cur new file mode 100644 index 0000000..10c75c4 Binary files /dev/null and b/CcRemote/CcRemote/res/1.cur differ diff --git a/CcRemote/CcRemote/res/2.cur b/CcRemote/CcRemote/res/2.cur new file mode 100644 index 0000000..7cfd168 Binary files /dev/null and b/CcRemote/CcRemote/res/2.cur differ diff --git a/CcRemote/CcRemote/res/3.cur b/CcRemote/CcRemote/res/3.cur new file mode 100644 index 0000000..60a0b71 Binary files /dev/null and b/CcRemote/CcRemote/res/3.cur differ diff --git a/CcRemote/CcRemote/res/4.cur b/CcRemote/CcRemote/res/4.cur new file mode 100644 index 0000000..7268e9d Binary files /dev/null and b/CcRemote/CcRemote/res/4.cur differ diff --git a/CcRemote/CcRemote/res/Bitmap_4.bmp b/CcRemote/CcRemote/res/Bitmap_4.bmp new file mode 100644 index 0000000..73df4a1 Binary files /dev/null and b/CcRemote/CcRemote/res/Bitmap_4.bmp differ diff --git a/CcRemote/CcRemote/res/Bitmap_5.bmp b/CcRemote/CcRemote/res/Bitmap_5.bmp new file mode 100644 index 0000000..e282375 Binary files /dev/null and b/CcRemote/CcRemote/res/Bitmap_5.bmp differ diff --git a/CcRemote/CcRemote/res/background_list_online.bmp b/CcRemote/CcRemote/res/background_list_online.bmp new file mode 100644 index 0000000..8b43b9c Binary files /dev/null and b/CcRemote/CcRemote/res/background_list_online.bmp differ diff --git a/CcRemote/CcRemote/res/bmp00001.bmp b/CcRemote/CcRemote/res/bmp00001.bmp new file mode 100644 index 0000000..71bc623 Binary files /dev/null and b/CcRemote/CcRemote/res/bmp00001.bmp differ diff --git a/CcRemote/CcRemote/res/dot.cur b/CcRemote/CcRemote/res/dot.cur index dc4be96..e3f707a 100644 Binary files a/CcRemote/CcRemote/res/dot.cur and b/CcRemote/CcRemote/res/dot.cur differ diff --git a/CcRemote/CcRemote/res/toolbar2.bmp b/CcRemote/CcRemote/res/toolbar2.bmp new file mode 100644 index 0000000..71bc623 Binary files /dev/null and b/CcRemote/CcRemote/res/toolbar2.bmp differ diff --git a/CcRemote/CcRemote/resource.h b/CcRemote/CcRemote/resource.h index f5712d7..c38367b 100644 --- a/CcRemote/CcRemote/resource.h +++ b/CcRemote/CcRemote/resource.h @@ -29,12 +29,26 @@ #define IDD_DIALOG1 149 #define IDD_SCREENSPY 149 #define IDI_DOT 153 -#define IDC_DOT 153 #define IDB_BACKGROUND_ 154 #define IDB_BACKGROUND_CCREMOTE 154 +#define IDD_FILE 155 +#define IDD_TRANSFERMODE_DLG 157 +#define IDR_FILEMANAGER 159 +#define IDR_LOCAL_VIEW 160 +#define IDR_REMOTE_VIEW 161 +#define IDC_DRAG 162 +#define IDC_MUTI_DRAG 163 +#define IDC_CURSOR3 164 +#define IDC_CURSOR4 165 +#define IDC_DOT 167 +#define IDB_TOOLBAR_ENABLE 168 +#define IDB_TOOLBAR_DISABLE 169 +#define IDR_TOOLBAR1 170 +#define IDR_TOOLBAR2 172 #define IDC_ONLINE 1000 #define IDC_LIST2 1001 #define IDC_MESSAGE 1001 +#define IDC_LIST_REMOTE 1001 #define IDC_EDIT_PORT 1002 #define IDC_EDIT_MAX 1003 #define IDC_EDIT 1003 @@ -42,6 +56,23 @@ #define IDC_LIST_WINDOWS 1005 #define IDC_LIST_PROCESS_OR_WINDOW 1006 #define IDC_LIST_PROCESS_OR_WINDOW_OR_WINDOW 1006 +#define IDC_STATIC_FILE_LOCAL 1006 +#define IDC_STATIC_LOCAL 1006 +#define IDC_STATIC_FILE_REMOTE 1007 +#define IDC_STATIC_REMOTE 1007 +#define IDC_LIST_LOCAL 1008 +#define IDC_LOCAL_PATH 1009 +#define IDC_REMOTE_PATH 1010 +#define IDC_OVERWRITE 1011 +#define IDC_TIPS 1012 +#define IDC_CANCEL 1013 +#define IDC_OVERWRITE_ALL 1016 +#define IDC_ADDITION 1017 +#define IDC_JUMP 1018 +#define IDC_ADDITION_ALL 1019 +#define IDC_JUMP_ALL 1020 +#define ID_LOCAL_TOOLBAR 0x5001 +#define ID_REMOTE_TOOLBAR 0x5002 #define ID_ONLINE_32771 32771 #define ID_ONLINE_32772 32772 #define ID_ONLINE_32773 32773 @@ -109,14 +140,59 @@ #define ID_WINDOW_MAX 32836 #define ID_WINDOW_MIN 32837 #define ID_WINDOW_S 32838 +#define ID_FILEMANGER_32839 32839 +#define ID_FILEMANGER_32840 32840 +#define ID_FILEMANGER_32841 32841 +#define ID_FILEMANGER_I32842 32842 +#define ID_FILEMANGER_32843 32843 +#define ID_FILEMANGER_32844 32844 +#define ID_FILEMANGER_32845 32845 +#define ID_FILEMANGER_32846 32846 +#define IDM_TRANSFER 32847 +#define IDM_RENAME 32848 +#define IDM_DELETE 32849 +#define IDM_NEWFOLDER 32850 +#define IDM_LOCAL_OPEN 32851 +#define IDM_REMOTE_OPEN_SHOW 32852 +#define IDM_REMOTE_OPEN_HIDE 32853 +#define IDM_REFRESH 32854 +#define ID_LVIEW_32855 32855 +#define ID_LVIEW_32856 32856 +#define ID_LVIEW_32857 32857 +#define ID_LVIEW_32858 32858 +#define IDM_LOCAL_BIGICON 32859 +#define IDM_LOCAL_SMALLICON 32860 +#define IDM_LOCAL_LIST 32861 +#define IDM_LOCAL_REPORT 32862 +#define ID_RVIEW_32863 32863 +#define ID_RVIEW_32864 32864 +#define ID_RVIEW_32865 32865 +#define ID_RVIEW_32866 32866 +#define IDM_REMOTE_BIGICON 32867 +#define IDM_REMOTE_SMALLICON 32868 +#define IDM_REMOTE_LIST 32869 +#define IDM_REMOTE_REPORT 32870 +#define IDT_LOCAL_PREV 32871 +#define IDT_LOCAL_COPY 32872 +#define IDT_LOCAL_DELETE 32873 +#define IDT_LOCAL_NEWFOLDER 32874 +#define ID_BUTTON32875 32875 +#define IDT_LOCAL_STOP 32875 +#define IDT_LOCAL_VIEW 32876 +#define IDT_REMOTE_PREV 32877 +#define IDT_REMOTE_COPY 32878 +#define IDT_REMOTE_DELETE 32879 +#define IDT_REMOTE_NEWFOLDER 32880 +#define IDT_REMOTE_VIEW 32881 +#define IDT_REMOTE_STOP 32882 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 155 -#define _APS_NEXT_COMMAND_VALUE 32839 -#define _APS_NEXT_CONTROL_VALUE 1006 +#define _APS_NEXT_RESOURCE_VALUE 174 +#define _APS_NEXT_COMMAND_VALUE 32883 +#define _APS_NEXT_CONTROL_VALUE 1014 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif diff --git a/bin/CcRemote.exe b/bin/CcRemote.exe index f1278a7..faf6989 100644 Binary files a/bin/CcRemote.exe and b/bin/CcRemote.exe differ