当前位置: 首页>>代码示例>>C#>>正文


C# WM类代码示例

本文整理汇总了C#中WM的典型用法代码示例。如果您正苦于以下问题:C# WM类的具体用法?C# WM怎么用?C# WM使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


WM类属于命名空间,在下文中一共展示了WM类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: KeyboardHookProc

        private static IntPtr KeyboardHookProc(int nCode, WM wParam, IntPtr lParam)
        {
            bool handled = false;

              if (nCode >= 0)
              {
            KeyboardHookStruct kbHookStruct = (KeyboardHookStruct)
              Marshal.PtrToStructure(lParam, typeof(KeyboardHookStruct));
            Keys keyData = (Keys)kbHookStruct.vkCode;
            KeyEventArgs e = new KeyEventArgs(keyData);

            if (s_KeyDown != null && (wParam == WM.KEYDOWN ||
            wParam == WM.SYSKEYDOWN))
            {
              s_KeyDown.Invoke(null, e);
              handled = e.Handled;
            }

            if (s_KeyUp != null && (wParam == WM.KEYUP ||
            wParam == WM.SYSKEYUP))
            {
              s_KeyUp.Invoke(null, e);
              handled = e.Handled;
            }

            if (handled)
            {
              return new IntPtr(-1);
            }
              }

              return CallNextHookEx(s_KeyboardHookHandle, nCode, wParam, lParam);
        }
开发者ID:shurizzle,项目名称:Scroto,代码行数:33,代码来源:Hooker.Callbacks.cs

示例2: KeyDataEventArgs

 /// <summary>
 ///
 /// </summary>
 /// <param name="keyMessage"></param>
 /// <param name="keyCode"></param>
 /// <param name="scanCode"></param>
 /// <param name="timeStamp"></param>
 public KeyDataEventArgs(WM keyMessage, int keyCode, int scanCode, int timeStamp)
 {
     KeyMessage = keyMessage;
     KeyCode = keyCode;
     ScanCode = scanCode;
     TimeStamp = timeStamp;
 }
开发者ID:usausa,项目名称:Smart-Net-CE,代码行数:14,代码来源:KeyDataEventArgs.cs

示例3: OnKey

    private static int OnKey(HC nCode, WM wParam, IntPtr lParam)
    {
        bool is_key = (wParam == WM.KEYDOWN || wParam == WM.SYSKEYDOWN
                        || wParam == WM.KEYUP || wParam == WM.SYSKEYUP);

        if (nCode == HC.ACTION && is_key)
        {
            // Retrieve key event data from native structure
            var data = (KBDLLHOOKSTRUCT)Marshal.PtrToStructure(lParam,
                                                      typeof(KBDLLHOOKSTRUCT));
            bool is_injected = (data.flags & LLKHF.INJECTED) != 0;

            Log.Debug("{0}: OnKey(HC.{1}, WM.{2}, [vk:0x{3:X02} sc:0x{4:X02} flags:{5}])",
                      is_injected ? "Ignored Injected Event" : "Event",
                      nCode, wParam, (int)data.vk, (int)data.sc, data.flags);

            if (!is_injected)
            {
                if (Composer.OnKey(wParam, data.vk, data.sc, data.flags))
                {
                    // Do not process further: that key was for us.
                    return -1;
                }
            }
        }
        else
        {
            Log.Debug("Ignored Event: OnKey({0}, {1})", nCode, wParam);
        }

        return NativeMethods.CallNextHookEx(m_hook, nCode, wParam, lParam);
    }
开发者ID:DarkDare,项目名称:wincompose,代码行数:32,代码来源:KeyboardHook.cs

示例4: OnKeyHook

 bool OnKeyHook(int code, WM wParam, KBDLLHOOKSTRUCT lParam, Hooker hooker)
 {
     if (lParam.vkCode ==  44 && wParam == WM.KEYUP)
     {
         takeScreenshot();
     }
     return false;
 }
开发者ID:furaga,项目名称:InstantScreenCapture,代码行数:8,代码来源:Form1.cs

