Imports System.Runtime.InteropServicesPublic Class SipClass#Region "API" <DllImport("coredll.dll", CharSet:=CharSet.Unicode, SetLastError:=True)> _ Private Shared Function SipShowIM(ByVal dwFlag As SIPStatus) As Integer End Function <DllImport("coredll.dll", CharSet:=CharSet.Unicode, SetLastError:=True)> _ Private Shared Function SipSetInfo(ByRef pSipInfo As SIPINFO) As Boolean End Function <DllImport("coredll.dll", CharSet:=CharSet.Unicode, SetLastError:=True)> _ Private Shared Function SipGetInfo(ByRef pSipInfo As SIPINFO) As Boolean End Function#End Region#Region "枚举" Private Enum SIPStatus SIPF_OFF = 0 SIPF_ON End Enum#End Region#Region "结构" Private Structure SIPINFO Public CbSize As Integer Public FdwFlags As SIPStatus Public RcVisibleDesktop As RECT Public RcSipRect As RECT Public DwImDataSize As Integer Public PvImData As Integer End Structure Private Structure RECT Public Left As Integer Public Top As Integer Public Right As Integer Public Bottom As Integer Public ReadOnly Property Width() As Integer Get Return Right - Left End Get End Property Public ReadOnly Property Height() As Integer Get Return Bottom - Top End Get End Property End Structure#End Region#Region "公共方法" ''' <summary> ''' 显示输入面板 ''' </summary> ''' <remarks></remarks> Public Shared Function Show() As Boolean Return SipShowIM(SIPStatus.SIPF_ON) End Function ''' <summary> ''' 影藏输入面板 ''' </summary> ''' <remarks></remarks> Public Shared Function Hide() As Boolean Return SipShowIM(SIPStatus.SIPF_OFF) End Function ''' <summary> ''' 显示输入面板,并设定面板的位置 ''' </summary> ''' <param name="Location"></param> ''' <returns></returns> ''' <remarks></remarks> Public Shared Function SetPosition(ByVal Location As Point) As Boolean Dim mySi As SIPINFO mySi.CbSize = Marshal.SizeOf(GetType(SIPINFO)) Call SipGetInfo(mySi) mySi.RcSipRect.Top = Location.Y mySi.RcSipRect.Bottom = Location.Y + mySi.RcSipRect.Height mySi.RcSipRect.Left = Location.X mySi.RcSipRect.Right = Location.X + mySi.RcSipRect.Width mySi.FdwFlags = SIPStatus.SIPF_ON Return SipSetInfo(mySi) End Function#End RegionEnd Class
复制代码