我可以在.NET Compact Framework中控制SIP(软件输入面板)的位置吗?

时间:2010-01-11 21:54:51

标签: windows-mobile compact-framework mobile

我想显示SIP,但是我想在屏幕上显示它比默认显示的更高。有没有办法垂直定位SIP?

3 个答案:

答案 0 :(得分:3)

是的,但这取决于您运行的平台;并非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#代码。

答案 1 :(得分:2)

在清除SetSipInfo和所需位置的情况下致电SIPF_DOCKED bit

答案 2 :(得分:1)

/// <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);