如何将软件输入面板(键盘)移动到Windows Mobile屏幕底部?

发布于 2024-12-01 03:30:39 字数 167 浏览 0 评论 0原文

我试图将键盘移至屏幕底部以隐藏 Windows Mobile 5/6 上默认显示的 35px 菜单栏。我见过的所有关于修改菜单栏的示例都涉及隐藏按钮“MS_SIPBUTTON”。我的问题分为两部分:

如何将键盘在屏幕上向下移动 35 像素?

并且,“MS_SIPBUTTON”在哪里定义?

I'm trying to move the keyboard to the bottom of the screen to hide the 35px menu bar that it shows by default on windows mobile 5/6. All of the examples I've seen about modifying the menu bar deal with hiding the button "MS_SIPBUTTON". The two parts of my question are:

How can I move the keyboard down 35 pixels on the screen?

And, where is "MS_SIPBUTTON" defined?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

清眉祭 2024-12-08 03:30:39

部分:

我移动键盘的最佳方法是从 pinvoke.net 引用的 Windows API 调用集合

第一 一堆 DllImport 语句:

        [DllImport("coredll.dll", SetLastError = true)]
        private static extern IntPtr FindWindow(string caption, string className);

        [DllImport("coredll.dll")]
        [return: MarshalAs(UnmanagedType.Bool)]
        public static extern bool GetWindowRect(IntPtr hwnd, out RECT lpRect);

        [DllImport("coredll.dll")]
        internal static extern void MoveWindow(IntPtr hwnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);

        [DllImport("coredll.dll", SetLastError = true)]
        extern static int SipShowIM(int dwFlag);

接下来是一些常量和变量:

        Rectangle sipbutton;
        Rectangle keyboardBackground;
        Rectangle keyboard;

        private const int SW_HIDE = 0;
        private const int SW_SHOW = 1;
        private const int GW_CHILD = 5;
        private const int SIPF_ON = 1;
        private const int SIPF_OFF = 0;

用于显示和隐藏页面底部显示的 SIP 按钮的函数。它们在我的构造函数和析构函数中被调用

            public void HideSip()
            {
                IntPtr hTaskBarWindow = FindWindow("MS_SIPBUTTON", null);
                if (hTaskBarWindow != IntPtr.Zero)
                {
                    RECT rct;

                    if (!GetWindowRect(hTaskBarWindow, out rct))
                    {
                        MessageBox.Show("ERROR");
                        return;
                    }

                    Rectangle myRect = new Rectangle();

                    myRect.X = (int)rct.Left;
                    myRect.Y = (int)rct.Top;
                    myRect.Width = (int)(rct.Right - rct.Left + 1);
                    myRect.Height = (int)(rct.Bottom - rct.Top + 1);

                    //save previous state
                    sipbutton = myRect;

                    MoveWindow(hTaskBarWindow, myRect.X, myRect.Y + 1000, myRect.Width, myRect.Height, true);
                    //MoveWindow(hTaskBarWindow, 100, 100, 100, 100, true);
                }
            }

            public void RestoreSip()
            {
                IntPtr hTaskBarWindow = FindWindow("MS_SIPBUTTON", null);
                if (hTaskBarWindow != IntPtr.Zero && sipbutton.Height > 0 && sipbutton.Width > 0)
                {
                    MoveWindow(hTaskBarWindow, sipbutton.X, sipbutton.Y, sipbutton.Width, sipbutton.Height, true);
                }
            }

,这样我们就需要将键盘向下移动到屏幕底部:

