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
|
#include "stdafx.h"
TOptions Options = {
true,
cDefaultSnapWidth,
false
};
INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
TCHAR str[64];
switch (msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
CheckDlgButton(hwndDlg, IDC_CHK_SNAP, Options.DoSnap ? BST_CHECKED : BST_UNCHECKED);
SendDlgItemMessage(hwndDlg, IDC_SLIDER_SNAPWIDTH, TBM_SETRANGE, FALSE, MAKELONG(1, 32));
SendDlgItemMessage(hwndDlg, IDC_SLIDER_SNAPWIDTH, TBM_SETPOS, TRUE, Options.SnapWidth);
mir_snwprintf(str, TranslateT("%d pix"), Options.SnapWidth);
SetDlgItemText(hwndDlg, IDC_TXT_SNAPWIDTH, str);
EnableWindow(GetDlgItem(hwndDlg, IDC_SLIDER_SNAPWIDTH), Options.DoSnap);
EnableWindow(GetDlgItem(hwndDlg, IDC_TXT_SNAPWIDTH), Options.DoSnap);
CheckDlgButton(hwndDlg, IDC_CHK_SCRIVERWORKAROUND, Options.ScriverWorkAround ? BST_CHECKED : BST_UNCHECKED);
break;
case WM_HSCROLL:
mir_snwprintf(str, TranslateT("%d pix"), SendDlgItemMessage(hwndDlg, IDC_SLIDER_SNAPWIDTH, TBM_GETPOS, 0, 0));
SetDlgItemText(hwndDlg, IDC_TXT_SNAPWIDTH, str);
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDC_CHK_SNAP:
if (HIWORD(wParam) == BN_CLICKED) {
EnableWindow(GetDlgItem(hwndDlg, IDC_SLIDER_SNAPWIDTH), IsDlgButtonChecked(hwndDlg, IDC_CHK_SNAP));
EnableWindow(GetDlgItem(hwndDlg, IDC_TXT_SNAPWIDTH), IsDlgButtonChecked(hwndDlg, IDC_CHK_SNAP));
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
break;
case IDC_CHK_SCRIVERWORKAROUND:
if (HIWORD(wParam) == BN_CLICKED)
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
}
break;
case WM_NOTIFY: //Here we have pressed either the OK or the APPLY button.
switch (((LPNMHDR)lParam)->idFrom) {
case 0:
switch (((LPNMHDR)lParam)->code) {
case PSN_RESET:
LoadOptions();
break;
case PSN_APPLY:
Options.DoSnap = (IsDlgButtonChecked(hwndDlg, IDC_CHK_SNAP) == TRUE);
Options.SnapWidth = SendDlgItemMessage(hwndDlg, IDC_SLIDER_SNAPWIDTH, TBM_GETPOS, 0, 0);
Options.ScriverWorkAround = (IsDlgButtonChecked(hwndDlg, IDC_CHK_SCRIVERWORKAROUND) == TRUE);
db_set_b(NULL, MODULENAME, "DoSnap", Options.DoSnap);
db_set_b(NULL, MODULENAME, "SnapWidth", Options.SnapWidth);
db_set_b(NULL, MODULENAME, "ScriverWorkAround", Options.ScriverWorkAround);
break;
}
}
break;
}
return 0;
}
int InitOptions(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE Opt = { sizeof(Opt) };
Opt.pfnDlgProc = OptionsDlgProc;
Opt.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_MAGNETICWINDOWS);
Opt.hInstance = g_plugin.getInst();
Opt.szGroup.a = LPGEN("Customize");
Opt.szTitle.a = LPGEN("Magnetic Windows");
Opt.flags = ODPF_BOLDGROUPS;
g_plugin.addOptions(wParam, &Opt);
return 0;
}
void LoadOptions()
{
Options.DoSnap = db_get_b(NULL, MODULENAME, "DoSnap", 1) != 0;
Options.SnapWidth = db_get_b(NULL, MODULENAME, "SnapWidth", cDefaultSnapWidth);
Options.ScriverWorkAround = db_get_b(NULL, MODULENAME, "ScriverWorkAround", 0) != 0;
}
|