You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

194 lines
3.5 KiB
C++

#include "stdafx.h"
#include "CrcMaker.h"
#include "CrcMakerDlg.h"
#include "crcmakerdlg.h"
#include "folderdialog.h"
#include ".\crcmakerdlg.h"
CGamevars crcmaker_ini;
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
enum { IDD = IDD_ABOUTBOX };
protected:
virtual void DoDataExchange(CDataExchange* pDX);
protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()
CCrcMakerDlg::CCrcMakerDlg(CWnd* pParent /*=NULL*/)
: CDialog(CCrcMakerDlg::IDD, pParent)
, m_dir_path(_T(""))
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
crcmaker_ini.LoadVars("crcmaker.ini");
m_dir_path = crcmaker_ini.GetVarS("dirpath","");
}
void CCrcMakerDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT1, m_dir_path);
DDX_Control(pDX, IDC_LIST2, m_listctrl);
DDX_Control(pDX, IDC_LIST1, m_list);
}
BEGIN_MESSAGE_MAP(CCrcMakerDlg, CDialog)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
//}}AFX_MSG_MAP
ON_BN_CLICKED(IDOK, OnBnClickedOk)
// ON_EN_CHANGE(IDC_EDIT1, OnEnChangeEdit1)
ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedButton2)
END_MESSAGE_MAP()
BOOL CCrcMakerDlg::OnInitDialog()
{
CDialog::OnInitDialog();
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);
}
}
SetIcon(m_hIcon, TRUE);
SetIcon(m_hIcon, FALSE);
m_dir_path = crcmaker_ini.GetVarS("dirpath","");
UpdateData(TRUE);
//
m_listctrl.InsertColumn(0,"File",LVCFMT_LEFT,130,0);
m_listctrl.InsertColumn(1,"Crc32",LVCFMT_RIGHT,80,0);
m_listctrl.InsertColumn(2,"Size",LVCFMT_RIGHT,80,0);
return TRUE;
}
void CCrcMakerDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
void CCrcMakerDlg::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
{
CDialog::OnPaint();
}
}
HCURSOR CCrcMakerDlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
void CCrcMakerDlg::OnBnClickedOk()
{
UpdateData(TRUE);
if( m_dir_path.IsEmpty() == TRUE ){
OnBnClickedButton1();
if( m_dir_path.IsEmpty() == TRUE ){
AfxMessageBox("No directory selected\nAborting",MB_ICONSTOP);
return;
}
}
ProcessDirectory(m_dir_path);
}
//void CCrcMakerDlg::OnEnChangeEdit1()
//{
//}
void CCrcMakerDlg::OnBnClickedButton1()
{
CFolderDialog dlg(0);
if( IDOK == dlg.DoModal() ){
m_dir_path = dlg.GetPathName();
UpdateData(FALSE);
crcmaker_ini.SetVarS("dirpath",m_dir_path);
crcmaker_ini.SaveVars("crcmaker.ini");
}
}
void CCrcMakerDlg::OnBnClickedButton2()
{
CString exestring;
exestring.Format("explorer %s", m_dir_path);
WinExec(exestring,SW_SHOW);
}