Example #1
0
INT_PTR CALLBACK AdvOptDlg(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	static bool inFocus = false;

	switch (msg) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hwndDlg);
		{
			g_fOptionsOpen = true;

			minutes = db_get_b(NULL, MOD_NAME, "time", 10);
			TCHAR szMinutes[4] = { 0 };
			_itot(minutes, szMinutes, 10);
			SendDlgItemMessage(hwndDlg, IDC_MAINOPT_TIME, EM_LIMITTEXT, 2, 0);
			SendDlgItemMessage(hwndDlg, IDC_MAINOPT_SPIN_TIME, UDM_SETRANGE32, 1, (LPARAM)99);
			SetDlgItemText(hwndDlg, IDC_MAINOPT_TIME, szMinutes);
			CheckDlgButton(hwndDlg, IDC_MAINOPT_HIDEIFLOCK, (g_wMaskAdv & OPT_HIDEIFLOCK) ? BST_CHECKED : BST_UNCHECKED);
			CheckDlgButton(hwndDlg, IDC_MAINOPT_MENUITEM, (g_wMaskAdv & OPT_MENUITEM) ? BST_CHECKED : BST_UNCHECKED);
			CheckDlgButton(hwndDlg, IDC_MAINOPT_HIDEIFWINIDLE, (g_wMaskAdv & OPT_HIDEIFWINIDLE) ? BST_CHECKED : BST_UNCHECKED);
			CheckDlgButton(hwndDlg, IDC_MAINOPT_HIDEIFMIRIDLE, (g_wMaskAdv & OPT_HIDEIFMIRIDLE) ? BST_CHECKED : BST_UNCHECKED);
			CheckDlgButton(hwndDlg, IDC_MAINOPT_HIDEIFSCRSVR, (g_wMaskAdv & OPT_HIDEIFSCRSVR) ? BST_CHECKED : BST_UNCHECKED);
			CheckDlgButton(hwndDlg, IDC_MAINOPT_HIDEONSTART, (g_wMaskAdv & OPT_HIDEONSTART) ? BST_CHECKED : BST_UNCHECKED);
			CheckDlgButton(hwndDlg, IDC_MAINOPT_RESTORE, (g_wMaskAdv & OPT_RESTORE) ? BST_CHECKED : BST_UNCHECKED);
		}
		return true;

	case WM_NOTIFY:
	{
		NMHDR* nmhdr = (NMHDR*)lParam;
		switch (nmhdr->code) {
		case PSN_APPLY:
			WORD wMaskAdv = 0;
			if (IsDlgButtonChecked(hwndDlg, IDC_MAINOPT_HIDEIFLOCK) == BST_CHECKED)		wMaskAdv |= OPT_HIDEIFLOCK;
			if (IsDlgButtonChecked(hwndDlg, IDC_MAINOPT_HIDEIFWINIDLE) == BST_CHECKED)	wMaskAdv |= OPT_HIDEIFWINIDLE;
			if (IsDlgButtonChecked(hwndDlg, IDC_MAINOPT_HIDEIFMIRIDLE) == BST_CHECKED)	wMaskAdv |= OPT_HIDEIFMIRIDLE;
			if (IsDlgButtonChecked(hwndDlg, IDC_MAINOPT_HIDEIFSCRSVR) == BST_CHECKED)	wMaskAdv |= OPT_HIDEIFSCRSVR;
			if (IsDlgButtonChecked(hwndDlg, IDC_MAINOPT_HIDEONSTART) == BST_CHECKED)		wMaskAdv |= OPT_HIDEONSTART;
			if (IsDlgButtonChecked(hwndDlg, IDC_MAINOPT_RESTORE) == BST_CHECKED)			wMaskAdv |= OPT_RESTORE;

			if (IsDlgButtonChecked(hwndDlg, IDC_MAINOPT_MENUITEM) == BST_CHECKED) {
				if (g_hMenuItem == 0)
					BossKeyMenuItemInit();
				wMaskAdv |= OPT_MENUITEM;
			}
			else if (g_hMenuItem != 0)
				BossKeyMenuItemUnInit();

			TCHAR szMinutes[4] = { 0 };
			GetDlgItemText(hwndDlg, IDC_MAINOPT_TIME, szMinutes, _countof(szMinutes));
			minutes = _ttoi(szMinutes);
			if (minutes < 1) minutes = 1;
			db_set_b(NULL, MOD_NAME, "time", minutes);
			db_set_w(NULL, MOD_NAME, "optsmaskadv", wMaskAdv);
			g_wMaskAdv = wMaskAdv;
			return true;
		}
	}
	break;

	case WM_COMMAND:
		switch (HIWORD(wParam)) {
		case BN_CLICKED:
			switch (LOWORD(wParam)) {
			case IDC_MAINOPT_MENUITEM:
			case IDC_MAINOPT_HIDEIFLOCK:
			case IDC_MAINOPT_HIDEIFSCRSVR:
			case IDC_MAINOPT_HIDEONSTART:
			case IDC_MAINOPT_RESTORE:
				SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0);
				return true;

			case IDC_MAINOPT_HIDEIFWINIDLE:
				if (IsDlgButtonChecked(hwndDlg, IDC_MAINOPT_HIDEIFWINIDLE) == BST_CHECKED)
					CheckDlgButton(hwndDlg, IDC_MAINOPT_HIDEIFMIRIDLE, BST_UNCHECKED);
				SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0);
				return true;

			case IDC_MAINOPT_HIDEIFMIRIDLE:
				if (IsDlgButtonChecked(hwndDlg, IDC_MAINOPT_HIDEIFMIRIDLE) == BST_CHECKED)
					CheckDlgButton(hwndDlg, IDC_MAINOPT_HIDEIFWINIDLE, BST_UNCHECKED);
				SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0);
				return true;
			}
			return 0;

		case EN_SETFOCUS:
			inFocus = true;
			return 0;

		case EN_UPDATE:
			switch (LOWORD(wParam)) {
			case IDC_MAINOPT_TIME:
				if (inFocus)
					SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0);
			}
			break;
		}
		break;

	case WM_DESTROY:
		g_fOptionsOpen = false;
		return 0;
	}
	return false;
}
Example #2
0
INT_PTR CALLBACK AdvOptDlg(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam)
{
	static bool inFocus = false;

	switch (msg)
	{
		case WM_INITDIALOG:
		{
			TranslateDialogDefault(hwndDlg);

			g_fOptionsOpen = true;

			minutes = DBGetContactSettingByte(NULL,MOD_NAME,"time",10);
			char szMinutes[4] = {0};
			_itoa(minutes, szMinutes, 10);
			SendDlgItemMessage(hwndDlg,IDC_MAINOPT_TIME,EM_LIMITTEXT,2,0);
			SendDlgItemMessage(hwndDlg, IDC_MAINOPT_SPIN_TIME, UDM_SETRANGE32, (WPARAM)1, (LPARAM)99);
			SetDlgItemTextA(hwndDlg, IDC_MAINOPT_TIME, szMinutes);			
			CheckDlgButton(hwndDlg,IDC_MAINOPT_HIDEIFLOCK,(g_wMaskAdv & OPT_HIDEIFLOCK) ? (BST_CHECKED) : (BST_UNCHECKED));
			CheckDlgButton(hwndDlg,IDC_MAINOPT_MENUITEM,(g_wMaskAdv & OPT_MENUITEM) ? (BST_CHECKED) : (BST_UNCHECKED));
			CheckDlgButton(hwndDlg,IDC_MAINOPT_HIDEIFWINIDLE,(g_wMaskAdv & OPT_HIDEIFWINIDLE) ? (BST_CHECKED) : (BST_UNCHECKED));
			CheckDlgButton(hwndDlg,IDC_MAINOPT_HIDEIFMIRIDLE,(g_wMaskAdv & OPT_HIDEIFMIRIDLE) ? (BST_CHECKED) : (BST_UNCHECKED));
			CheckDlgButton(hwndDlg,IDC_MAINOPT_HIDEIFSCRSVR,(g_wMaskAdv & OPT_HIDEIFSCRSVR) ? (BST_CHECKED) : (BST_UNCHECKED));
			CheckDlgButton(hwndDlg,IDC_MAINOPT_HIDEONSTART,(g_wMaskAdv & OPT_HIDEONSTART) ? (BST_CHECKED) : (BST_UNCHECKED));
			CheckDlgButton(hwndDlg,IDC_MAINOPT_RESTORE,(g_wMaskAdv & OPT_RESTORE) ? (BST_CHECKED) : (BST_UNCHECKED));

			return(true);
		} break;
		case WM_NOTIFY:
		{
			NMHDR* nmhdr = (NMHDR*)lParam;
			switch (nmhdr->code)
			{
				case PSN_APPLY:
				{
					WORD wMaskAdv = 0;
					if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_HIDEIFLOCK) == BST_CHECKED)		wMaskAdv |= OPT_HIDEIFLOCK;
					if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_HIDEIFWINIDLE) == BST_CHECKED)	wMaskAdv |= OPT_HIDEIFWINIDLE;
					if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_HIDEIFMIRIDLE) == BST_CHECKED)	wMaskAdv |= OPT_HIDEIFMIRIDLE;
					if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_HIDEIFSCRSVR) == BST_CHECKED)	wMaskAdv |= OPT_HIDEIFSCRSVR;
					if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_HIDEONSTART) == BST_CHECKED)		wMaskAdv |= OPT_HIDEONSTART;
					if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_RESTORE) == BST_CHECKED)			wMaskAdv |= OPT_RESTORE;

					if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_MENUITEM) == BST_CHECKED ) 
					{
						if (g_hMenuItem == 0) BossKeyMenuItemInit();
						wMaskAdv |= OPT_MENUITEM;
					} else 
						if (g_hMenuItem != 0) BossKeyMenuItemUnInit();

					char szMinutes[4] = {0};
					GetDlgItemTextA(hwndDlg,IDC_MAINOPT_TIME,szMinutes,3);
					(atoi(szMinutes) > 0) ? minutes = atoi(szMinutes) : minutes = 1;
					DBWriteContactSettingByte(NULL,MOD_NAME,"time",minutes);
					DBWriteContactSettingWord(NULL,MOD_NAME,"optsmaskadv",wMaskAdv);
					g_wMaskAdv = wMaskAdv;

					return(true);
				} break;
			}
		} break;
		case WM_COMMAND:
		{
			switch (HIWORD(wParam))
			{
				case BN_CLICKED:
				{
					switch(LOWORD(wParam))
					{
						case IDC_MAINOPT_MENUITEM:
						case IDC_MAINOPT_HIDEIFLOCK:
						case IDC_MAINOPT_HIDEIFSCRSVR:
						case IDC_MAINOPT_HIDEONSTART:
						case IDC_MAINOPT_RESTORE:
						{
							SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0);
							return(true);
						} break;
						case IDC_MAINOPT_HIDEIFWINIDLE:
						{
							if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_HIDEIFWINIDLE) == BST_CHECKED)
								CheckDlgButton(hwndDlg,IDC_MAINOPT_HIDEIFMIRIDLE,BST_UNCHECKED);
							SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0);
							return(true);
						} break;
						case IDC_MAINOPT_HIDEIFMIRIDLE:
						{
							if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_HIDEIFMIRIDLE) == BST_CHECKED)
								CheckDlgButton(hwndDlg,IDC_MAINOPT_HIDEIFWINIDLE,BST_UNCHECKED);
							SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0);
							return(true);
						} break;
					}
					return(0);
				} break;
				case EN_SETFOCUS:
				{
					inFocus = true;
					return(0);
				} break;
				case EN_UPDATE:
				{
					switch( LOWORD( wParam )) {
						case IDC_MAINOPT_TIME:
							if(inFocus)
								SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0);
					}
				} break;
				default:break;
			}
		} break;
		case WM_DESTROY:
		{
			g_fOptionsOpen = false;
			return(0);
		} break;
	}
	return(false);
}