// 清理VC工程Dlg.cpp : implementation file
//
#include "stdafx.h"
#include "清理VC工程.h"
#include "清理VC工程Dlg.h"
#include "dir.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//VC环境里的各种扩展名文件,可以自己添加,
CString strFileType[]={"h","cpp","aps","clw","txt","rc","dsp","dsw","rc2","ico","bmp","ncb","plg","opt"};
//VC的Debug目录里的各种文件,可以自己添加
CString strDeugFileExt[]={"res","idb","pch","pdb","sbr","obj","ilk","exe"};
//VC的Release目录里的各种文件,可以自己添加
CString strReleaseFileExt[]={"res","pch","idb","obj","sbr","exe"};
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CVCDlg dialog
CVCDlg::CVCDlg(CWnd* pParent /*=NULL*/)
: CDialog(CVCDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CVCDlg)
m_strBeginPath = _T("");
m_bDelDebugFile = FALSE;
m_bDelDebugFold = FALSE;
m_bDelProjFile = FALSE;
m_bDelReleaseFile = FALSE;
m_bDelReleaseFold = FALSE;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CVCDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CVCDlg)
DDX_Control(pDX, IDC_EDIT1, m_cbEdit);
DDX_Control(pDX, IDC_DELDEBUGFILE, m_ctrlDelDebugFile);
DDX_Control(pDX, IDC_DELDEBUGFOLD, m_ctrlDelDebugFold);
DDX_Control(pDX, IDC_DELRELEASEFILE, m_ctrlDelReleaseFile);
DDX_Control(pDX, IDC_DELRELEASEFOLD, m_ctrlDelReleaseFold);
DDX_Control(pDX, IDC_FILENAMEEXT, m_clbFileType);
DDX_Control(pDX, IDC_DEBUG_FILE_EXT, m_clbDeugFileExt);
DDX_Control(pDX, IDC_RELEASE_FILE_EXT, m_clbReleaseFileExt);
DDX_Text(pDX, IDC_PATH, m_strBeginPath);
DDX_Check(pDX, IDC_DELDEBUGFILE, m_bDelDebugFile);
DDX_Check(pDX, IDC_DELDEBUGFOLD, m_bDelDebugFold);
DDX_Check(pDX, IDC_DELPROJFILE, m_bDelProjFile);
DDX_Check(pDX, IDC_DELRELEASEFILE, m_bDelReleaseFile);
DDX_Check(pDX, IDC_DELRELEASEFOLD, m_bDelReleaseFold);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CVCDlg, CDialog)
//{{AFX_MSG_MAP(CVCDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_FILETYPE_DELETE_FILE, OnFiletypeDeleteFile)
ON_BN_CLICKED(IDC_DEBUG_DELETE_FILE, OnDebugDeleteFile)
ON_BN_CLICKED(IDC_DEBUG_DELETE_FOLD, OnDebugDeleteFold)
ON_BN_CLICKED(IDC_RELEASE_DELETE_FILE, OnReleaseDeleteFile)
ON_BN_CLICKED(IDC_RELEASE_DELETE_FOLD, OnReleaseDeleteFold)
ON_WM_MOUSEMOVE()
ON_WM_SETCURSOR()
ON_BN_CLICKED(IDC_SELECT_PATH, OnSelectPath)
ON_BN_CLICKED(IDC_HANDLEPROJ, OnHandleProj)
ON_BN_CLICKED(IDC_DELDEBUGFILE, OnDelDebugFile)
ON_BN_CLICKED(IDC_DELDEBUGFOLD, OnDelDebugFold)
ON_BN_CLICKED(IDC_DELRELEASEFILE, OnDelReleaseFile)
ON_BN_CLICKED(IDC_DELRELEASEFOLD, OnDelReleaseFold)
ON_BN_CLICKED(IDC_SELECT_PATH2, OnSelectPath2)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CVCDlg message handlers
BOOL CVCDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// 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
// TODO: Add extra initialization here
// m_bFinished =0;
// RECT rcWindow,rcStatus;
// GetWindowRect(&rcWindow);
// rcWindow.bottom += 20;
// MoveWindow(&rcWindow, FALSE);
// rcStatus=rcWindow;
// rcStatus.top=rcWindow.bottom-20;
/*
//建立状态条
if (!m_wndStatusBar.Create(WS_CHILD|WS_VISIBLE|CCS_BOTTOM,rcStatus,this,IDC_MYSTATUS))
{
TRACE0("Failed to create status bar\n");
return -1;
}
ShowStatus=TRUE;
m_wndStatusBar.SetTipText(0," ");
*/
//
for(int i=0;i<sizeof(strFileType)/sizeof(CString);i++)
{
m_clbFileType.AddString("*."+strFileType[i]);
BOOL b=FALSE;
strFileType[i].MakeLower();
//这里是要删除的VC工程中指定扩展名文件,按照格式自己添加
if(strFileType[i]=="ncb" || strFileType[i]=="opt" ||
strFileType[i]=="plg" || strFileType[i]=="aps")
b=TRUE;
m_clbFileType.SetCheck(i,b);
}
for( i=0;i<sizeof(strDeugFileExt)/sizeof(CString);i++)
{
m_clbDeugFileExt.AddString("*."+strDeugFileExt[i]);
BOOL b=TRUE;
strDeugFileExt[i].MakeLower();
if(strDeugFileExt[i]=="exe")
b=FALSE;
m_clbDeugFileExt.SetCheck(i,b);
}
for( i=0;i<sizeof(strReleaseFileExt)/sizeof(CString);i++)
{
m_clbReleaseFileExt.AddString("*."+strReleaseFileExt[i]);
BOOL b=TRUE;
strReleaseFileExt[i].MakeLower();
if(strReleaseFileExt[i]=="exe")
b=FALSE;
m_clbReleaseFileExt.SetCheck(i,b);
}
m_strBeginPath="";
m_bDelProjFile = TRUE; //删除工程目录下文件
m_bDelDebugFile = TRUE;
m_bDelDebugFold = FALSE;
m_bDelReleaseFile = TRUE;
m_bDelReleaseFold = FALSE;
m_ctrlDelDebugFold.EnableWindow(FALSE);
m_ctrlDelReleaseFold.EnableWindow(FALSE);
//拖放操作
m_dropEdit.SubclassDlgItem(IDC_PATH, this);
m_dropEdit.SetUseDir(TRUE);
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
}
void CVCDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CVCDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
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;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
//设置状态行提示文本
void CVCDlg::SetStatusText(LPCTSTR lpszText, int nSel)
{
//m_wndStatusBar.SetText(lpszText,0,0);
if(nSel == 1)
{
m_cbEdit.SetSel(0,-1);
m_cbEdit.Clear();
return;
}
CString str = lpszText;
m_cbEdit.SetSel(-1, -1); //自动滚屏(其中m_Edit是EDIT筐所关联的EDIT控制对象)
m_cbEdit.ReplaceSel(str+"\r\n"); //自动换行
}
// The system calls this to obtain the cursor t