public void MoveKeyboardDown(int pixelsDown)
        {

            IntPtr hSipWindow = FindWindow("SipWndClass",null);
            if (hSipWindow != IntPtr.Zero)
            {
                RECT rct;

                if (!GetWindowRect(hSipWindow, out rct))
                {
                    MessageBox.Show("ERROR");
                    return;
                }

                Rectangle myRect = new Rectangle();

                myRect.X = (int)rct.Left;
                myRect.Y = (int)rct.Top;
                myRect.Width = (int)(rct.Right - rct.Left + 1);
                myRect.Height = (int)(rct.Bottom - rct.Top + 1);

                //save previous state
                keyboard = myRect;

                MoveWindow(hSipWindow, myRect.X, myRect.Y + pixelsDown, myRect.Width, myRect.Height, true);

            }

            IntPtr hSipWindow2 = FindWindow("SipBackDropWndClass",null);
            if (hSipWindow2 != IntPtr.Zero)
            {
                RECT rct;

                if (!GetWindowRect(hSipWindow2, out rct))
                {
                    MessageBox.Show("ERROR");
                    return;
                }

                Rectangle myRect = new Rectangle();

                myRect.X = (int)rct.Left;
                myRect.Y = (int)rct.Top;
                myRect.Width = (int)(rct.Right - rct.Left + 1);
                myRect.Height = (int)(rct.Bottom - rct.Top + 1);

                //save previous state
                keyboardBackground = myRect;

                MoveWindow(hSipWindow2, myRect.X, myRect.Y + pixelsDown, myRect.Width, myRect.Height, true);

            }


            arPages[iCurrentPage].Invalidate();
        }

        public void RestoreKeyboard()
        {

            IntPtr hSipWindow = FindWindow("SipWndClass", null);
            if (hSipWindow != IntPtr.Zero && keyboard.Height > 0 && keyboard.Width > 0)
            {
                MoveWindow(hSipWindow, keyboard.X, keyboard.Y, keyboard.Width, keyboard.Height, true);
            }

            IntPtr hSipWindow2 = FindWindow("SipBackDropWndClass", null);
            if (hSipWindow2 != IntPtr.Zero && keyboardBackground.Height > 0 && keyboardBackground.Width > 0)
            {
                MoveWindow(hSipWindow2, keyboardBackground.X, keyboardBackground.Y, keyboardBackground.Width, keyboardBackground.Height, true);
            }

        }

当您想显示键盘时,请执行以下操作:

    SipShowIM(SIPF_ON);
    MoveKeyboardDown(25);

当您想隐藏它时,请执行以下操作:

    SipShowIM(SIPF_OFF);
    RestoreKeyboard();

第二部分:

我能够使用 CE Remote Tools/Windows CE Remote Spy 发现上面引用的窗口的名称。可执行文件是“ccspy.exe”

Part one:

The best way I could muster to move the keyboard was a collection of Windows API calls all referenced from pinvoke.net

First a bunch of DllImport statements:

        [DllImport("coredll.dll", SetLastError = true)]
        private static extern IntPtr FindWindow(string caption, string className);

        [DllImport("coredll.dll")]
        [return: MarshalAs(UnmanagedType.Bool)]
        public static extern bool GetWindowRect(IntPtr hwnd, out RECT lpRect);

        [DllImport("coredll.dll")]
        internal static extern void MoveWindow(IntPtr hwnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);

        [DllImport("coredll.dll", SetLastError = true)]
        extern static int SipShowIM(int dwFlag);

Next some constants and variables:

        Rectangle sipbutton;
        Rectangle keyboardBackground;
        Rectangle keyboard;

        private const int SW_HIDE = 0;
        private const int SW_SHOW = 1;
        private const int GW_CHILD = 5;
        private const int SIPF_ON = 1;
        private const int SIPF_OFF = 0;

