-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDlgGeneral.cpp
More file actions
235 lines (186 loc) · 5.94 KB
/
DlgGeneral.cpp
File metadata and controls
235 lines (186 loc) · 5.94 KB
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
/*******************************************************************
// Copyright (c) 2002, 2003, 2004, 2005,
// Robert Umbehant
// mailto:rumbehant@wheresjames.com
//
// 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, write to the Free
// Software Foundation, Inc., 59 Temple Place, Suite 330,
// Boston, MA 02111-1307 USA
//
*******************************************************************/
// DlgGeneral.cpp : implementation file
//
#include "stdafx.h"
#include "vp.h"
#include "DlgGeneral.h"
#include "DlgTreeFrame.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define SHORTCUT_FILENAME "WheresJames Webcam Publisher Pro.lnk"
#define SHORTCUT_NAME "WheresJames Webcam Publisher Pro"
#define STARTUP_HKEY HKEY_CURRENT_USER
#define STARTUP_SZKEY "Software\\Microsoft\\Windows\\CurrentVersion\\Run"
/////////////////////////////////////////////////////////////////////////////
// CDlgGeneral dialog
CDlgGeneral::CDlgGeneral(CWnd* pParent /*=NULL*/)
: CDialog(CDlgGeneral::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlgGeneral)
m_bStartup = FALSE;
m_bTrayIcon = FALSE;
m_nAction = 0;
m_bToolbar = FALSE;
m_bAutoUpdate = FALSE;
//}}AFX_DATA_INIT
}
void CDlgGeneral::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgGeneral)
DDX_Control(pDX, IDC_CLOSEICON, m_imgClose);
DDX_Check(pDX, IDC_STARTUP, m_bStartup);
DDX_Check(pDX, IDC_TRAYICON, m_bTrayIcon);
DDX_Radio(pDX, IDC_ACTION, m_nAction);
DDX_Check(pDX, IDC_TOOLBAR, m_bToolbar);
DDX_Check(pDX, IDC_AUTOUPDATE, m_bAutoUpdate);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgGeneral, CDialog)
//{{AFX_MSG_MAP(CDlgGeneral)
ON_BN_CLICKED(IDC_ACTION, OnAction)
ON_BN_CLICKED(IDC_ACTION2, OnAction2)
ON_BN_CLICKED(IDC_ACTION3, OnAction3)
ON_BN_CLICKED(IDC_STARTUP, OnStartup)
ON_BN_CLICKED(IDC_TRAYICON, OnTrayicon)
//}}AFX_MSG_MAP
ON_MESSAGE( WM_PG_SAVE, OnSave )
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlgGeneral message handlers
void CDlgGeneral::OnCancel()
{
}
void CDlgGeneral::OnOK()
{
}
BOOL CDlgGeneral::OnInitDialog()
{
CDialog::OnInitDialog();
m_imgClose.SetInfo( "WINDOW", WP_CLOSEBUTTON, CBS_NORMAL,
CGrDC::LoadIcon( IDI_CLOSE ) );
OnRefresh( 0, 0L );
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
LRESULT CDlgGeneral::OnRefresh(WPARAM wParam, LPARAM lParam)
{
{ // Check startup
BOOL ok = FALSE;
HKEY hKey;
if ( RegOpenKeyEx( STARTUP_HKEY, STARTUP_SZKEY,
0, KEY_ALL_ACCESS | KEY_READ, &hKey ) == ERROR_SUCCESS )
{
DWORD len = CWF_STRSIZE;
char path[ CWF_STRSIZE ];
// Attempt to query entry
if ( RegQueryValueEx( hKey, SHORTCUT_NAME,
0, NULL, (LPBYTE)path, &len ) == ERROR_SUCCESS )
{
char exe[ CWF_STRSIZE ];
// Remove quotes from path
CWinFile::Unquote( path );
// Verify this points to us
if ( GetModuleFileName( NULL, exe, CWF_STRSIZE ) &&
!strcmpi( path, exe ) )
{
ok = TRUE;
} // end if
} // end if
RegCloseKey( hKey );
} // end if
m_bStartup = ok;
} // end check startup
DWORD onclose = 0;
CFG().GetValue( "Settings", "OnCloseAction", &onclose );
m_nAction = onclose;
if ( m_nAction > 2 ) m_nAction = 0;
// Restore settings
m_bTrayIcon = CFG().GetDword( "Settings", "NoMinimizeToTray", 0 ) == 0;
m_bToolbar = CFG().GetDword( "Settings", "RestoreToolbars", 0 ) != 0;
m_bAutoUpdate = CFG().GetDword( "Settings", "AutoUpdateCheck", 1 ) != 0;
UpdateData( FALSE );
return 0;
}
LRESULT CDlgGeneral::OnSave(WPARAM wParam, LPARAM lParam)
{
UpdateData( TRUE );
if ( m_nAction > 2 || m_nAction < 0 ) m_nAction = 0;
CFG().SetValue( "Settings", "OnCloseAction", (DWORD)m_nAction );
if ( CFG().GetDword( "Settings", "AutoUpdateCheck", 1 ) != 0 )
// Minimize to tray
CFG().SetValue( "Settings", "NoMinimizeToTray", (DWORD)( m_bTrayIcon ? 0 : 1 ) );
// Restore toolbars
CFG().SetValue( "Settings", "RestoreToolbars", (DWORD)( m_bToolbar ? 1 : 0 ) );
// Restore toolbars
CFG().SetValue( "Settings", "AutoUpdateCheck", (DWORD)( m_bAutoUpdate ? 1 : 0 ) );
if ( m_bStartup )
{
char path[ CWF_STRSIZE ];
HKEY hKey;
if ( GetModuleFileName( NULL, path, sizeof( path ) ) &&
RegCreateKey( STARTUP_HKEY, STARTUP_SZKEY, &hKey ) == ERROR_SUCCESS )
{
// Put the path in quotes
CWinFile::Quote( path );
// Add to registry
RegSetValueEx( hKey, SHORTCUT_NAME,
0, REG_SZ, (const BYTE *)path, strlen( path ) );
// Close the key
RegCloseKey( hKey );
} // end if
} // end if
// Oh well, remove us from the windows startup files
else
{
HKEY hKey;
if ( RegOpenKeyEx( STARTUP_HKEY, STARTUP_SZKEY,
0, KEY_ALL_ACCESS, &hKey ) == ERROR_SUCCESS )
{
// Attempt to remove our entry
RegDeleteValue( hKey, SHORTCUT_NAME );
RegCloseKey( hKey );
} // end if
} // end else
UpdateData( FALSE );
return 0;
}
void CDlgGeneral::OnAction()
{ CDlgTreeFrame::EnableApply( GetSafeHwnd() );
}
void CDlgGeneral::OnAction2()
{ CDlgTreeFrame::EnableApply( GetSafeHwnd() );
}
void CDlgGeneral::OnAction3()
{ CDlgTreeFrame::EnableApply( GetSafeHwnd() );
}
void CDlgGeneral::OnChangeFramerate()
{ CDlgTreeFrame::EnableApply( GetSafeHwnd() );
}
void CDlgGeneral::OnStartup()
{ CDlgTreeFrame::EnableApply( GetSafeHwnd() );
}
void CDlgGeneral::OnTrayicon()
{ CDlgTreeFrame::EnableApply( GetSafeHwnd() );
}