OSDN Git Service

グローバルホットキーの重複登録チェック追加
authorkiri_feather <kiri_feather@users.sourceforge.jp>
Tue, 25 May 2010 04:17:58 +0000 (04:17 +0000)
committerKimura Youichi <kim.upsilon@bucyou.net>
Sat, 18 Feb 2012 14:12:48 +0000 (23:12 +0900)
KeyEventArgsのコンストラクタに渡す値がおかしかったので修正

git-svn-id: http://svn.sourceforge.jp/svnroot/tween/trunk@373 e39ad16e-3079-482e-bb30-4b4d378143b6

Tween/HookGlobalHotkey.vb

index ed41647..cd6cbb1 100644 (file)
@@ -47,7 +47,15 @@ Public Class HookGlobalHotkey
     End Sub
 
     Public Function RegisterOriginalHotkey(ByVal hotkey As Keys, ByVal modifiers As ModKeys) As Boolean
-        Dim key As New KeyEventArgs(DirectCast(hotkey Or modifiers, Keys))
+        Dim modKey As Keys = Keys.None
+        If (modifiers And ModKeys.Alt) = ModKeys.Alt Then modKey = modKey Or Keys.Alt
+        If (modifiers And ModKeys.Ctrl) = ModKeys.Ctrl Then modKey = modKey Or Keys.Control
+        If (modifiers And ModKeys.Shift) = ModKeys.Shift Then modKey = modKey Or Keys.Shift
+        If (modifiers And ModKeys.Win) = ModKeys.Win Then modKey = modKey Or Keys.LWin
+        Dim key As New KeyEventArgs(hotkey Or modKey)
+        For Each kvp As KeyValuePair(Of Integer, KeyEventArgs) In Me._hotkeyID
+            If kvp.Value.KeyData = key.KeyData Then Return True '\93o\98^\8dÏ\82Ý\82È\82ç\90³\8fí\8fI\97¹
+        Next
         Dim hotkeyId As Integer = RegisterGlobalHotKey(hotkey, modifiers, Me._targetForm)
         If hotkeyId > 0 Then
             Me._hotkeyID.Add(hotkeyId, key)