-
Notifications
You must be signed in to change notification settings - Fork 0
/
DSAMessageBox.cpp
248 lines (230 loc) · 7.47 KB
/
DSAMessageBox.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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
/*
* This file is part of Retell Software Call Recorder.
*
* Retell Software Call Recorder 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 3 of the License,
* or (at your option) any later version.
*
* Retell Software Call Recorder 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
* Retell Software Call Recorder. If not, see <https://www.gnu.org/licenses/>.
*
* Description:
*
* Implementation file for DSAMessageBox (DontShowAgainMessageBox)
*
* $Log: D:/pvcsarch/telar/DSAMessageBox.cpv $
*
* Rev 1.29 Dec 19 2007 17:27:26 tmielke
* Adaptions to Windows Vista
*
* Rev 1.28 Oct 11 2007 10:15:00 tmielke
* Made the soundcard recognition more flexible in case plug and play
* soundcards have switched places.
*
* Rev 1.27 Sep 21 2007 15:47:16 tmielke
* Added Dutch translations and some additional debug code.
*
* Rev 1.26 Aug 14 2007 14:09:04 tmielke
* v1.83 resolved issues with voice modems and other exotic audio devices.
*
* Rev 1.25 May 09 2007 10:23:40 tmielke
* Word wrap now also enabled for edit box in edit record entry dialog.
* Changed the 'Maximise on line signal' checkbox to a numeric value holding
* the number of seconds before the window maximizes to prevent the software
* from popping up if a noise sets the recording off.
* Added an option 'Minimize after automatic recording'.
* Improved usability of options screen by using sliders and spin buttons.
*
* Rev 1.24 Nov 16 2006 14:59:42 tmielke
* v1.80 -- Resolves compatibility issues with Windows NT and 9X version.
* (SHGetSpecialFolder now from redisributable shfolder.dll included in the
* setup rather than shell32.dll)
*
* Rev 1.23 Nov 13 2006 13:26:20 tmielke
* v1.79 build 2100 -- final network licensable version
*
* Rev 1.22 Jun 12 2006 15:13:20 tmielke
* v1.78:
* - If a recording has been done using a password, this password is required to delete the recording (#211)
* - Now using a word-wrap edit box for the notes field (#336)
* - Playback volume control added (#314)
*
* Rev 1.21 Nov 25 2005 01:32:14 tmielke
* v1.76: several bugfixes
*
* Rev 1.20 Nov 23 2005 16:11:16 tmielke
* v1.75 solves the following issues:
* - Master master password wasn't queried when opening the scr window by clicking on the icon in the start menu
* - the application window will now really get the focus when automatically opened with 'maximize on signal'
* - same with master password when window maximized after clicking on the system tray icon (but not when maximized with start menu icon)
* - crash after FTP update is now prohibited
* - the software will now start after setup if the check on the last setup screen is set.
*
* Rev 1.19 Nov 11 2005 09:50:56 tmielke
* v1.74 release
* New layout of the playback tab with tabular list, including in-field
* editing of name and reference (F2 key).
* Abandoned Microsoft database engine. The new index file is now more robust
* in multiuser environments.
*
* Rev 1.18 Jul 11 2005 08:52:30 tmielke
* v1.74 build 1632 (alphatest version)
* - SQLite index file
* - CListCtrls on playback tab
* - Workstations table support
*
* Rev 1.17 Jul 05 2005 01:50:16 tmielke
* improved performance & stability when copying or deleting recordings
*
* Rev 1.16 Jun 28 2005 01:46:24 tmielke
* v1.72 build 1250
*
* Rev 1.15 Jun 02 2005 01:30:24 tmielke
* v1.72 build 1207
*
* Rev 1.14 May 18 2005 13:47:08 tmielke
* v1.72 build 1200
*
* Rev 1.13 Mar 18 2005 16:11:58 tmielke
*
*
* Rev 1.12 Mar 12 2005 07:08:28 tmielke
* v1.69
*
* Rev 1.11 Feb 22 2005 16:53:20 tmielke
* v1.67 build 960
* Added support for 957 Data Integration Linc to allow access in automatic recording mode.
*
* Rev 1.10 Nov 21 2004 01:29:14 tmielke
* v1.66 build 883
*
* Rev 1.9 Dec 04 2003 03:36:40 tmielke
* v1.66 buid 730 -- Database Index File Pre-Release
*
* Rev 1.8 Nov 18 2003 09:39:40 tmielke
* komisch, Workfile älter als Archive...
* Checkin anyway...
*
* Rev 1.7 Oct 03 2003 01:22:08 tmielke
* v1.65 build 572:
* - Added support for master password.
* - Fixed spelling of export message.
* - Fixed export with encryption level 0.
*
*
* Rev 1.6 Sep 23 2003 01:48:02 tmielke
* v1.64 build 557 (improved control tone detection)
*
* Rev 1.5 Sep 12 2003 01:12:08 tmielke
*
*
* Rev 1.4 Sep 11 2003 04:04:04 tmielke
*
*
* Rev 1.3 Sep 04 2003 00:55:24 tmielke
* v1.64 build 514
* C: drive licensing problem solved
* added build count to better determine versions
* fixed problem with disk key licensing
*
* Rev 1.2 Aug 04 2003 00:34:58 tmielke
* v1.64
*
* Rev 1.1 Jun 09 2003 15:25:14 tmielke
* v1.63 final
*
* Rev 1.0 Apr 30 2003 01:02:26 tmielke
* DSAMessageBox eingebaut
*
*/
#include "stdafx.h"
#include "nbMessageBox.h"
#include "DSAMessageBox.h"
// 'member' variables
static HINSTANCE m_hInst = NULL; // module name to get the ressource strings from
static char m_hkcu[200] = ""; // registry key to remember history for each ressource string ID
// --- Call these both to initialize DSAMessageBox
// set module to get ressource strings from (e.g. by using GetModuleHandle("MYAPP.EXE") )
void DSASetModule(HINSTANCE hInst)
{
m_hInst = hInst;
}
// set registry key to store checkbox history (e.g. "SOFTWARE\\MyCompany\\MyProduct")
void DSASetRegKey(char *s)
{
ASSERT(strlen(s) < sizeof(m_hkcu));
strcpy(m_hkcu, s);
}
//--- Main function
int DSAGetStoredValue(int nStringId)
{
HKEY hkcu; // registry key handle
char data[2]; // store data from registry here
CString csValueName; // value name in registry
csValueName.Format("DSA%05d", nStringId);
// look in user registry
if (RegCreateKey(HKEY_CURRENT_USER, m_hkcu, &hkcu) == ERROR_SUCCESS)
{
long lDummy;
long lType = REG_SZ;
long lCb;
lDummy = 0L;
// read settings for current user
*data = '\0';
lCb = sizeof(data);
if (RegQueryValueEx(hkcu, csValueName.GetBuffer(0),
NULL, (ULONG *)&lType,
(LPBYTE)data, (ULONG *)&lCb) != ERROR_SUCCESS)
{
*data = '0'; data[1] = '\0';
}
}
else
{
*data = '0'; data[1] = '\0';
hkcu = NULL;
}
if (hkcu) RegCloseKey(hkcu);
return atoi(data);
}
int DSAMessageBox(int nStringId, UINT nType)
{
int rc = 0; // return value
HKEY hkcu; // registry key handle
// look in user registry
if (RegCreateKey(HKEY_CURRENT_USER, m_hkcu, &hkcu) == ERROR_SUCCESS)
{
char data[2]; // store data from registry here
CString csValueName; // value name in registry
csValueName.Format("DSA%05d", nStringId);
int nValue = DSAGetStoredValue(nStringId);
*data = '0' + nValue; data[1] = '\0';
// show message box
if (*data != '1')
{
char buf[10000];
CnbMessageBox box(AfxGetMainWnd());
LoadString(m_hInst, nStringId, buf, sizeof(buf));
rc = box.MessageBox(buf, nType);
if (hkcu)
{
if (box.GetChecked()) // 'Don't show again' checked?
{
long lRetCode;
*data = '1'; data[1] = '\0';
lRetCode = RegSetValueEx(hkcu, csValueName.GetBuffer(0), // remember in user registry
(ULONG)0, (ULONG)REG_SZ,
(LPBYTE)data, (ULONG)strlen(data));
}
}
}
if (hkcu) RegCloseKey(hkcu);
}
return rc;
}