コード例 #1
0
ファイル: BossKey.cpp プロジェクト: MrtsComputers/miranda-ng
static int ChangeAllProtoStatuses(unsigned statusMode, TCHAR *msg)
{
	for (int i=0; i < protoCount; i++)
	{
		unsigned status = CallProtoService(proto[i]->szModuleName,PS_GETSTATUS,0,0);
		if (
			(g_wMask & OPT_ONLINEONLY) ? // check "Change only if current status is Online" option
			((status == ID_STATUS_ONLINE) || (status == ID_STATUS_FREECHAT)) // process only "online" and "free for chat"
			:
			((status > ID_STATUS_OFFLINE) && (status < ID_STATUS_IDLE) && (status != ID_STATUS_INVISIBLE))) // process all existing statuses except for "invisible" & "offline"
		{
			if (g_wMask & OPT_SETONLINEBACK){ // need to save old statuses & status messages
				oldStatus[i] = status;
				if (ProtoServiceExists(proto[i]->szModuleName, PS_GETMYAWAYMSG))
					oldStatusMsg[i] = (TCHAR*)ProtoCallService(proto[i]->szModuleName, PS_GETMYAWAYMSG, 0, SGMA_TCHAR);
				else
					oldStatusMsg[i] = GetDefStatusMsg(status, proto[i]->szModuleName);
			}
			SetStatus(proto[i]->szModuleName, statusMode, msg);
		}
	}
	return 0;
}
コード例 #2
0
ファイル: Options.cpp プロジェクト: Seldom/miranda-ng
INT_PTR CALLBACK MainOptDlg(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	static bool s_fRedraw;

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

			// set icon and tooltip for variables help button
			variables_skin_helpbutton(hwndDlg, IDC_MAINOPT_VARHELP);

			SendDlgItemMessage(hwndDlg, IDC_MAINOPT_PASS, EM_LIMITTEXT, MAXPASSLEN, 0); // limit password length

			DBVARIANT dbVar;

			if (!db_get_s(NULL, MOD_NAME, "password", &dbVar)) {
				SetDlgItemTextA(hwndDlg, IDC_MAINOPT_PASS, dbVar.pszVal);
				db_free(&dbVar);
			}

			CheckDlgButton(hwndDlg, IDC_MAINOPT_SETONLINEBACK, (g_wMask & OPT_SETONLINEBACK) ? BST_CHECKED : BST_UNCHECKED);
			CheckDlgButton(hwndDlg, IDC_MAINOPT_CHANGESTATUSBOX, (g_wMask & OPT_CHANGESTATUS) ? BST_CHECKED : BST_UNCHECKED);
			CheckDlgButton(hwndDlg, IDC_MAINOPT_DISABLESNDS, (g_wMask & OPT_DISABLESNDS) ? BST_CHECKED : BST_UNCHECKED);
			CheckDlgButton(hwndDlg, IDC_MAINOPT_REQPASS, (g_wMask & OPT_REQPASS) ? BST_CHECKED : BST_UNCHECKED);
			CheckDlgButton(hwndDlg, IDC_MAINOPT_ONLINEONLY, (g_wMask & OPT_ONLINEONLY) ? BST_CHECKED : BST_UNCHECKED);
			CheckDlgButton(hwndDlg, IDC_MAINOPT_USEDEFMSG, (g_wMask & OPT_USEDEFMSG) ? BST_CHECKED : BST_UNCHECKED);
			CheckDlgButton(hwndDlg, IDC_MAINOPT_TRAYICON, (g_wMask & OPT_TRAYICON) ? BST_CHECKED : BST_UNCHECKED);

			for (int i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++)
				SendDlgItemMessage(hwndDlg, IDC_MAINOPT_CHGSTS, CB_INSERTSTRING, -1, (LPARAM)pcli->pfnGetStatusModeDescription(i, 0));

			SendDlgItemMessage(hwndDlg, IDC_MAINOPT_CHGSTS, CB_SETCURSEL, db_get_b(NULL, MOD_NAME, "stattype", 2), 0);

			SendMessage(hwndDlg, WM_USER + 60, 0, 0);
			SendMessage(hwndDlg, WM_USER + 50, 0, 0);

			s_fRedraw = true;
		}
		return true;

	case WM_NOTIFY:
		switch (((NMHDR*)lParam)->code) {
		case PSN_APPLY:
			WORD wMask = 0;
			// we apply changes here
			// this plugin ain't that big, no need for a seperate routine

			// write down status type
			if (IsDlgButtonChecked(hwndDlg, IDC_MAINOPT_CHANGESTATUSBOX) == BST_CHECKED) {
				db_set_b(NULL, MOD_NAME, "stattype", (BYTE)SendDlgItemMessage(hwndDlg, IDC_MAINOPT_CHGSTS, CB_GETCURSEL, 0, 0));

				// status msg, if needed
				if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_MAINOPT_STATMSG))) { // meaning we should save it
					TCHAR tszMsg[1025];
					GetDlgItemText(hwndDlg, IDC_MAINOPT_STATMSG, tszMsg, _countof(tszMsg));
					if (tszMsg[0] != 0)
						db_set_ts(NULL, MOD_NAME, "statmsg", tszMsg);
					else // delete current setting
						db_unset(NULL, MOD_NAME, "statmsg");
				}
				wMask |= OPT_CHANGESTATUS;
			}

			// checkbox
			if (IsDlgButtonChecked(hwndDlg, IDC_MAINOPT_REQPASS) == BST_CHECKED) {
				char szPass[MAXPASSLEN + 1];
				GetDlgItemTextA(hwndDlg, IDC_MAINOPT_PASS, szPass, _countof(szPass));
				if (szPass[0] != 0){
					db_set_s(NULL, MOD_NAME, "password", szPass);
					wMask |= OPT_REQPASS;
				}
			}
			if (IsDlgButtonChecked(hwndDlg, IDC_MAINOPT_SETONLINEBACK) == BST_CHECKED) wMask |= OPT_SETONLINEBACK;
			if (IsDlgButtonChecked(hwndDlg, IDC_MAINOPT_DISABLESNDS) == BST_CHECKED) wMask |= OPT_DISABLESNDS;
			if (IsDlgButtonChecked(hwndDlg, IDC_MAINOPT_ONLINEONLY) == BST_CHECKED) wMask |= OPT_ONLINEONLY;
			if (IsDlgButtonChecked(hwndDlg, IDC_MAINOPT_USEDEFMSG) == BST_CHECKED)  wMask |= OPT_USEDEFMSG;
			if (IsDlgButtonChecked(hwndDlg, IDC_MAINOPT_TRAYICON) == BST_CHECKED)  wMask |= OPT_TRAYICON;

			db_set_w(NULL, MOD_NAME, "optsmask", wMask);
			g_wMask = wMask;
			return true;
		}
		break;

	case WM_USER + 50: // we're told to checkout the selection state of the combobox, and enable/disable accordingly
	{
		BYTE bSelection = (BYTE)SendDlgItemMessage(hwndDlg, IDC_MAINOPT_CHGSTS, CB_GETCURSEL, 0, 0);
		WORD wMode = STATUS_ARR_TO_ID[bSelection];
		if (IsDlgButtonChecked(hwndDlg, IDC_MAINOPT_USEDEFMSG) == BST_CHECKED) {
			TCHAR *ptszDefMsg = GetDefStatusMsg(wMode, 0);
			SetDlgItemText(hwndDlg, IDC_MAINOPT_STATMSG, ptszDefMsg);
			if (ptszDefMsg)
				mir_free(ptszDefMsg);
		}
		else {
			DBVARIANT dbVar;
			SendDlgItemMessage(hwndDlg, IDC_MAINOPT_STATMSG, EM_LIMITTEXT, 1024, 0);
			if (!db_get_ts(NULL, MOD_NAME, "statmsg", &dbVar)) {
				SetDlgItemText(hwndDlg, IDC_MAINOPT_STATMSG, dbVar.ptszVal);
				db_free(&dbVar);
			}
		}
		EnableWindow(GetDlgItem(hwndDlg, IDC_MAINOPT_STATMSG), (IsDlgButtonChecked(hwndDlg, IDC_MAINOPT_CHANGESTATUSBOX) == BST_CHECKED) && (IsDlgButtonChecked(hwndDlg, IDC_MAINOPT_USEDEFMSG) != BST_CHECKED));
		ShowWindow(GetDlgItem(hwndDlg, IDC_MAINOPT_VARHELP), IsWindowEnabled(GetDlgItem(hwndDlg, IDC_MAINOPT_STATMSG)) && ServiceExists(MS_VARS_FORMATSTRING));
	}
	return true;

	case WM_USER + 60:
	{
		bool fEnable = IsDlgButtonChecked(hwndDlg, IDC_MAINOPT_CHANGESTATUSBOX) == BST_CHECKED;
		EnableWindow(GetDlgItem(hwndDlg, IDC_MAINOPT_CHGSTS), fEnable);
		EnableWindow(GetDlgItem(hwndDlg, IDC_MAINOPT_SETONLINEBACK), fEnable);
		EnableWindow(GetDlgItem(hwndDlg, IDC_MAINOPT_ONLINEONLY), fEnable);
		EnableWindow(GetDlgItem(hwndDlg, IDC_MAINOPT_USEDEFMSG), fEnable);
		EnableWindow(GetDlgItem(hwndDlg, IDC_MAINOPT_PASS), IsDlgButtonChecked(hwndDlg, IDC_MAINOPT_REQPASS) == BST_CHECKED);
	}
	return true;

	case WM_COMMAND:
		switch (HIWORD(wParam)) {
		case CBN_SELCHANGE:
			if (LOWORD(wParam) == IDC_MAINOPT_CHGSTS)
				SendMessage(hwndDlg, WM_USER + 50, 0, 0);

			SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0);
			return 0;

		case BN_CLICKED:
			switch (LOWORD(wParam)) {
			case IDC_MAINOPT_DISABLESNDS:
			case IDC_MAINOPT_SETONLINEBACK:
			case IDC_MAINOPT_ONLINEONLY:
			case IDC_MAINOPT_TRAYICON:
				SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0);
				return true;

			case IDC_MAINOPT_USEDEFMSG:
				SendMessage(hwndDlg, WM_USER + 50, 0, 0);
				SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0);
				return true;

			case IDC_MAINOPT_CHANGESTATUSBOX:
				SendMessage(hwndDlg, WM_USER + 60, 0, 0);
				SendMessage(hwndDlg, WM_USER + 50, 0, 0);
				SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0);
				return true;

			case IDC_MAINOPT_REQPASS:
				SendMessage(hwndDlg, WM_USER + 60, 0, 0);
				SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0);
				return true;

			case IDC_MAINOPT_VARHELP:
				variables_showhelp(hwndDlg, IDC_MAINOPT_STATMSG, VHF_INPUT | VHF_HELP, 0, 0);
				SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0);
				return true;

			case IDC_MAINOPT_LNK_HOTKEY:
				OPENOPTIONSDIALOG ood = { 0 };
				ood.cbSize = sizeof(ood);
				ood.pszGroup = "Customize";
				ood.pszPage = "Hotkeys";
				Options_Open(&ood);
				return (true);
			}
			return 0;

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

	case WM_DESTROY:
		g_fOptionsOpen = false;
		return 0;
	}
	return(false);
}
コード例 #3
0
ファイル: Options.cpp プロジェクト: TonyAlloa/miranda-dev
INT_PTR CALLBACK MainOptDlg(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam)
{
	static bool s_fRedraw;

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

			g_fOptionsOpen = true;
			s_fRedraw = false;

			extern PWTSRegisterSessionNotification wtsRegisterSessionNotification;

			if (wtsRegisterSessionNotification == 0)
				EnableWindow(GetDlgItem(hwndDlg, IDC_MAINOPT_HIDEIFLOCK), SW_HIDE);

			// set icon and tooltip for variables help button

			if (ServiceExists(MS_VARS_GETSKINITEM)) {
				HICON hIcon = (HICON)CallService(MS_VARS_GETSKINITEM, 0, (LPARAM)VSI_HELPICON);
				if (hIcon != NULL)
					SendMessage(GetDlgItem(hwndDlg, IDC_MAINOPT_VARHELP), BM_SETIMAGE, (WPARAM)IMAGE_ICON, (LPARAM)hIcon);
				SendMessage(GetDlgItem(hwndDlg, IDC_MAINOPT_VARHELP), BUTTONADDTOOLTIP, (WPARAM)TranslateT("Open String Formatting Help"), BATF_TCHAR);
				SendDlgItemMessage(hwndDlg, IDC_MAINOPT_VARHELP, BUTTONSETASFLATBTN, 0, 0);
			}

			SendDlgItemMessage(hwndDlg,IDC_MAINOPT_PASS,EM_LIMITTEXT,MAXPASSLEN,0); // limit password length

			DBVARIANT dbVar;

			if (!DBGetContactSettingString(NULL,MOD_NAME,"password",&dbVar))
			{
				CallService( MS_DB_CRYPT_DECODESTRING, strlen( dbVar.pszVal )+1, ( LPARAM )dbVar.pszVal );

				SetDlgItemTextA(hwndDlg,IDC_MAINOPT_PASS,dbVar.pszVal);
				DBFreeVariant(&dbVar);
			}
			
			CheckDlgButton(hwndDlg,IDC_MAINOPT_SETONLINEBACK,(g_wMask & OPT_SETONLINEBACK) ? (BST_CHECKED) : (BST_UNCHECKED));
			CheckDlgButton(hwndDlg,IDC_MAINOPT_CHANGESTATUSBOX,(g_wMask & OPT_CHANGESTATUS) ? (BST_CHECKED) : (BST_UNCHECKED));
			CheckDlgButton(hwndDlg,IDC_MAINOPT_DISABLESNDS,(g_wMask & OPT_DISABLESNDS) ? (BST_CHECKED) : (BST_UNCHECKED));
			CheckDlgButton(hwndDlg,IDC_MAINOPT_REQPASS,(g_wMask & OPT_REQPASS) ? (BST_CHECKED) : (BST_UNCHECKED));
			CheckDlgButton(hwndDlg,IDC_MAINOPT_ONLINEONLY,(g_wMask & OPT_ONLINEONLY) ? (BST_CHECKED) : (BST_UNCHECKED));
			CheckDlgButton(hwndDlg,IDC_MAINOPT_USEDEFMSG,(g_wMask & OPT_USEDEFMSG) ? (BST_CHECKED) : (BST_UNCHECKED));
			CheckDlgButton(hwndDlg,IDC_MAINOPT_TRAYICON,(g_wMask & OPT_TRAYICON) ? (BST_CHECKED) : (BST_UNCHECKED));

			const TCHAR *STATUS_ARR_TO_NAME[8] = { _T("Offline"), _T("Online"), _T("Away"), _T("NA"), _T("Occupied"), _T("DND"), _T("Free for chat"), _T("Invisible") };

			for (BYTE i = 0;i < 8; i++)
				SendDlgItemMessage(hwndDlg,IDC_MAINOPT_CHGSTS,CB_INSERTSTRING,-1,(LPARAM)TranslateTS(STATUS_ARR_TO_NAME[i]));

			SendDlgItemMessage(hwndDlg,IDC_MAINOPT_CHGSTS,CB_SETCURSEL,DBGetContactSettingByte(NULL,MOD_NAME,"stattype",4),0);

			SendMessage(hwndDlg,WM_USER + 60,0,0);
			SendMessage(hwndDlg,WM_USER + 50,0,0);

			s_fRedraw = true;
			return(true);
		} break;
		case WM_NOTIFY:
		{
			NMHDR* nmhdr = (NMHDR*)lParam;
			switch (nmhdr->code)
			{
				case PSN_APPLY:
				{
					WORD wMask = 0;
					// we apply changes here
					// this plugin ain't that big, no need for a seperate routine

					// write down status type
					if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_CHANGESTATUSBOX) == BST_CHECKED)
					{
						DBWriteContactSettingByte(NULL,MOD_NAME,"stattype",(BYTE)SendDlgItemMessage(hwndDlg,IDC_MAINOPT_CHGSTS,CB_GETCURSEL,0,0));

						// status msg, if needed
						if (IsWindowEnabled(GetDlgItem(hwndDlg,IDC_MAINOPT_STATMSG))) // meaning we should save it
						{
							TCHAR tszMsg[1025];
							GetDlgItemText(hwndDlg,IDC_MAINOPT_STATMSG,tszMsg,1024);
							if (lstrlen(tszMsg) != 0)
								DBWriteContactSettingTString(NULL,MOD_NAME,"statmsg",tszMsg);
							else // delete current setting
								DBDeleteContactSetting(NULL,MOD_NAME,"statmsg");
						}
						wMask |= OPT_CHANGESTATUS;
					}

					// checkbox
					if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_REQPASS) == BST_CHECKED)
					{
						char szPass[MAXPASSLEN+1];
						GetDlgItemTextA(hwndDlg,IDC_MAINOPT_PASS,szPass,MAXPASSLEN+1);
						if (strlen(szPass) != 0){
							CallService( MS_DB_CRYPT_ENCODESTRING, MAXPASSLEN+1, ( LPARAM )szPass );
							DBWriteContactSettingString(NULL,MOD_NAME,"password",szPass);
							wMask |= OPT_REQPASS;
						}
					}
					if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_SETONLINEBACK) == BST_CHECKED) wMask |= OPT_SETONLINEBACK;
					if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_DISABLESNDS) == BST_CHECKED) wMask	|= OPT_DISABLESNDS;
					if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_ONLINEONLY) == BST_CHECKED) wMask |= OPT_ONLINEONLY;
					if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_USEDEFMSG) == BST_CHECKED)  wMask |= OPT_USEDEFMSG;
					if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_TRAYICON) == BST_CHECKED)  wMask |= OPT_TRAYICON;

					DBWriteContactSettingWord(NULL,MOD_NAME,"optsmask",wMask);
					g_wMask = wMask;

					return(true);
				} break;
			}
		} break;
		case WM_USER+50: // we're told to checkout the selection state of the combobox, and enable/disable accordingly
		{
			BYTE bSelection = (BYTE)SendDlgItemMessage(hwndDlg,IDC_MAINOPT_CHGSTS,CB_GETCURSEL,0,0);
			WORD wMode = STATUS_ARR_TO_ID[bSelection];
			if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_USEDEFMSG) == BST_CHECKED)
			{
				TCHAR *ptszDefMsg = GetDefStatusMsg(wMode, 0);
				SetDlgItemText(hwndDlg, IDC_MAINOPT_STATMSG, ptszDefMsg);
				if(ptszDefMsg)
					mir_free(ptszDefMsg);
			}
			else
			{
				DBVARIANT dbVar;
				SendDlgItemMessage(hwndDlg,IDC_MAINOPT_STATMSG,EM_LIMITTEXT,1024,0);
				if (!DBGetContactSettingTString(NULL,MOD_NAME,"statmsg",&dbVar))
				{
					SetDlgItemText(hwndDlg,IDC_MAINOPT_STATMSG,dbVar.ptszVal);
					DBFreeVariant(&dbVar);
				}
			}
			EnableWindow(GetDlgItem(hwndDlg,IDC_MAINOPT_STATMSG),(IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_CHANGESTATUSBOX) == BST_CHECKED) && (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_USEDEFMSG) != BST_CHECKED));
			ShowWindow(GetDlgItem(hwndDlg, IDC_MAINOPT_VARHELP), IsWindowEnabled(GetDlgItem(hwndDlg,IDC_MAINOPT_STATMSG)) && ServiceExists(MS_VARS_FORMATSTRING));
			return(true);
		} break;
		case WM_USER+60:
		{
			bool fEnable = IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_CHANGESTATUSBOX) == BST_CHECKED;
			EnableWindow(GetDlgItem(hwndDlg,IDC_MAINOPT_CHGSTS),fEnable);
			EnableWindow(GetDlgItem(hwndDlg,IDC_MAINOPT_SETONLINEBACK),fEnable);
			EnableWindow(GetDlgItem(hwndDlg,IDC_MAINOPT_ONLINEONLY),fEnable);
			EnableWindow(GetDlgItem(hwndDlg,IDC_MAINOPT_USEDEFMSG),fEnable);			
			EnableWindow(GetDlgItem(hwndDlg,IDC_MAINOPT_PASS),IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_REQPASS) == BST_CHECKED);
			return(true);
		} break;
		case WM_COMMAND:
		{
			switch (HIWORD(wParam))
			{
				case CBN_SELCHANGE:
				{
					// check the type
					// if type doesn't require a msg, we don't use one
					if (LOWORD(wParam) == IDC_MAINOPT_CHGSTS)
					{
						SendMessage(hwndDlg,WM_USER + 50,0,0);
					}
					SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0);
					return(0);
				} break;
				case BN_CLICKED:
				{
					switch(LOWORD(wParam))
					{
						case IDC_MAINOPT_DISABLESNDS:
						case IDC_MAINOPT_SETONLINEBACK:
						case IDC_MAINOPT_ONLINEONLY:
						case IDC_MAINOPT_TRAYICON:
						{
							SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0);
							return(true);
						} break;
						case IDC_MAINOPT_USEDEFMSG:
						{
							SendMessage(hwndDlg,WM_USER + 50,0,0);
							SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0);
							return(true);
						} break;
						case IDC_MAINOPT_CHANGESTATUSBOX:
						{
							SendMessage(hwndDlg,WM_USER + 60,0,0);
							SendMessage(hwndDlg,WM_USER + 50,0,0);
							SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0);
							return(true);
						} break;
						case IDC_MAINOPT_REQPASS:
						{
							SendMessage(hwndDlg,WM_USER + 60,0,0);
							SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0);
							return(true);
						} break;
						case IDC_MAINOPT_VARHELP:
						{
							variables_showhelp(hwndDlg, IDC_MAINOPT_STATMSG, VHF_INPUT|VHF_HELP, 0, 0);
							SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0);
							return(true);
						} break;
						case IDC_MAINOPT_LNK_HOTKEY:
						{
							OPENOPTIONSDIALOG ood = {0};
							ood.cbSize = sizeof(ood);
							ood.pszGroup = "Customize";
							ood.pszPage = "Hotkeys";
							CallService( MS_OPT_OPENOPTIONS, 0, (LPARAM)&ood );
							return (true);
						} break;
					}
					return(0);
				} break;
				case EN_UPDATE:
				{
					switch( LOWORD( wParam )) {
						case IDC_MAINOPT_STATMSG:
						case IDC_MAINOPT_PASS:
							if (s_fRedraw)
								SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0);
					}
				} break;
				default:break;
			}
		} break;
		case WM_DESTROY:
		{
			g_fOptionsOpen = false;
			return(0);
		} break;
	}
	return(false);
}
コード例 #4
0
ファイル: BossKey.cpp プロジェクト: MrtsComputers/miranda-ng
LRESULT CALLBACK ListenWndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
	switch (uMsg){
	case WM_WTSSESSION_CHANGE:
		if (wParam == WTS_SESSION_LOCK && g_wMaskAdv & OPT_HIDEIFLOCK && !g_bWindowHidden) // Windows locked
			PostMessage(hWnd,WM_USER + 40, 0, 0);
		return 0;

	case WM_USER + 24:
		if (lParam == WM_LBUTTONDBLCLK)
			PostMessage(hWnd,WM_USER + 52, 0, 0);
		return 0;

	case WM_USER+40: // hide
		{
			if (g_bWindowHidden || g_fOptionsOpen) // already hidden or in options, no hiding
				break;

			DWORD dwWndPID; // remember foreground window
			HWND hForegroundWnd = GetForegroundWindow();
			GetWindowThreadProcessId(hForegroundWnd,&dwWndPID);
			if (g_dwMirandaPID == dwWndPID)
				hOldForegroundWindow = hForegroundWnd;

			EnumWindows(EnumWindowsProc, 0);

			if (g_wMask & OPT_CHANGESTATUS) // is this even needed?
			{
				BYTE bReqMode = db_get_b(NULL, MOD_NAME, "stattype", 2);
				unsigned uMode = (STATUS_ARR_TO_ID[bReqMode]);
				DBVARIANT dbVar;
				if (g_wMask & OPT_USEDEFMSG || db_get_ts(NULL,MOD_NAME,"statmsg",&dbVar))
				{
					TCHAR *ptszDefMsg = GetDefStatusMsg(uMode, 0);
					ChangeAllProtoStatuses(uMode, ptszDefMsg);
					mir_free(ptszDefMsg);
				}
				else
				{
					if (ServiceExists(MS_VARS_FORMATSTRING))
					{
						TCHAR *ptszParsed = variables_parse(dbVar.ptszVal, 0, 0);
						ChangeAllProtoStatuses(uMode, ptszParsed);
						mir_free(ptszParsed);
					}
					else
						ChangeAllProtoStatuses(uMode, dbVar.ptszVal);
					db_free(&dbVar);
				}
			}

			pcli->pfnTrayIconDestroy (pcli->hwndContactList);
			pcli->pfnUninitTray();

			if (g_wMask & OPT_TRAYICON)
				CreateTrayIcon(true);

			// disable popups
			if (CallService(MS_POPUP_QUERY, PUQS_GETSTATUS, 0) == 1)
			{
				// save current
				g_bOldSetting |= OLD_POPUP;
				CallService(MS_POPUP_QUERY, PUQS_DISABLEPOPUPS, 0);
			}

			// disable sounds
			if ((g_wMask & OPT_DISABLESNDS) && db_get_b(NULL,"Skin","UseSound",1))
			{
				// save current
				g_bOldSetting |= OLD_SOUND;
				db_set_b(NULL,"Skin","UseSound",0);
			}

			g_bWindowHidden = true;

			g_bOldSetting |= OLD_WASHIDDEN;
			db_set_b(NULL, MOD_NAME, "OldSetting", g_bOldSetting);
		}
		return 0;

	case WM_USER+52: // back
		{
			if (!g_bWindowHidden || g_fPassRequested)
				break;

			if (g_wMask & OPT_REQPASS){  //password request
				DBVARIANT dbVar;
				if (!db_get_s(NULL,MOD_NAME, "password", &dbVar)) {
					g_fPassRequested = true;

					strncpy(g_password, dbVar.pszVal, MAXPASSLEN);
					db_free(&dbVar);

					int res = DialogBox(g_hInstance,(MAKEINTRESOURCE(IDD_PASSDIALOGNEW)),GetForegroundWindow(), DlgStdInProc);

					g_fPassRequested = false;
					if(res != IDOK) return 0;
				}
			}

			if (g_wMask & OPT_CHANGESTATUS && g_wMask & OPT_SETONLINEBACK) // set back to some status
				BackAllProtoStatuses();

			HWND_ITEM *pCurWnd = g_pMirWnds;
			while (pCurWnd != NULL)
			{
				HWND_ITEM *pNextWnd = pCurWnd->next;
				TCHAR szTemp[32];
				GetClassName(pCurWnd->hWnd,szTemp,32);

				if (IsWindow(pCurWnd->hWnd) && lstrcmp(szTemp,_T("SysShadow")) != 0) // precaution
					ShowWindow(pCurWnd->hWnd, SW_SHOW);

				delete pCurWnd; // bye-bye
				pCurWnd = pNextWnd; // traverse to next item
			}
			g_pMirWnds = NULL;

			if (hOldForegroundWindow)
			{
				SetForegroundWindow(hOldForegroundWindow);
				hOldForegroundWindow = NULL;
			}

			RestoreOldSettings();

			if (g_TrayIcon) CreateTrayIcon(false);

			pcli->pfnInitTray();
			pcli->pfnTrayIconInit(pcli->hwndContactList);

			// force a redraw
			// should prevent drawing problems
			InvalidateRect(pcli->hwndContactList,NULL,true);
			UpdateWindow(pcli->hwndContactList);

			PostMessage(hWnd, WM_MOUSEMOVE, 0, (LPARAM)MAKELONG(2, 2)); // reset core's IDLE
			g_bWindowHidden = false;

			db_set_b(NULL, MOD_NAME, "OldSetting", 0);
		}
		return 0;
	}
	return(DefWindowProc(hWnd, uMsg, wParam, lParam));
}