Menu

[r176]: / trunk / src / OptionsDlg.cpp  Maximize  Restore  History

Download this file

156 lines (144 with data), 6.0 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
#include "StdAfx.h"
#include "Resource.h"
#include "OptionsDlg.h"
#include "Registry.h"
#include <string>
#include <Commdlg.h>
using namespace std;
COptionsDlg::COptionsDlg(HWND hParent)
{
m_hParent = hParent;
}
COptionsDlg::~COptionsDlg(void)
{
}
LRESULT COptionsDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
UNREFERENCED_PARAMETER(lParam);
switch (uMsg)
{
case WM_INITDIALOG:
{
InitDialog(hwndDlg, IDI_COMMITMONITOR);
AddToolTip(IDC_AUTOSTART, _T("Starts the CommitMonitor automatically when Windows starts up."));
AddToolTip(IDC_TASKBAR_ALWAYSON, _T("If disabled, the taskbar icon is only shown if new commits are available.\nThe CommitMonitor can be shown by 'starting' it again."));
AddToolTip(IDC_DIFFVIEWER, _T("Path to a viewer for unified diff files."));
AddToolTip(IDC_DIFFVIEWERLABEL, _T("Path to a viewer for unified diff files."));
AddToolTip(IDC_ANIMATEICON, _T("Animates the system tray icon as long as there are unread commits"));
// initialize the controls
bool bShowTaskbarIcon = !!(DWORD)CRegStdWORD(_T("Software\\CommitMonitor\\TaskBarIcon"), FALSE);
bool bStartWithWindows = !wstring(CRegStdString(_T("Software\\Microsoft\\Windows\\CurrentVersion\\Run\\CommitMonitor"))).empty();
bool bAnimateIcon = !!CRegStdWORD(_T("Software\\CommitMonitor\\Animate"), TRUE);
bool bPlaySound = !!CRegStdWORD(_T("Software\\CommitMonitor\\PlaySound"), TRUE);
CRegStdString diffViewer = CRegStdString(_T("Software\\CommitMonitor\\DiffViewer"));
CRegStdString notifySound = CRegStdString(_T("Software\\CommitMonitor\\NotificationSound"));
SendMessage(GetDlgItem(*this, IDC_TASKBAR_ALWAYSON), BM_SETCHECK, bShowTaskbarIcon ? BST_CHECKED : BST_UNCHECKED, NULL);
SendMessage(GetDlgItem(*this, IDC_AUTOSTART), BM_SETCHECK, bStartWithWindows ? BST_CHECKED : BST_UNCHECKED, NULL);
SendMessage(GetDlgItem(*this, IDC_ANIMATEICON), BM_SETCHECK, bAnimateIcon ? BST_CHECKED : BST_UNCHECKED, NULL);
SetWindowText(GetDlgItem(*this, IDC_DIFFVIEWER), wstring(diffViewer).c_str());
SetWindowText(GetDlgItem(*this, IDC_NOTIFICATIONSOUNDPATH), wstring(notifySound).c_str());
SendMessage(GetDlgItem(*this, IDC_NOTIFICATIONSOUND), BM_SETCHECK, bPlaySound ? BST_CHECKED : BST_UNCHECKED, NULL);
}
return TRUE;
case WM_COMMAND:
return DoCommand(LOWORD(wParam));
default:
return FALSE;
}
}
LRESULT COptionsDlg::DoCommand(int id)
{
switch (id)
{
case IDOK:
{
CRegStdWORD regShowTaskbarIcon = CRegStdWORD(_T("Software\\CommitMonitor\\TaskBarIcon"), FALSE);
CRegStdString regStartWithWindows = CRegStdString(_T("Software\\Microsoft\\Windows\\CurrentVersion\\Run\\CommitMonitor"));
CRegStdWORD regAnimateIcon = CRegStdWORD(_T("Software\\CommitMonitor\\Animate"), TRUE);
CRegStdWORD regPlaySound = CRegStdWORD(_T("Software\\CommitMonitor\\PlaySound"), TRUE);
bool bShowTaskbarIcon = !!SendMessage(GetDlgItem(*this, IDC_TASKBAR_ALWAYSON), BM_GETCHECK, 0, NULL);
bool bStartWithWindows = !!SendMessage(GetDlgItem(*this, IDC_AUTOSTART), BM_GETCHECK, 0, NULL);
bool bAnimateIcon = !!SendMessage(GetDlgItem(*this, IDC_ANIMATEICON), BM_GETCHECK, 0, NULL);
bool bPlaySound = !!SendMessage(GetDlgItem(*this, IDC_NOTIFICATIONSOUND), BM_GETCHECK, 0, NULL);
regShowTaskbarIcon = bShowTaskbarIcon;
regAnimateIcon = bAnimateIcon;
regPlaySound = bPlaySound;
::SendMessage(m_hHiddenWnd, COMMITMONITOR_CHANGEDINFO, 0, 0);
if (bStartWithWindows)
{
TCHAR buf[MAX_PATH*4];
GetModuleFileName(NULL, buf, MAX_PATH*4);
wstring cmd = wstring(buf);
cmd += _T(" /hidden");
regStartWithWindows = cmd;
}
else
regStartWithWindows.removeValue();
int len = ::GetWindowTextLength(GetDlgItem(*this, IDC_DIFFVIEWER));
TCHAR * divi = new TCHAR[len+1];
::GetDlgItemText(*this, IDC_DIFFVIEWER, divi, len+1);
wstring dv = wstring(divi);
delete [] divi;
CRegStdString diffViewer = CRegStdString(_T("Software\\CommitMonitor\\DiffViewer"));
if (!dv.empty())
diffViewer = dv;
else
diffViewer.removeValue();
len = ::GetWindowTextLength(GetDlgItem(*this, IDC_NOTIFICATIONSOUNDPATH));
divi = new TCHAR[len+1];
::GetDlgItemText(*this, IDC_NOTIFICATIONSOUNDPATH, divi, len+1);
wstring ns = wstring(divi);
delete [] divi;
CRegStdString notifySound = CRegStdString(_T("Software\\CommitMonitor\\NotificationSound"));
if (!ns.empty())
notifySound = ns;
else
notifySound.removeValue();
}
// fall through
case IDCANCEL:
EndDialog(*this, id);
break;
case IDC_DIFFBROWSE:
{
OPENFILENAME ofn = {0}; // common dialog box structure
TCHAR szFile[MAX_PATH] = {0}; // buffer for file name
// Initialize OPENFILENAME
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = *this;
ofn.lpstrFile = szFile;
ofn.nMaxFile = sizeof(szFile)/sizeof(TCHAR);
ofn.lpstrTitle = _T("Select Diff Viewer...\0");
ofn.Flags = OFN_FILEMUSTEXIST|OFN_HIDEREADONLY|OFN_PATHMUSTEXIST|OFN_DONTADDTORECENT;
ofn.lpstrFilter = _T("Programs\0*.exe;*.com\0All files\0*.*\0\0");
ofn.nFilterIndex = 1;
// Display the Open dialog box.
if (GetOpenFileName(&ofn)==TRUE)
{
SetWindowText(GetDlgItem(*this, IDC_DIFFVIEWER), szFile);
}
}
break;
case IDC_SOUNDBROWSE:
{
OPENFILENAME ofn = {0}; // common dialog box structure
TCHAR szFile[MAX_PATH] = {0}; // buffer for file name
// Initialize OPENFILENAME
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = *this;
ofn.lpstrFile = szFile;
ofn.nMaxFile = sizeof(szFile)/sizeof(TCHAR);
ofn.lpstrTitle = _T("Select Notification Sound...\0");
ofn.Flags = OFN_FILEMUSTEXIST|OFN_HIDEREADONLY|OFN_PATHMUSTEXIST|OFN_DONTADDTORECENT;
ofn.lpstrFilter = _T("Sound Files\0*.wav;*.mp3\0All files\0*.*\0\0");
ofn.nFilterIndex = 1;
// Display the Open dialog box.
if (GetOpenFileName(&ofn)==TRUE)
{
SetWindowText(GetDlgItem(*this, IDC_NOTIFICATIONSOUNDPATH), szFile);
}
}
break;
}
return 1;
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.