【问题标题】:Can I control position of SIP ( Software Input Panel ) in .NET Compact Framework?我可以在 .NET Compact Framework 中控制 SIP(​​软件输入面板)的位置吗?
【发布时间】:2011-01-03 22:51:11
【问题描述】:

我想显示 SIP,但我想在屏幕上显示的位置比默认显示的位置高一点。有没有办法垂直放置 SIP?

【问题讨论】:

    标签: windows-mobile compact-framework mobile


    【解决方案1】:

    是的,但这取决于您运行的平台;并非所有 SIP 实现都允许您移动它,尤其是那些在 Windows Mobile 上的实现。 (Windows Mobile基于基于 Windows CE,本质上是通过 Platform Builder 创建的特定版本,但并非所有运行 Windows CE 的设备都“插入”了相同的平台组件。)I blogged about doing this in an application that runs on a version of Windows CE a few months ago. 您将在那里找到示例 C# 代码。

    【讨论】:

    【解决方案2】:
    /// <summary>
    /// Sets the location of the SIP
    /// </summary>
    /// <param name="x">x coordinate of the SIP</param>
    /// <param name="y">y coordinate of the SIP</param>
    public static void SetSipLocation(int x, int y)
    {
        try
        {
            NativeMethods.SIPINFO info = new NativeMethods.SIPINFO();
            info.cbSize = Marshal.SizeOf(info);
    
            if (NativeMethods.SipGetInfo(out info))
            {
                info.rcSipRect.right = (info.rcSipRect.right -
                    info.rcSipRect.left) + x;
                info.rcSipRect.left = x;
    
                info.rcSipRect.bottom = (info.rcSipRect.bottom -
                    info.rcSipRect.top) + y;
                info.rcSipRect.top = y;
    
                NativeMethods.SipSetInfo(out info);
            }
        }
        catch (DllNotFoundException)
        {
        }
        catch (MissingMethodException)
        {
        }
    }
    
    /// <summary>
    /// This structure contains information about the current state of the input panel, such as the input panel size, screen location, docked status, and visibility status.
    /// </summary>
    [StructLayout(LayoutKind.Sequential)]
    internal struct SIPINFO
    {
        /// <summary>
        /// Size, in bytes, of the SIPINFO structure. This member must be filled in by the application with the size of operator. Because the system can check the size of the structure to determine the operating system version number, this member allows for future enhancements to the SIPINFO structure while maintaining backward compatibility.
        /// </summary>
        public int cbSize;
    
        /// <summary>
        /// Specifies flags representing state information of the input panel. It is any combination of the following bit flags:
        /// Value               Description
        /// SIPF_DOCKED         The input panel is docked, or not floating.
        /// SIPF_LOCKED         The input panel is locked, meaning that the user cannot change its visible status.
        /// SIPF_OFF            The input panel is off, or not visible.
        /// SIPF_ON             The input panel is on, or visible.
        /// </summary>
        public uint fdwFlags;
    
        /// <summary>
        /// Rectangle, in screen coordinates, that represents the area of the desktop not obscured by the input panel. If the input panel is floating, this rectangle is equivalent to the working area. Full-screen applications that respond to input panel size changes can set their window rectangle to this rectangle. If the input panel is docked but does not occupy an entire edge, then this rectangle represents the largest rectangle not obscured by the input panel. If an application wants to use the screen space around the input panel, it needs to reference rcSipRect.
        /// </summary>
        public RECT rcVisibleDesktop;
    
        /// <summary>
        /// Rectangle, in screen coordinates of the window rectangle and not the client area, the represents the size and location of the input panel. An application does not generally use this information unless it needs to wrap around a floating or a docked input panel that does not occupy an entire edge.
        /// </summary>
        public RECT rcSipRect;
    
        /// <summary>
        /// Specifies the size of the data pointed to by the pvImData member.
        /// </summary>
        public uint dwImDataSize;
    
        /// <summary>
        /// Void pointer to input method (IM)-defined data. The IM calls the IInputMethod::GetImData and IInputMethod::SetImData methods to send and receive information from this structure. 
        /// </summary>
        public IntPtr pvImData;
    }
    
    /// <summary>
    /// This structure defines the coordinates of the upper-left and lower-right corners of a rectangle. 
    /// </summary>
    [StructLayout(LayoutKind.Sequential)]
    internal struct RECT
    {
        /// <summary>
        /// Specifies the x-coordinate of the upper-left corner of the rectangle.
        /// </summary>
        public int left;
    
        /// <summary>
        /// Specifies the y-coordinate of the upper-left corner of the rectangle.
        /// </summary>
        public int top;
    
        /// <summary>
        /// Specifies the x-coordinate of the lower-right corner of the rectangle. 
        /// </summary>
        public int right;
    
        /// <summary>
        /// Specifies the y-coordinate of the lower-right corner of the rectangle.
        /// </summary>
        public int bottom;
    }
    

    在 NativeMethods 类中:

        /// <summary>
        /// This function receives information including the state of the software-based input panel, the area of the desktop that is not obscured by the software-based input panel, the screen coordinates of the software-based input panel, and information about the input method (IM) that the software-based input panel is currently using.
        /// </summary>
        /// <param name="info">[out] Pointer to the SIPINFO structure that contains information about the current software-based input panel.</param>
        /// <returns>TRUE indicates success. FALSE indicates failure. To get extended error information, call GetLastError.</returns>
        [DllImport("coredll.dll")]
        [return: MarshalAs(UnmanagedType.Bool)]
        internal static extern bool SipGetInfo(out SIPINFO info);
    

    【讨论】:

      【解决方案3】:

      呼叫SetSipInfo,清除SIPF_DOCKED bit 和所需位置。

      【讨论】:

        猜你喜欢
        • 2010-12-23
        • 2010-09-28
        • 1970-01-01
        • 1970-01-01
        • 2011-01-02
        • 2015-04-25
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多