Functions for showing and hiding the SIP button that displays at the bottom of the page. They are called in my constructor and destructor

            public void HideSip()
            {
                IntPtr hTaskBarWindow = FindWindow("MS_SIPBUTTON", null);
                if (hTaskBarWindow != IntPtr.Zero)
                {
                    RECT rct;

                    if (!GetWindowRect(hTaskBarWindow, out rct))
                    {
                        MessageBox.Show("ERROR");
                        return;
                    }

                    Rectangle myRect = new Rectangle();

                    myRect.X = (int)rct.Left;
                    myRect.Y = (int)rct.Top;
                    myRect.Width = (int)(rct.Right - rct.Left + 1);
                    myRect.Height = (int)(rct.Bottom - rct.Top + 1);

                    //save previous state
                    sipbutton = myRect;

                    MoveWindow(hTaskBarWindow, myRect.X, myRect.Y + 1000, myRect.Width, myRect.Height, true);
                    //MoveWindow(hTaskBarWindow, 100, 100, 100, 100, true);
                }
            }

            public void RestoreSip()
            {
                IntPtr hTaskBarWindow = FindWindow("MS_SIPBUTTON", null);
                if (hTaskBarWindow != IntPtr.Zero && sipbutton.Height > 0 && sipbutton.Width > 0)
                {
                    MoveWindow(hTaskBarWindow, sipbutton.X, sipbutton.Y, sipbutton.Width, sipbutton.Height, true);
                }
            }

With that out of the way we need to move the keyboard down to the bottom of the screen:

public void MoveKeyboardDown(int pixelsDown)
        {

            IntPtr hSipWindow = FindWindow("SipWndClass",null);
            if (hSipWindow != IntPtr.Zero)
            {
                RECT rct;

                if (!GetWindowRect(hSipWindow, out rct))
                {
                    MessageBox.Show("ERROR");
                    return;
                }

                Rectangle myRect = new Rectangle();

                myRect.X = (int)rct.Left;
                myRect.Y = (int)rct.Top;
                myRect.Width = (int)(rct.Right - rct.Left + 1);
                myRect.Height = (int)(rct.Bottom - rct.Top + 1);

                //save previous state
                keyboard = myRect;

                MoveWindow(hSipWindow, myRect.X, myRect.Y + pixelsDown, myRect.Width, myRect.Height, true);

            }

            IntPtr hSipWindow2 = FindWindow("SipBackDropWndClass",null);
            if (hSipWindow2 != IntPtr.Zero)
            {
                RECT rct;

                if (!GetWindowRect(hSipWindow2, out rct))
                {
                    MessageBox.Show("ERROR");
                    return;
                }

                Rectangle myRect = new Rectangle();

                myRect.X = (int)rct.Left;
                myRect.Y = (int)rct.Top;
                myRect.Width = (int)(rct.Right - rct.Left + 1);
                myRect.Height = (int)(rct.Bottom - rct.Top + 1);

                //save previous state
                keyboardBackground = myRect;

                MoveWindow(hSipWindow2, myRect.X, myRect.Y + pixelsDown, myRect.Width, myRect.Height, true);

            }


            arPages[iCurrentPage].Invalidate();
        }

        public void RestoreKeyboard()
        {

            IntPtr hSipWindow = FindWindow("SipWndClass", null);
            if (hSipWindow != IntPtr.Zero && keyboard.Height > 0 && keyboard.Width > 0)
            {
                MoveWindow(hSipWindow, keyboard.X, keyboard.Y, keyboard.Width, keyboard.Height, true);
            }

            IntPtr hSipWindow2 = FindWindow("SipBackDropWndClass", null);
            if (hSipWindow2 != IntPtr.Zero && keyboardBackground.Height > 0 && keyboardBackground.Width > 0)
            {
                MoveWindow(hSipWindow2, keyboardBackground.X, keyboardBackground.Y, keyboardBackground.Width, keyboardBackground.Height, true);
            }

        }

When you want to show the keyboard do some thing like this:

    SipShowIM(SIPF_ON);
    MoveKeyboardDown(25);

When you want to hide it do this:

    SipShowIM(SIPF_OFF);
    RestoreKeyboard();

Part two:

I was able to discover the names of windows referenced above using CE Remote Tools/Windows CE Remote Spy. The executable is "ccspy.exe"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文