diff options
author | berkeviktor@aol.com <berkeviktor@aol.com> | 2011-07-27 09:04:58 +0200 |
---|---|---|
committer | berkeviktor@aol.com <berkeviktor@aol.com> | 2011-07-27 09:04:58 +0200 |
commit | 69ba67b2549b6c6a46abd19879b67e1545c9ae3b (patch) | |
tree | 5063f496b71b6934790096d25b30f0a87415e4d6 /plugins/xtray | |
parent | 34144faca5e0bb09ccc4cee4e298cb80dff740dd (diff) |
fix xtray keyboard shortcut handling
Diffstat (limited to 'plugins/xtray')
-rw-r--r-- | plugins/xtray/utility.cpp | 47 | ||||
-rw-r--r-- | plugins/xtray/utility.h | 3 |
2 files changed, 48 insertions, 2 deletions
diff --git a/plugins/xtray/utility.cpp b/plugins/xtray/utility.cpp index 60f3f2f0..4faed90b 100644 --- a/plugins/xtray/utility.cpp +++ b/plugins/xtray/utility.cpp @@ -29,6 +29,49 @@ TCHAR BACKUP_INI_FILE[] = _T(".\\plugins\\config\\xtray.conf"); struct HOTKEY g_hHotKey; +/* we need to convert ALT and SHIFT modifiers +// from <winuser.h> +#define MOD_ALT 0x0001 +#define MOD_CONTROL 0x0002 +#define MOD_SHIFT 0x0004 +// from <commctrl.h> +#define HOTKEYF_SHIFT 0x01 +#define HOTKEYF_CONTROL 0x02 +#define HOTKEYF_ALT 0x04 +*/ + +WORD HotkeyfToMod(WORD modifiers) +{ + WORD newmods = 0; + + if (modifiers & HOTKEYF_SHIFT) + newmods |= MOD_SHIFT; + + if (modifiers & HOTKEYF_CONTROL) + newmods |= MOD_CONTROL; + + if (modifiers & HOTKEYF_ALT) + newmods |= MOD_ALT; + + return newmods; +} + +WORD ModToHotkeyf(WORD modifiers) +{ + WORD newmods = 0; + + if (modifiers & MOD_SHIFT) + newmods |= HOTKEYF_SHIFT; + + if (modifiers & MOD_CONTROL) + newmods |= HOTKEYF_CONTROL; + + if (modifiers & MOD_ALT) + newmods |= HOTKEYF_ALT; + + return newmods; +} + void SavePrefs(int iDlg) { /**************************************************************************************************/ @@ -292,7 +335,7 @@ void CheckPrefs(HWND hwnd, int iDlg) hHotkey = SendDlgItemMessage(hwnd, IDC_ALERT_HOTKEY, HKM_GETHOTKEY, 0, 0); g_hHotKey.key = LOBYTE(hHotkey); - g_hHotKey.mod = HIBYTE(hHotkey); + g_hHotKey.mod = HotkeyfToMod(HIBYTE(hHotkey)); if(IsDlgButtonChecked(hwnd, PREF_UWIOB) == BST_CHECKED) { @@ -403,7 +446,7 @@ void SetDialog(HWND hwnd, int iDlg) /**********************************************************/ TCHAR tTime[255]; SendDlgItemMessage(hwnd, IDC_ALERT_TIME, WM_SETTEXT, 0, (LPARAM)_itot(g_iTime, tTime, 10)); - SendDlgItemMessage(hwnd, IDC_ALERT_HOTKEY, HKM_SETHOTKEY, MAKEWORD(g_hHotKey.key, g_hHotKey.mod), 0); + SendDlgItemMessage(hwnd, IDC_ALERT_HOTKEY, HKM_SETHOTKEY, MAKEWORD(g_hHotKey.key, ModToHotkeyf(g_hHotKey.mod)), 0); } break; } diff --git a/plugins/xtray/utility.h b/plugins/xtray/utility.h index ce3d541c..6bee8aed 100644 --- a/plugins/xtray/utility.h +++ b/plugins/xtray/utility.h @@ -19,6 +19,9 @@ #ifndef _H_UTILITY_H #define _H_UTILITY_H +WORD HotkeyfToMod (WORD); +WORD ModToHotkeyf (WORD); + int SetOption (HWND, unsigned int, unsigned int); int SetCheck (HWND, unsigned int, unsigned int); int SetToggle (HWND, unsigned int, unsigned int, bool); |