示例5: OnKey

    /// <summary>
    /// Get input from the keyboard hook; return true if the key was handled
    /// and needs to be removed from the input chain.
    /// </summary>
    public static bool OnKey(WM ev, VK vk, SC sc, LLKHF flags)
    {
        // Remember when the user touched a key for the last time
        m_last_key_time = DateTime.Now;

        // Do nothing if we are disabled
        if (m_disabled)
        {
            return false;
        }

        int dead_key = SaveDeadKey();
        bool ret = OnKeyInternal(ev, vk, sc, flags);
        RestoreDeadKey(dead_key);

        return ret;
    }
开发者ID:carter-lavering,项目名称:wincompose,代码行数:21,代码来源:Composer.cs

示例6: OnKey

        private static int OnKey(HC nCode, WM wParam, IntPtr lParam)
        {
            if (nCode == HC.ACTION)
            {
            // Retrieve event data from native structure
            var data = (KBDLLHOOKSTRUCT)Marshal.PtrToStructure(lParam,
                                                      typeof(KBDLLHOOKSTRUCT));

            bool is_key = (wParam == WM.KEYDOWN || wParam == WM.SYSKEYDOWN
                            || wParam == WM.KEYUP || wParam == WM.SYSKEYUP);
            bool is_injected = (data.flags & LLKHF.INJECTED) != 0;

            if (is_key && !is_injected)
            {
                if (Composer.OnKey(wParam, data.vk, data.sc, data.flags))
                {
                    // Do not process further: that key was for us.
                    return -1;
                }
            }
            }

            return NativeMethods.CallNextHookEx(m_hook, nCode, wParam, lParam);
        }
开发者ID:modulexcite,项目名称:wincompose,代码行数:24,代码来源:KeyboardHook.cs

示例7: _ChangeWindowMessageFilterEx

 private static extern bool _ChangeWindowMessageFilterEx(IntPtr hwnd, WM message, MSGFLT action, [In, Out, Optional] ref CHANGEFILTERSTRUCT pChangeFilterStruct);
开发者ID:AlertProject,项目名称:Text-processing-bundle,代码行数:1,代码来源:NativeMethods.cs

示例8: SendMessage

 public static extern IntPtr SendMessage(IntPtr hWnd, WM Msg, IntPtr wParam, IntPtr lParam);
开发者ID:AlertProject,项目名称:Text-processing-bundle,代码行数:1,代码来源:NativeMethods.cs

示例9: DwmDefWindowProc

 public static extern bool DwmDefWindowProc(IntPtr hwnd, WM msg, IntPtr wParam, IntPtr lParam, out IntPtr plResult);
开发者ID:AlertProject,项目名称:Text-processing-bundle,代码行数:1,代码来源:NativeMethods.cs

示例10: ChangeWindowMessageFilterEx

        public static HRESULT ChangeWindowMessageFilterEx(IntPtr hwnd, WM message, MSGFLT action, out MSGFLTINFO filterInfo)
        {
            filterInfo = MSGFLTINFO.NONE;

            bool ret;

            // This origins of this API were added for Vista.  The Ex version was added for Windows 7.
            // If we're not on either, then this message filter isolation doesn't exist.
            if (!Utility.IsOSVistaOrNewer)
            {
                return HRESULT.S_FALSE;
            }

            // If we're on Vista rather than Win7 then we can't use the Ex version of this function.
            // The Ex version is preferred if possible because this results in process-wide modifications of the filter
            // and is deprecated as of Win7.
            if (!Utility.IsOSWindows7OrNewer)
            {
                // Note that the Win7 MSGFLT_ALLOW/DISALLOW enum values map to the Vista MSGFLT_ADD/REMOVE
                ret = _ChangeWindowMessageFilter(message, action);
                if (!ret)
                {
                    return (HRESULT)Win32Error.GetLastError();
                }
                return HRESULT.S_OK;
            }

            var filterstruct = new CHANGEFILTERSTRUCT { cbSize = (uint)Marshal.SizeOf(typeof(CHANGEFILTERSTRUCT)) };
            ret = _ChangeWindowMessageFilterEx(hwnd, message, action, ref filterstruct);
            if (!ret)
            {
                return (HRESULT)Win32Error.GetLastError();
            }

            filterInfo = filterstruct.ExtStatus;
            return HRESULT.S_OK;
        }
