summaryrefslogtreecommitdiff
path: root/plugins/RecentContacts/src/options.cpp
blob: d8f733a3fa1c5aed77cee9105e2c3293f7e29e98 (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
#include "stdafx.h"

extern HINSTANCE hInst;
void LoadDBSettings();

INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	char str[32];

	switch (msg) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hwndDlg);
		CheckDlgButton(hwndDlg, IDC_HIDEOFFLINE, (LastUCOpt.HideOffline ? BST_CHECKED : BST_UNCHECKED));
		CheckDlgButton(hwndDlg, IDC_WINDOWAUTOSIZE, (LastUCOpt.WindowAutoSize ? BST_CHECKED : BST_UNCHECKED));

		mir_snprintf(str, "%d", LastUCOpt.MaxShownContacts);
		SetDlgItemTextA(hwndDlg, IDC_SHOWNCONTACTS, str);

		strncpy_s(str, LastUCOpt.DateTimeFormat.c_str(), _TRUNCATE);
		SetDlgItemTextA(hwndDlg, IDC_DATETIME, str);

		SetWindowLongPtr(hwndDlg,GWLP_USERDATA,lParam);
		return TRUE;

	case WM_COMMAND:
		switch(HIWORD(wParam)) {
		case EN_CHANGE:
		case BN_CLICKED:
		case CBN_EDITCHANGE:
		case CBN_SELCHANGE:
			SendMessage(GetParent(hwndDlg),PSM_CHANGED,0,0);
		}
		break;

	case WM_NOTIFY:
		{
			LPNMHDR phdr = (LPNMHDR)(lParam);
			if (phdr->idFrom == 0 && phdr->code == PSN_APPLY) {
				BOOL bSuccess = FALSE;

				LastUCOpt.HideOffline = (BOOL)IsDlgButtonChecked(hwndDlg, IDC_HIDEOFFLINE);
				db_set_b(NULL, dbLastUC_ModuleName, dbLastUC_HideOfflineContacts, (BYTE)LastUCOpt.HideOffline);

				LastUCOpt.WindowAutoSize = (BOOL)IsDlgButtonChecked(hwndDlg, IDC_WINDOWAUTOSIZE);
				db_set_b(NULL, dbLastUC_ModuleName, dbLastUC_WindowAutosize, (BYTE)LastUCOpt.WindowAutoSize);

				GetDlgItemTextA(hwndDlg, IDC_SHOWNCONTACTS, str, _countof(str));
				LastUCOpt.MaxShownContacts= atoi(str);
				db_set_b(0,dbLastUC_ModuleName, dbLastUC_MaxShownContacts, LastUCOpt.MaxShownContacts);

				GetDlgItemTextA(hwndDlg, IDC_DATETIME, str, _countof(str));
				db_set_s(0,dbLastUC_ModuleName, dbLastUC_DateTimeFormat, str );

				LoadDBSettings();
				return TRUE;
			}
			break;
		}
	}
	return FALSE;
}

int onOptInitialise(WPARAM wParam, LPARAM lParam)
{
	OPTIONSDIALOGPAGE odp = { 0 };
	odp.hInstance = hInst;
	odp.pszGroup = LPGEN("Contacts");
	odp.pszTemplate = MAKEINTRESOURCEA(IDD_LASTUC_OPT);
	odp.pszTitle = msLastUC_ShowListName;
	odp.pfnDlgProc = DlgProcOptions;
	odp.flags = ODPF_BOLDGROUPS;
	Options_AddPage(wParam, &odp);
	return 0;
}