📄 ncfileclientprocesswnd.cpp
字号:
// NCFileClientProcessWnd.cpp : 实现文件
//
#include "stdafx.h"
#include "NCSimulaSys.h"
#include "NCFileSocket.h"
#include "NCMessage.h"
#include "NCFileClientProcessWnd.h"
#include "MainFrm.h"
// CNCFileClientProcessWnd
IMPLEMENT_DYNCREATE(CNCFileClientProcessWnd, CFrameWnd)
CNCFileClientProcessWnd::CNCFileClientProcessWnd()
{
}
CNCFileClientProcessWnd::CNCFileClientProcessWnd(CMainFrame* p)
{
pMainWnd = p;
}
CNCFileClientProcessWnd::~CNCFileClientProcessWnd()
{
}
BEGIN_MESSAGE_MAP(CNCFileClientProcessWnd, CFrameWnd)
END_MESSAGE_MAP()
// CNCFileClientProcessWnd 消息处理程序
void CNCFileClientProcessWnd::OnReceive(CNCFileSocket* pSocket, CNCMessage& msg)
{
CString strMsg = msg.m_strMessage;
// 返回"主动注销成功"信息.
if(strMsg == _T("FILESERVER-LOGOUT-SUCCESSFUL"))
{
theApp.m_Socket_File->CloseSocket();
delete theApp.m_Socket_File;
theApp.m_Socket_File = NULL;
// 清空文件列表.
pMainWnd->m_wndTaskPane.m_wndGridCtrl_ServerFile.RemoveAll();
pMainWnd->m_wndTaskPane.m_wndGridCtrl_ServerFile.Sort(0);
// 停止下载.
}
// 返回"服务器关闭"信息.
if(strMsg == _T("FILESERVER-CLOSE"))
{
theApp.m_Socket_File->CloseSocket();
delete theApp.m_Socket_File;
theApp.m_Socket_File = NULL;
// 清空文件列表.
pMainWnd->m_wndTaskPane.m_wndGridCtrl_ServerFile.RemoveAll();
pMainWnd->m_wndTaskPane.m_wndGridCtrl_ServerFile.Sort(0);
// 停止下载.
AfxMessageBox(_T("远程文件服务器被关闭,被迫注销."));
}
// 返回"服务器强迫客户端注销"信息.
if(strMsg == _T("FILESERVER-CLOSE-LOGOUT-FORCED"))
{
theApp.m_Socket_File->CloseSocket();
delete theApp.m_Socket_File;
theApp.m_Socket_File = NULL;
// 清空文件列表.
pMainWnd->m_wndTaskPane.m_wndGridCtrl_ServerFile.RemoveAll();
pMainWnd->m_wndTaskPane.m_wndGridCtrl_ServerFile.Sort(0);
// 停止下载.
AfxMessageBox(_T("远程文件服务器强迫注销."));
}
// 返回"更新TaskPane中服务器文件列表"信息.
if(strMsg.Left(16) == _T("UPDATE-FILELIST-"))
{
CString strInfo = strMsg.Right(strMsg.GetLength() - 16);
CArray<CString, CString> strArrayDirectoryName;
CArray<CString, CString> strArrayFileName;
CArray<CString, CString> strArrayFileSize;
// 分割字符串.
if(strInfo.GetLength() > 0)
{
for(;;)
{
int iPos_1 = 0;
int iPos_2 = 0;
if(strInfo.Find('|') != -1)
{
CString strSplit;
iPos_1 = strInfo.Find('|');
strSplit = strInfo.Left(iPos_1);
strInfo = strInfo.Right(strInfo.GetLength() - iPos_1 -1);
CString strName,strAttrib,strSize;
iPos_2 = strSplit.Find('*');
strName = strSplit.Left(iPos_2);
strSplit = strSplit.Right(strSplit.GetLength() - iPos_2 -1);
iPos_2 = strSplit.Find('*');
strAttrib = strSplit.Left(iPos_2);
strSize = strSplit.Right(strSplit.GetLength() - iPos_2 -1);
if(strAttrib == _T("FOLDER"))
{
strArrayDirectoryName.Add(strName);
}
if(strAttrib == _T("FILE"))
{
strArrayFileName.Add(strName);
strArrayFileSize.Add(strSize);
}
}
else
{
CString strName,strAttrib,strSize;
iPos_2 = strInfo.Find('*');
strName = strInfo.Left(iPos_2);
strInfo = strInfo.Right(strInfo.GetLength() - iPos_2 -1);
iPos_2 = strInfo.Find('*');
strAttrib = strInfo.Left(iPos_2);
strSize = strInfo.Right(strInfo.GetLength() - iPos_2 -1);
if(strAttrib == _T("FOLDER"))
{
strArrayDirectoryName.Add(strName);
}
else
{
strArrayFileName.Add(strName);
strArrayFileSize.Add(strSize);
}
break;
}
}
}
// 更新TaskPane上的服务器文件列表.
pMainWnd->m_wndTaskPane.m_wndGridCtrl_ServerFile.RemoveAll();
for(int i=0;i<strArrayDirectoryName.GetSize();i++)
{
CBCGPGridRow* pRow = pMainWnd->m_wndTaskPane.m_wndGridCtrl_ServerFile.CreateRow(pMainWnd->m_wndTaskPane.m_wndGridCtrl_ServerFile.GetColumnCount());
pRow->GetItem(0)->SetValue((_variant_t)strArrayDirectoryName[i]);
pRow->GetItem(2)->SetValue(_T("文件夹"));
pMainWnd->m_wndTaskPane.m_wndGridCtrl_ServerFile.AddRow(pRow);
}
for(int i=0;i<strArrayFileName.GetSize();i++)
{
CBCGPGridRow* pRow = pMainWnd->m_wndTaskPane.m_wndGridCtrl_ServerFile.CreateRow(pMainWnd->m_wndTaskPane.m_wndGridCtrl_ServerFile.GetColumnCount());
pRow->GetItem(0)->SetValue((_variant_t)strArrayFileName[i]);
pRow->GetItem(1)->SetValue((_variant_t)strArrayFileSize[i]);
pRow->GetItem(2)->SetValue(_T("文 件"));
pMainWnd->m_wndTaskPane.m_wndGridCtrl_ServerFile.AddRow(pRow);
}
}
// 如果返回的信息说明当前已经到了服务器共享目录的根目录.
if(strMsg == _T("INFO-GET-TOP-FOLDER"))
{
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -