-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathPropPage_Dirs.cpp
117 lines (95 loc) · 3.03 KB
/
PropPage_Dirs.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// This file is part of Par-N-Rar
// http://www.milow.net/site/projects/parnrar.html
//
// Copyright (c) Gil Milow
//
// Par-N-Rar is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// Par-N-Rar is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// This code may not be used to develop a RAR (WinRAR) compatible archiver.
//
// PropPage_Dirs.cpp : implementation file
//
#include "stdafx.h"
#include "ParNRar.h"
#include "PropPage_Dirs.h"
#include "XBrowseForFolder.h"
#include "DialogUtils.h"
// PropPage_Dirs dialog
IMPLEMENT_DYNCREATE(PropPage_Dirs, CPropertyPage)
PropPage_Dirs::PropPage_Dirs()
: CPropertyPage(PropPage_Dirs::IDD)
{
m_bInitialized = false;
}
PropPage_Dirs::~PropPage_Dirs()
{
}
void PropPage_Dirs::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(PropPage_Dirs, CPropertyPage)
ON_WM_SHOWWINDOW()
ON_BN_CLICKED(IDC_BROWSE_DIR, OnBnClickedBrowseDir)
ON_BN_CLICKED(IDC_BROWSE_DIR2, OnBnClickedBrowseDir2)
END_MESSAGE_MAP()
BOOL PropPage_Dirs::OnWizardFinish()
{
return TRUE;
}
BOOL PropPage_Dirs::OnApply()
{
CString cstr = "";
GetDlgItem(IDC_MONITORDIR)->GetWindowText(cstr);
theApp.m_Options.SetExtractDir(cstr.GetBuffer(0));
GetDlgItem(IDC_NonRarDir)->GetWindowText(cstr);
theApp.m_Options.SetNonRarDir(cstr.GetBuffer(0));
return TRUE;
}
void PropPage_Dirs::OnBnClickedBrowseDir()
{
BrowseDirClick(IDC_EXTRACTDIR);
}
void PropPage_Dirs::OnBnClickedBrowseDir2()
{
BrowseDirClick(IDC_NonRarDir);
}
void PropPage_Dirs::BrowseDirClick(int nId)
{
CString cstrCurFolder = "";
GetDlgItem(nId)->GetWindowText(cstrCurFolder);
cstrCurFolder.Replace("%s", "");
cstrCurFolder.Replace("%d", "");
cstrCurFolder.Replace("%m", "");
auto_ptr<char> apCurFolder( new char[cstrCurFolder.GetLength() + 1] );
char *szCurFolder = apCurFolder.get();
szCurFolder[cstrCurFolder.GetLength()] = 0;
TCHAR szFolder[MAX_PATH * 2];
szFolder[0] = _T('\0');
if (cstrCurFolder != "")
strcpy(szCurFolder, cstrCurFolder.GetBuffer(0));
BOOL bRet = XBrowseForFolder(m_hWnd, szCurFolder, szFolder, sizeof(szFolder)/sizeof(TCHAR)-2);
if (bRet)
GetDlgItem(nId)->SetWindowText(szFolder);
}
void PropPage_Dirs::OnShowWindow(BOOL bShow, UINT nStatus)
{
CPropertyPage::OnShowWindow(bShow, nStatus);
if (m_bInitialized)
return;
GetDlgItem(IDC_EXTRACTDIR)->SetWindowText(theApp.m_Options.GetExtractDir().c_str());
GetDlgItem(IDC_NonRarDir)->SetWindowText(theApp.m_Options.GetNonRarDir().c_str());
m_bInitialized = true;
}