#include "pch.h"
#include "framework.h"
#include "MFCTest.h"
#include "MFCTestDlg.h"
#include "afxdialogex.h"
#include<string>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
map<int, string >m_filenames;
int m_n_fileNum;
int num;
vector<string> v1;
vector<string> v2;
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
class CAboutDlg : public CDialogEx
{
public:
CAboutDlg();
#ifdef AFX_DESIGN_TIME
enum { IDD = IDD_ABOUTBOX };
#endif
protected:
virtual void DoDataExchange(CDataExchange* pDX);
protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialogEx(IDD_ABOUTBOX)
{
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx)
END_MESSAGE_MAP()
CMFCTestDlg::CMFCTestDlg(CWnd* pParent )
: CDialogEx(IDD_MFCTEST_DIALOG, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CMFCTestDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CMFCTestDlg, CDialogEx)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON1, &CMFCTestDlg::OnBnClickedButton1)
END_MESSAGE_MAP()
BOOL CMFCTestDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != nullptr)
{
BOOL bNameValid;
CString strAboutMenu;
bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
ASSERT(bNameValid);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
SetIcon(m_hIcon, TRUE);
SetIcon(m_hIcon, FALSE);
return TRUE;
}
void CMFCTestDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialogEx::OnSysCommand(nID, lParam);
}
}
void CMFCTestDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this);
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialogEx::OnPaint();
}
}
HCURSOR CMFCTestDlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
void CMFCTestDlg::OnBnClickedButton1()
{
CString strFolderPath(_T("C:\\Users\\whwan\\Desktop\\MFCTest\\1"));
ScanDiskFile(strFolderPath,1);
CString strFolderPath2(_T("C:\\Users\\whwan\\Desktop\\MFCTest\\2"));
ScanDiskFile(strFolderPath2,2);
CString temp1 = to_string(v1.size()).c_str();
CString temp2 = to_string(v2.size()).c_str();
if (temp1!=temp2)
{
MessageBox("不匹配,有丢帧现象");
return;
}
for (size_t i=0; i<v1.size(); i++)
{
if (v1[i]!=v2[i])
{
CString p = to_string(i + 1).c_str();
MessageBox("不匹配,有串帧现象,第" + p);
return;
}
}
MessageBox(" 加载完成 !!!");
}
void CMFCTestDlg::ScanDiskFile(const CString& strPath, int sign)
{
CString filePath = strPath;
string filePathS = filePath.GetBuffer();
CFileFind find;
CString strTemp = strPath;
CString strDirectory = strPath + _T("\\") + _T("\\*.*");
CString strFile;
vector<CString> m_vStrAllFiles;
BOOL IsFind = find.FindFile(strDirectory);
while (IsFind)
{
IsFind = find.FindNextFile();
if (find.IsDots())
continue;
else if (find.IsDirectory())
{
strFile = find.GetFileName();
strTemp = strTemp + _T("\\") + strFile;
ScanDiskFile(strTemp,sign);
}
else
{
strFile = find.GetFileName();
string s1 = strFile.GetBuffer();
if (sign ==1)
{
v1.push_back(s1);
}
else
{
v2.push_back(s1);
}
num++;
}
}
find.Close();
}