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
|
#include "plugin.h"
#include "playSnd.h"
#include "resource.h"
#include "optionsdlg.h"
#include <math.h>
#pragma comment(lib, "comctl32.lib")
extern void SetRadioVolume(int value);
extern COLORREF g_clrback;
extern HBRUSH g_HBRback;
extern int g_mRadioMuted;
extern HWND hwndMRadio;
extern HICON hIconMRadio, hIconMRadio_off;
void LoadBackgroundSettings()
{
HWND hwnd;
if(g_HBRback)
DeleteObject(g_HBRback);
if(DBGetContactSettingByte(NULL, SERVICENAME, "def_bg", 1))
g_clrback = GetSysColor(COLOR_3DFACE);
else
g_clrback = DBGetContactSettingDword(NULL, SERVICENAME, "bgc", GetSysColor(COLOR_3DFACE));
g_HBRback = CreateSolidBrush(g_clrback);
hwnd = GetFocus();
InvalidateRect(hwndSlider, NULL, TRUE);
SetFocus(hwndSlider);
RedrawWindow(hwndFrame, NULL, NULL, RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_ERASE);
SetFocus(hwnd);
}
LRESULT CALLBACK GroupWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch( uMsg )
{
case WM_LBUTTONDOWN:
::MessageBox(0,_T("LB"),_T(""),0);
return 0;
case WM_PAINT:
{
CallWindowProc((WNDPROC)GetWindowLong(hwnd, GWL_USERDATA), hwnd, uMsg, wParam, lParam);
HDC hdc = GetDC(hwnd);
RECT rc;
TCHAR szTitle[256];
HFONT oldfont;
int oldBk;
ZeroMemory(&rc, sizeof(rc));
// Determine a size of the text
oldBk = SetBkMode(hdc, TRANSPARENT);
oldfont = (HFONT)SelectObject(hdc, (HFONT)SendMessage(hwnd, WM_GETFONT, 0,0));
SetBkMode(hdc, TRANSPARENT);
GetWindowText(hwnd, szTitle, sizeof(szTitle) / sizeof(TCHAR));
DrawText(hdc, szTitle, lstrlen(szTitle), &rc, DT_SINGLELINE|DT_CALCRECT);
rc.left += 8; rc.right += 8 + 16 + 4;
FillRect(hdc, &rc, (HBRUSH) (COLOR_BTNFACE+1));
DrawIconEx(hdc, rc.left+2, rc.top, hSoundOn, 16,16, 0, NULL, DI_NORMAL);
rc.left += 2 + 16 + 2;
//rc.right += 2 + 16 + 2;
DrawText(hdc, szTitle, lstrlen(szTitle), &rc, DT_SINGLELINE|DT_WORD_ELLIPSIS);
SetBkMode(hdc, oldBk);
SelectObject(hdc, oldfont);
ReleaseDC(hwnd, hdc);
return 0;
}
}
return CallWindowProc((WNDPROC)GetWindowLong(hwnd, GWL_USERDATA), hwnd, uMsg, wParam, lParam);
}
LRESULT CALLBACK OptionsDlgProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
switch( uMsg ) {
case WM_INITDIALOG:
{
HWND grp = GetDlgItem(hwndDlg, IDC_GRP);
TranslateDialogDefault(hwndDlg);
CheckDlgButton(hwndDlg, IDC_AUTO, DBGetContactSettingByte(NULL,SERVICENAME,"AutoPreview", TRUE)?BST_CHECKED:BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_MUTE, DBGetContactSettingByte(NULL,SERVICENAME,"MuteBtn", TRUE)?BST_CHECKED:BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_MRADIO, DBGetContactSettingByte(NULL, SERVICENAME, "mRadioAdjust", 0) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_MUTERADIO, DBGetContactSettingByte(NULL, SERVICENAME, "mRadioMute", 0) ? BST_CHECKED : BST_UNCHECKED);
EnableWindow(GetDlgItem(hwndDlg, IDC_MRADIO), ServiceExists(MS_RADIO_SETVOL));
EnableWindow(GetDlgItem(hwndDlg, IDC_MUTERADIO), ServiceExists(MS_RADIO_SETVOL));
hwndOptSlider = GetDlgItem(hwndDlg, IDC_VOLUME);
SendDlgItemMessage(hwndDlg, IDC_VOLUME, TBM_SETRANGE, FALSE, MAKELONG(SLIDER_MIN,SLIDER_MAX));
SendDlgItemMessage(hwndDlg, IDC_VOLUME, TBM_SETPOS, TRUE, DBGetContactSettingDword(NULL,SERVICENAME,"Volume",100));
SetWindowLong(grp, GWL_USERDATA, GetWindowLong(grp, GWL_WNDPROC));
SetWindowLong(grp, GWL_WNDPROC, (LONG)GroupWndProc);
SendDlgItemMessage(hwndDlg, IDC_BACKCOLOR, CPM_SETCOLOUR, 0, (LPARAM)DBGetContactSettingDword(NULL, SERVICENAME, "bgc", GetSysColor(COLOR_3DFACE)));
EnableWindow(GetDlgItem(hwndDlg, IDC_BACKCOLOR), DBGetContactSettingByte(NULL, SERVICENAME, "def_bg", 1) ? FALSE : TRUE);
CheckDlgButton(hwndDlg, IDC_DEFCOLOR, DBGetContactSettingByte(NULL, SERVICENAME, "def_bg", 1));
return TRUE;
}
case WM_HSCROLL:
{
int value = (DWORD)SendDlgItemMessage(hwndDlg, IDC_VOLUME, TBM_GETPOS, 0, 0);
if(hwndSlider)
SendMessage(hwndSlider, TBM_SETPOS, TRUE, value);
else
DBWriteContactSettingDword(NULL, SERVICENAME, "Volume", value);
playSnd::SetVolume(value);
if(IsDlgButtonChecked(hwndDlg, IDC_AUTO))
SkinPlaySound("AlertMsg");
SetRadioVolume(value);
break;
}
case WM_COMMAND:
if(LOWORD(wParam) == IDC_TEST) {
playSnd::SetVolume((DWORD)SendDlgItemMessage(hwndDlg, IDC_VOLUME, TBM_GETPOS, 0, 0));
SkinPlaySound("AlertMsg");
return FALSE;
}
else if(LOWORD(wParam) == IDC_MRADIO) {
DBWriteContactSettingByte(NULL, SERVICENAME, "mRadioAdjust", IsDlgButtonChecked(hwndDlg, IDC_MRADIO) ? 1 : 0);
if(IsDlgButtonChecked(hwndDlg, IDC_MRADIO) && ServiceExists(MS_RADIO_SETVOL)) {
int value = (DWORD)SendDlgItemMessage(hwndDlg, IDC_VOLUME, TBM_GETPOS, 0, 0);
CallService(MS_RADIO_SETVOL, (WPARAM)value, 0);
}
}
else if(LOWORD(wParam) == IDC_MUTERADIO) {
int useSound = DBGetContactSettingByte(NULL, "Skin", "UseSound", 1);
int value;
DBWriteContactSettingByte(NULL, SERVICENAME, "mRadioMute", IsDlgButtonChecked(hwndDlg, IDC_MUTERADIO) ? 1 : 0);
if(ServiceExists(MS_RADIO_SETVOL)) {
if(IsDlgButtonChecked(hwndDlg, IDC_MUTERADIO))
g_mRadioMuted = !useSound;
value = g_mRadioMuted ? 0 : (int)SendMessage(hwndSlider, TBM_GETPOS, 0, 0);
CallService(MS_RADIO_SETVOL, (WPARAM)value, 0);
DBWriteContactSettingByte(NULL, "mRadio", "Volume", (BYTE)value);
SendMessage(hwndMRadio, BM_SETIMAGE,IMAGE_ICON,(LPARAM)(g_mRadioMuted ? hIconMRadio_off : hIconMRadio));
}
}
else if(LOWORD(wParam) == IDC_DEFCOLOR) {
DBWriteContactSettingByte(NULL, SERVICENAME, "def_bg", IsDlgButtonChecked(hwndDlg, IDC_DEFCOLOR) ? 1 : 0);
EnableWindow(GetDlgItem(hwndDlg, IDC_BACKCOLOR), DBGetContactSettingByte(NULL, SERVICENAME, "def_bg", 1) ? FALSE : TRUE);
LoadBackgroundSettings();
}
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0,0);
break;
case WM_NOTIFY:
switch(((LPNMHDR)lParam)->code) {
case NM_RELEASEDCAPTURE:
if(IsDlgButtonChecked(hwndDlg, IDC_AUTO) == BST_CHECKED) {
int value = (DWORD)SendDlgItemMessage(hwndDlg, IDC_VOLUME, TBM_GETPOS, 0, 0);
if(hwndSlider)
SendMessage(hwndSlider, TBM_SETPOS, TRUE, value);
playSnd::SetVolume(value);
SkinPlaySound("AlertMsg");
SetRadioVolume(value);
}
break;
case PSN_APPLY:
{
int value = (DWORD)SendDlgItemMessage(hwndDlg, IDC_VOLUME, TBM_GETPOS, 0, 0);
if(hwndSlider)
SendMessage(hwndSlider, TBM_SETPOS, TRUE, value);
playSnd::SetVolume(value);
DBWriteContactSettingDword(NULL, SERVICENAME, "Volume", value);
autoPreview = (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_AUTO) == BST_CHECKED);
DBWriteContactSettingByte(NULL, SERVICENAME, "AutoPreview", autoPreview);
value = (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_MUTE) == BST_CHECKED);
DBWriteContactSettingByte(NULL, SERVICENAME, "MuteBtn", value);
PostMessage(hwndFrame, WM_USER, value, 0);
DBWriteContactSettingDword(NULL, SERVICENAME, "bgc", (DWORD)SendDlgItemMessage(hwndDlg, IDC_BACKCOLOR, CPM_GETCOLOUR, 0, 0));
LoadBackgroundSettings();
return TRUE;
}
case PSN_RESET:
{
int value = DBGetContactSettingDword(NULL,SERVICENAME,"Volume",100);
SendDlgItemMessage(hwndDlg, IDC_VOLUME, TBM_SETPOS, TRUE, value);
if(hwndSlider)
SendMessage(hwndSlider, TBM_SETPOS, TRUE, value);
playSnd::SetVolume(value);
return TRUE;
}
}
break;
case WM_DESTROY:
hwndOptSlider = NULL;
return FALSE;
}
return FALSE;
}
|