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
249
250
|
#include "common.h"
#include "options.h"
Options options;
static BOOL CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
switch ( msg ) {
case WM_INITDIALOG:
TranslateDialogDefault( hwndDlg );
{
// initialise and fill listbox
HWND hwndList = GetDlgItem(hwndDlg, IDC_LST_STATUS);
ListView_DeleteAllItems(hwndList);
SendMessage(hwndList,LVM_SETEXTENDEDLISTVIEWSTYLE, 0,LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES);
LVCOLUMN lvc = {0};
// Initialize the LVCOLUMN structure.
// The mask specifies that the format, width, text, and
// subitem members of the structure are valid.
lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
lvc.fmt = LVCFMT_LEFT;
lvc.iSubItem = 0;
lvc.pszText = TranslateT("Status");
lvc.cx = 120; // width of column in pixels
ListView_InsertColumn(hwndList, 0, &lvc);
LVITEM lvI = {0};
// Some code to create the list-view control.
// Initialize LVITEM members that are common to all
// items.
lvI.mask = LVIF_TEXT;
char *strptr;
wchar_t buff[256];
for(int i = 0; i < 9; i++) {
strptr = (char *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, (WPARAM)(ID_STATUS_ONLINE + i), (LPARAM)0);
MultiByteToWideChar((int)CallService(MS_LANGPACK_GETCODEPAGE, 0, 0), 0, strptr, -1, buff, 256);
lvI.pszText = buff;
lvI.iItem = i;
ListView_InsertItem(hwndList, &lvI);
ListView_SetCheckState(hwndList, i, options.disable_status[i]);
}
}
{
CheckDlgButton(hwndDlg, IDC_CHK_TABS, options.consider_tabs ? TRUE : FALSE);
HWND hwnd = GetDlgItem(hwndDlg, IDC_CHK_TABS);
switch(options.notify_when) {
case NOTIFY_CLOSED:
CheckDlgButton(hwndDlg, IDC_RAD_CLOSED, TRUE);
EnableWindow(hwnd, FALSE);
break;
case NOTIFY_NFORE:
CheckDlgButton(hwndDlg, IDC_RAD_NFORE, TRUE);
EnableWindow(hwnd, TRUE);
break;
case NOTIFY_ALWAYS:
CheckDlgButton(hwndDlg, IDC_RAD_ALWAYS, TRUE);
EnableWindow(hwnd, FALSE);
break;
};
}
CheckDlgButton(hwndDlg, IDC_CHK_CLOSE, options.close_win ? TRUE : FALSE);
if(options.timeout == -1) {
CheckDlgButton(hwndDlg, IDC_CHK_SETTIMEOUT, FALSE);
SetDlgItemInt(hwndDlg, IDC_ED_TIMEOUT, 0, FALSE);
HWND hwnd = GetDlgItem(hwndDlg, IDC_ED_TIMEOUT);
EnableWindow(hwnd, FALSE);
} else {
CheckDlgButton(hwndDlg, IDC_CHK_SETTIMEOUT, TRUE);
SetDlgItemInt(hwndDlg, IDC_ED_TIMEOUT, options.timeout, FALSE);
}
CheckDlgButton(hwndDlg, IDC_CHK_SETCOLOURS, options.set_colours ? TRUE : FALSE);
SendDlgItemMessage(hwndDlg, IDC_CP_BK, CPM_SETCOLOUR, 0, (LPARAM)options.bkCol);
SendDlgItemMessage(hwndDlg, IDC_CP_TXT, CPM_SETCOLOUR, 0, (LPARAM)options.textCol);
if(!options.set_colours) {
CheckDlgButton(hwndDlg, IDC_CHK_SETCOLOURS, FALSE);
HWND hwnd = GetDlgItem(hwndDlg, IDC_CP_BK);
EnableWindow(hwnd, FALSE);
hwnd = GetDlgItem(hwndDlg, IDC_CP_TXT);
EnableWindow(hwnd, FALSE);
}
return FALSE;
case WM_COMMAND:
if(LOWORD(wParam) == IDC_CP_BK || LOWORD(wParam) == IDC_CP_TXT) {
SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
break;
}
if ( HIWORD( wParam ) == EN_CHANGE && ( HWND )lParam == GetFocus()) {
switch( LOWORD( wParam )) {
case IDC_ED_TIMEOUT:
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
break;
}
if ( HIWORD( wParam ) == BN_CLICKED ) {
switch( LOWORD( wParam )) {
case IDC_RAD_CLOSED:
case IDC_RAD_ALWAYS:
{
HWND hwnd = GetDlgItem(hwndDlg, IDC_CHK_TABS);
EnableWindow(hwnd, FALSE);
}
SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
return TRUE;
case IDC_RAD_NFORE:
{
HWND hwnd = GetDlgItem(hwndDlg, IDC_CHK_TABS);
EnableWindow(hwnd, TRUE);
}
SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
return TRUE;
case IDC_CHK_SETTIMEOUT:
{
HWND hwnd = GetDlgItem(hwndDlg, IDC_ED_TIMEOUT);
EnableWindow(hwnd, IsDlgButtonChecked(hwndDlg, IDC_CHK_SETTIMEOUT));
}
SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
return TRUE;
case IDC_CHK_SETCOLOURS:
{
HWND hwnd = GetDlgItem(hwndDlg, IDC_CP_BK);
EnableWindow(hwnd, IsDlgButtonChecked(hwndDlg, IDC_CHK_SETCOLOURS));
hwnd = GetDlgItem(hwndDlg, IDC_CP_TXT);
EnableWindow(hwnd, IsDlgButtonChecked(hwndDlg, IDC_CHK_SETCOLOURS));
}
SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
return TRUE;
case IDC_CHK_CLOSE:
case IDC_CHK_TABS:
SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
return TRUE;
}
}
break;
case WM_NOTIFY:
if(IsWindowVisible(hwndDlg) && ((LPNMHDR) lParam)->hwndFrom == GetDlgItem(hwndDlg, IDC_LST_STATUS)) {
switch (((LPNMHDR) lParam)->code) {
case LVN_ITEMCHANGED:
{
NMLISTVIEW *nmlv = (NMLISTVIEW *)lParam;
if((nmlv->uNewState ^ nmlv->uOldState) & LVIS_STATEIMAGEMASK) {
SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
}
}
break;
}
} else
if (((LPNMHDR)lParam)->code == (DWORD)PSN_APPLY ) {
options.consider_tabs = IsDlgButtonChecked(hwndDlg, IDC_CHK_TABS) ? true : false;
if(IsDlgButtonChecked(hwndDlg, IDC_RAD_CLOSED))
options.notify_when = NOTIFY_CLOSED;
else if(IsDlgButtonChecked(hwndDlg, IDC_RAD_NFORE))
options.notify_when = NOTIFY_NFORE;
else
options.notify_when = NOTIFY_ALWAYS;
options.close_win = IsDlgButtonChecked(hwndDlg, IDC_CHK_CLOSE) ? true : false;
if(IsDlgButtonChecked(hwndDlg, IDC_CHK_SETTIMEOUT)) {
BOOL trans;
int t = GetDlgItemInt(hwndDlg, IDC_ED_TIMEOUT, &trans, FALSE);
if(trans) options.timeout = t;
} else
options.timeout = -1;
options.set_colours = IsDlgButtonChecked(hwndDlg, IDC_CHK_SETCOLOURS) ? true : false;
options.bkCol = (COLORREF)SendDlgItemMessage(hwndDlg, IDC_CP_BK, CPM_GETCOLOUR, 0, 0);
options.textCol = (COLORREF)SendDlgItemMessage(hwndDlg, IDC_CP_TXT, CPM_GETCOLOUR, 0, 0);
for(int i = 0; i < 9; i++)
options.disable_status[i] = (ListView_GetCheckState(GetDlgItem(hwndDlg, IDC_LST_STATUS), i) ? true : false);
SaveOptions();
if(options.notify_when == NOTIFY_NFORE)
StartFocusTimer();
else
StopFocusTimer();
return TRUE;
}
break;
case WM_DESTROY:
break;
}
return FALSE;
}
int OptInit(WPARAM wParam,LPARAM lParam)
{
OPTIONSDIALOGPAGE odp = { 0 };
#define OPTIONPAGE_OLD_SIZE2 60
//odp.cbSize = sizeof(odp);
odp.cbSize = OPTIONPAGE_OLD_SIZE2;
odp.position = -790000000;
odp.hInstance = hInst;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS);
odp.pszTitle = Translate(MODULE);
odp.pszGroup = Translate("Popups");
odp.flags = ODPF_BOLDGROUPS;
odp.nIDBottomSimpleControl = 0;
odp.pfnDlgProc = DlgProcOpts;
CallService( MS_OPT_ADDPAGE, wParam,( LPARAM )&odp );
return 0;
}
void LoadOptions() {
options.notify_when = DBGetContactSettingByte(0, MODULE, "NotifyWhen", NOTIFY_NFORE);
options.timeout = (int)DBGetContactSettingDword(0, MODULE, "Timeout", 5);
options.set_colours = (DBGetContactSettingByte(0, MODULE, "SetColours", 0) == 1);
options.bkCol = (COLORREF)DBGetContactSettingDword(0, MODULE, "BkColour", (DWORD)0xFFFFFF);
options.textCol = (COLORREF)DBGetContactSettingDword(0, MODULE, "TextColour", (DWORD)0x000000);
options.consider_tabs = (DBGetContactSettingByte(0, MODULE, "ConsiderTabs", 1) == 1);
options.close_win = (DBGetContactSettingByte(0, MODULE, "CloseWin", 0) == 1);
char buff[128];
for(int i = 0; i < 9; i++) {
sprintf(buff, "DisableStatus%d", i);
options.disable_status[i] = (DBGetContactSettingByte(0, MODULE, buff, 0) == 1);
}
}
void SaveOptions() {
DBWriteContactSettingByte(0, MODULE, "NotifyWhen", options.notify_when);
DBWriteContactSettingDword(0, MODULE, "Timeout", (DWORD)options.timeout);
DBWriteContactSettingByte(0, MODULE, "SetColours", options.set_colours ? 1 : 0);
DBWriteContactSettingDword(0, MODULE, "BkColour", (DWORD)options.bkCol);
DBWriteContactSettingDword(0, MODULE, "TextColour", (DWORD)options.textCol);
DBWriteContactSettingByte(0, MODULE, "ConsiderTabs", options.consider_tabs ? 1 : 0);
DBWriteContactSettingByte(0, MODULE, "CloseWin", options.close_win ? 1 : 0);
char buff[128];
for(int i = 0; i < 9; i++) {
sprintf(buff, "DisableStatus%d", i);
DBWriteContactSettingByte(0, MODULE, buff, options.disable_status[i] ? 1 : 0);
}
}
|