summaryrefslogtreecommitdiff
path: root/plugins/FileAsMessage/optionsdlg.cpp
blob: da605d0f32ab059fb4ff5f37ae75e9e7c1aafbb6 (plain)
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
#include "main.h"

DWORD settingDefault[] =
{
	RGB(64,255,64),
	RGB(255,255,64),
	RGB(128,128,128),
	RGB(192,192,192),

	6000,
	5000
};
char *settingName[] =
{
	"colorRecv",
	"colorSent",
	"colorUnsent",
	"colorTosend",

	"SendDelay",
	"ChunkSize"
};
int settingId[] =
{
	IDC_RECV,
	IDC_SENT,
	IDC_UNSENT,
	IDC_TOSEND,

	-IDC_SENDDELAY,
	-IDC_CHUNKSIZE
};
//
// OptionsDlgProc()
// this handles the options page
// verwaltet die Optionsseite
//
LRESULT CALLBACK OptionsDlgProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
	switch( uMsg )
	{
		case WM_INITDIALOG:
		{	
			TranslateDialogDefault(hwndDlg);
			
			for(int indx = 0; indx < SIZEOF(settingId); indx++)
				if(settingId[indx] > 0)
					SendDlgItemMessage(hwndDlg, settingId[indx], CPM_SETCOLOUR, 0, DBGetContactSettingDword(NULL, SERVICE_NAME, settingName[indx], settingDefault[indx]));
				else
					SetDlgItemInt(hwndDlg, -settingId[indx], DBGetContactSettingDword(NULL, SERVICE_NAME, settingName[indx], settingDefault[indx]), FALSE);

			CheckDlgButton(hwndDlg, IDC_ALPHANUM, DBGetContactSettingDword(NULL, SERVICE_NAME, "base64", 1)?BST_CHECKED:BST_UNCHECKED);

			return TRUE;

		}
		case WM_COMMAND:
		{
			if(//MAKEWPARAM(IDC_AUTO, BN_CLICKED) != wParam || 
			   MAKEWPARAM(IDC_ALPHANUM, BN_CLICKED) != wParam)
			{	
				for(int indx = 0; indx < SIZEOF(settingId); indx++)
				{
					if(LOWORD(wParam) == abs(settingId[indx]))
					{
						if(settingId[indx] > 0)
						{
							if(HIWORD(wParam) != CPN_COLOURCHANGED) return FALSE;
						}
						else
						{
							if(HIWORD(wParam) != EN_CHANGE) return FALSE;
							if((HWND)lParam != GetFocus()) return FALSE;
						}
					}
				}
			}
			SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0,0);
			break;
		}
		case WM_DESTROY:
			return FALSE;

		case WM_NOTIFY:
		{
			if((((NMHDR*)lParam)->idFrom == 0) && (((LPNMHDR)lParam)->code == PSN_APPLY))
			{
				int value;
				BOOL succ;
				
				for(int indx = 0; indx < SIZEOF(settingId); indx++)
				{
					if(settingId[indx] > 0)
						value = SendDlgItemMessage(hwndDlg, settingId[indx], CPM_GETCOLOUR, 0, 0);
					else
					{
						value = GetDlgItemInt(hwndDlg, -settingId[indx], &succ, FALSE);
						if(!succ) value = settingDefault[indx];
					}
					DBWriteContactSettingDword(NULL,SERVICE_NAME,settingName[indx], value);
				}
				DBWriteContactSettingDword(NULL,SERVICE_NAME, "base64", (IsDlgButtonChecked(hwndDlg, IDC_ALPHANUM) == BST_CHECKED)?1:0);

				return TRUE;
			}
			break;
		}

	}

	return FALSE;
}