forked from ImpulseAdventure/JPEGsnoop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SettingsDlg.cpp
155 lines (127 loc) · 4.28 KB
/
SettingsDlg.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
// JPEGsnoop - JPEG Image Decoder & Analysis Utility
// Copyright (C) 2017 - Calvin Hass
// http://www.impulseadventure.com/photo/jpeg-snoop.html
//
// This program 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.
//
// This program 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, see <http://www.gnu.org/licenses/>.
//
// SettingsDlg.cpp : implementation file
//
#include "stdafx.h"
#include "JPEGsnoop.h"
#include "SettingsDlg.h"
#include ".\settingsdlg.h"
#include "FolderDlg.h"
#include "JPEGsnoop.h"
#include "SnoopConfig.h"
// CSettingsDlg dialog
IMPLEMENT_DYNAMIC(CSettingsDlg, CDialog)
CSettingsDlg::CSettingsDlg(CWnd* pParent /*=NULL*/)
: CDialog(CSettingsDlg::IDD, pParent)
, m_strDbDir(_T(""))
, m_bUpdateAuto(FALSE)
, m_bReprocessAuto(FALSE)
, m_nUpdateChkDays(0)
, m_bDbSubmitNet(FALSE)
, m_nRptErrMaxScanDecode(0)
{
}
CSettingsDlg::~CSettingsDlg()
{
}
void CSettingsDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_DB_DIR, m_strDbDir);
DDX_Check(pDX, IDC_UPDATE_CHK, m_bUpdateAuto);
DDX_Check(pDX, IDC_REPROCESS_AUTO, m_bReprocessAuto);
DDX_Text(pDX, IDC_UPDATE_CHK_DAYS, m_nUpdateChkDays);
DDV_MinMaxUInt(pDX, m_nUpdateChkDays, 1, 365);
DDX_Check(pDX, IDC_DBSUBMIT_NET, m_bDbSubmitNet);
DDX_Text(pDX, IDC_RPTERRMAX_SCANDECODE, m_nRptErrMaxScanDecode);
}
BEGIN_MESSAGE_MAP(CSettingsDlg, CDialog)
ON_BN_CLICKED(IDC_DB_DIR_BROWSE, OnBnClickedDbDirBrowse)
ON_BN_CLICKED(IDC_DB_DIR_DEFAULT, OnBnClickedDbDirDefault)
ON_BN_CLICKED(IDC_COACH_RESET, OnBnClickedCoachReset)
END_MESSAGE_MAP()
// CSettingsDlg message handlers
void CSettingsDlg::OnBnClickedDbDirBrowse()
{
// TODO: Add your control notification handler code here
CString strDir;
strDir = SelectFolder(_T("Please select folder for User Database"));
if (strDir == _T("")) {
// User cancelled
} else {
m_strDbDir = strDir;
UpdateData(false);
}
}
CString CSettingsDlg::SelectFolder(const CString& strMessage)
{
CString Result;
BROWSEINFO BrowseInfo;
memset(&BrowseInfo, 0, sizeof(BrowseInfo));
TCHAR szBuffer[MAX_PATH];
szBuffer[0] = '\0'; // Start as null-terminated
BrowseInfo.hwndOwner = m_hWnd;
BrowseInfo.pszDisplayName = szBuffer;
BrowseInfo.lpszTitle = strMessage;
BrowseInfo.ulFlags = BIF_RETURNONLYFSDIRS;
// Throw display dialog
LPITEMIDLIST pList = SHBrowseForFolder(&BrowseInfo);
ASSERT(_tcslen(szBuffer) < sizeof(szBuffer));
if (pList != NULL)
{
// Convert from MIDLISt to real string path
SHGetPathFromIDList(pList, szBuffer);
Result = szBuffer;
// Global pointer to the shell's IMalloc interface.
LPMALLOC pMalloc;
// Get the shell's allocator and free the PIDL returned by
// SHBrowseForFolder.
if (SUCCEEDED(SHGetMalloc(&pMalloc)))
pMalloc->Free(pList);
}
return Result;
}
LPITEMIDLIST CSettingsDlg::ConvertPathToLpItemIdList(const char *pszPath)
{
LPITEMIDLIST pidl = NULL;
LPSHELLFOLDER pDesktopFolder;
OLECHAR olePath[MAX_PATH];
ULONG* pchEaten = NULL;
ULONG dwAttributes = 0;
HRESULT hr;
if (SUCCEEDED(SHGetDesktopFolder(&pDesktopFolder)))
{
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, pszPath, -1, olePath, MAX_PATH);
hr = pDesktopFolder->ParseDisplayName(NULL,NULL,olePath,pchEaten, &pidl,&dwAttributes);
pDesktopFolder->Release();
}
return pidl;
}
void CSettingsDlg::OnBnClickedDbDirDefault()
{
CJPEGsnoopApp* pApp;
pApp = (CJPEGsnoopApp*)AfxGetApp();
m_strDbDir = pApp->m_pAppConfig->GetDefaultDbDir();
UpdateData(false);
}
void CSettingsDlg::OnBnClickedCoachReset()
{
CJPEGsnoopApp* pApp;
pApp = (CJPEGsnoopApp*)AfxGetApp();
pApp->m_pAppConfig->CoachReset();
}