开发者ID:AlertProject,项目名称:Text-processing-bundle,代码行数:37,代码来源:NativeMethods.cs

示例11: _WndProc

        private static IntPtr _WndProc(IntPtr hwnd, WM msg, IntPtr wParam, IntPtr lParam)
        {
            var ret = IntPtr.Zero;
            MessageWindow hwndWrapper = null;

            if (msg == WM.CREATE)
            {
                var createStruct = (CREATESTRUCT)Marshal.PtrToStructure(lParam, typeof(CREATESTRUCT));
                var gcHandle = GCHandle.FromIntPtr(createStruct.lpCreateParams);
                hwndWrapper = (MessageWindow)gcHandle.Target;
                SWindowLookup.Add(hwnd, hwndWrapper);
            }
            else
            {
                if (!SWindowLookup.TryGetValue(hwnd, out hwndWrapper))
                {
                    return NativeMethods.DefWindowProc(hwnd, msg, wParam, lParam);
                }
            }
            Assert.IsNotNull(hwndWrapper);

            var callback = hwndWrapper._wndProcCallback;
            if (callback != null)
            {
                ret = callback(hwnd, msg, wParam, lParam);
            }
            else
            {
                ret = NativeMethods.DefWindowProc(hwnd, msg, wParam, lParam);
            }

            if (msg != WM.NCDESTROY) return ret;

            hwndWrapper._Dispose(true, true);
            GC.SuppressFinalize(hwndWrapper);

            return ret;
        }
开发者ID:LionFree,项目名称:Cush,代码行数:38,代码来源:MessageWindow.cs

示例12: SendMessage

 public static extern int SendMessage(IntPtr hWnd, WM Msg, int wParam, int lParam);
开发者ID:0xwas,项目名称:LiveSplit.Video,代码行数:1,代码来源:GDI32.cs

示例13: _HandleNCCalcSize

        private IntPtr _HandleNCCalcSize(WM uMsg, IntPtr wParam, IntPtr lParam, out bool handled)
        {
            // lParam is an [in, out] that can be either a RECT* (wParam == FALSE) or an NCCALCSIZE_PARAMS*.
            // Since the first field of NCCALCSIZE_PARAMS is a RECT and is the only field we care about
            // we can unconditionally treat it as a RECT.

            // Since we always want the client size to equal the window size, we can unconditionally handle it
            // without having to modify the parameters.

            handled = true;
            return new IntPtr((int)WVR.REDRAW);
        }
开发者ID:JeremyDurnell,项目名称:ChromeTabs,代码行数:12,代码来源:WindowChromeWorker.cs

示例14: _HandleNCActivate

        private IntPtr _HandleNCActivate(WM uMsg, IntPtr wParam, IntPtr lParam, out bool handled)
        {
            // Despite MSDN's documentation of lParam not being used,
            // calling DefWindowProc with lParam set to -1 causes Windows not to draw over the caption.

            // Directly call DefWindowProc with a custom parameter
            // which bypasses any other handling of the message.
            IntPtr lRet = NativeMethods.DefWindowProc(_hwnd, WM.NCACTIVATE, wParam, new IntPtr(-1));
            handled = true;
            return lRet;
        }
开发者ID:JeremyDurnell,项目名称:ChromeTabs,代码行数:11,代码来源:WindowChromeWorker.cs

示例15: _HandleMove

        private IntPtr _HandleMove(WM uMsg, IntPtr wParam, IntPtr lParam, out bool handled)
        {
            // This is only intercepted to deal with bugs in Window in .Net 3.5 and below.
            Assert.IsTrue(Utility.IsPresentationFrameworkVersionLessThan4);

            if (_isUserResizing)
            {
                _hasUserMovedWindow = true;
            }

            handled = false;
            return IntPtr.Zero;
        }
开发者ID:JeremyDurnell,项目名称:ChromeTabs,代码行数:13,代码来源:WindowChromeWorker.cs


注:本文中的WM类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。