예제 #1
0
        static void DispatchThreadMessages()
        {
            uint atom  = ((_threadId_ ^ (_threadId_ >> 16)) & 0x0ffff) - 25;
            uint count = 0;
            var  msg   = new Native.Message();

            while (Native.GetMessage(ref msg, (IntPtr)0, 0, 0) > 0)
            {
                switch (msg.Msg)
                {
                case WM_USER_HOTKEY_REGISTER:
                    bool rhk = Native.RegisterHotKey(IntPtr.Zero,
                                                     atom + count,
                                                     (uint)msg.WParam,
                                                     (uint)msg.LParam);
                    if (rhk)
                    {
                        count++;
                    }
                    break;

                case WM_USER_HOTKEY_UNREGISTER_ALL:
                    while (count > 0)
                    {
                        count--;
                        Native.UnregisterHotKey(IntPtr.Zero, atom + count);
                    }
                    break;

                case WM_HOTKEY:
                    EvalHotKey((uint)msg.LParam);     // lword=modifiers, hword=virtualKey
                    break;
                }
            }
        }
예제 #2
0
 static void DispatchThreadMessages() {
     uint atom = ((_threadId_ ^ (_threadId_ >> 16)) & 0x0ffff) - 25;
     uint count = 0;
     var msg = new Native.Message();
     while (Native.GetMessage(ref msg, (IntPtr)0, 0, 0) > 0) {
         switch(msg.Msg){
             case WM_USER_HOTKEY_REGISTER:
                 bool rhk = Native.RegisterHotKey(IntPtr.Zero,
                                                  atom + count,
                                                  (uint)msg.WParam,
                                                  (uint)msg.LParam);
                 if (rhk) {
                     count++;
                 }
                 break;
             case WM_USER_HOTKEY_UNREGISTER_ALL:
                 while (count > 0) {
                     count--;
                     Native.UnregisterHotKey(IntPtr.Zero, atom + count);
                 }
                 break;
             case WM_HOTKEY:
                 EvalHotKey((uint)msg.LParam); // lword=modifiers, hword=virtualKey
                 break;
         }
     }
 }