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


C# WM.ToString方法代码示例

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


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

示例1: OnKeyInternal

    private static bool OnKeyInternal(WM ev, VK vk, SC sc, LLKHF flags)
    {
        CheckKeyboardLayout();

        bool is_keydown = (ev == WM.KEYDOWN || ev == WM.SYSKEYDOWN);
        bool is_keyup = !is_keydown;

        bool has_shift = (NativeMethods.GetKeyState(VK.SHIFT) & 0x80) != 0;
        bool has_altgr = (NativeMethods.GetKeyState(VK.LCONTROL) &
                          NativeMethods.GetKeyState(VK.RMENU) & 0x80) != 0;
        bool has_lrshift = (NativeMethods.GetKeyState(VK.LSHIFT) &
                            NativeMethods.GetKeyState(VK.RSHIFT) & 0x80) != 0;
        bool has_capslock = NativeMethods.GetKeyState(VK.CAPITAL) != 0;

        // Guess what key was just pressed. If we can not find a printable
        // representation for the key, default to its virtual key code.
        Key key = new Key(vk);

        byte[] keystate = new byte[256];
        NativeMethods.GetKeyboardState(keystate);
        keystate[(int)VK.SHIFT] = (byte)(has_shift ? 0x80 : 0x00);
        keystate[(int)VK.CONTROL] = (byte)(has_altgr ? 0x80 : 0x00);
        keystate[(int)VK.MENU] = (byte)(has_altgr ? 0x80 : 0x00);
        keystate[(int)VK.CAPITAL] = (byte)(has_capslock ? 0x01 : 0x00);



        string str_if_normal = KeyToUnicode(vk, sc, keystate, flags);
        string str_if_dead = KeyToUnicode(VK.SPACE);
        if (str_if_normal != "")
        {
            // This appears to be a normal, printable key
            key = new Key(str_if_normal);
        }
        else if (str_if_dead != " ")
        {
            // This appears to be a dead key
            key = new Key(str_if_dead);
        }

        // Special case: we don't consider characters such as Esc as printable
        // otherwise they are not properly serialised in the config file.
        if (key.IsPrintable() && key.ToString()[0] < ' ')
        {
            key = new Key(vk);
        }

        Log("WM.{0} {1} (VK:0x{2:X02} SC:0x{3:X02})",
            ev.ToString(), key.FriendlyName, (int)vk, (int)sc);

        // FIXME: we don’t properly support compose keys that also normally
        // print stuff, such as `.
        if (key == Settings.ComposeKey.Value)
        {
            if (is_keyup)
            {
                // If we receive a keyup for the compose key, but we hadn't
                // previously marked it as down, it means we're in emulation
                // mode and we need to cancel it.
                if (!m_compose_down)
                {
                    Log("Fallback Off");
                    SendKeyUp(Settings.ComposeKey.Value.VirtualKey);
                }

                m_compose_down = false;
            }
            else if (is_keydown && !m_compose_down)
            {
                // FIXME: we don't want compose + compose to disable composing,
                // since there are compose sequences that use Multi_key.
                // FIXME: also, if a sequence was in progress, print it!
                m_compose_down = true;
                m_composing = !m_composing;
                if (!m_composing)
                    m_sequence.Clear();

                Log("{0} Composing", m_composing ? "Now" : "No Longer");

                // Lauch the sequence reset expiration thread
                // FIXME: do we need to launch a new thread each time the
                // compose key is pressed? Let's have a dormant thread instead
                if (m_composing && Settings.ResetDelay.Value > 0)
                {
                    new Thread(() =>
                    {
                        while (m_composing && DateTime.Now < m_last_key_time.AddMilliseconds(Settings.ResetDelay.Value))
                            Thread.Sleep(50);
                        ResetSequence();
                    }).Start();
                }
            }

            Changed(null, new EventArgs());

            return true;
        }

        // Feature: emulate capslock key with both shift keys, and optionally
        // disable capslock using only one shift key.
//.........这里部分代码省略.........
开发者ID:carter-lavering,项目名称:wincompose,代码行数:101,代码来源:Composer.cs


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