by Leif R?n Pedersen (1 Submission)
Category: Custom Controls/Forms/Menus
Compatability: VB.NET
Difficulty: Unknown Difficulty
Originally Published: Mon 7th January 2008
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Controlling the Soft Input Panel (SIP) in Compact framework. I wrote this code, because I was dissatisfied, if the textbox in focus was hidden
API Declarations
' ToolBox and drag it into the form.
' We have to dispose the InputPanel, otherwise the EnabledChange event
' will be fired, even if we have closed the form
' Call this method from the form Closed event.
Try
If IsNothing(SIP) = False Then
SIP.Dispose()
End If
Catch ex As Exception
End Try
End Sub
Public Sub SIPEnable(ByRef frm As Form, ByRef SIP As Microsoft.WindowsCE.Forms.InputPanel)
' This method shows the InputPanel. It is implemented because of error
' handling.
Try
SIP.Enabled = True
Catch ex As Exception
End Try
End Sub
Public Sub SIPDisable(ByRef frm As Form, ByRef SIP As Microsoft.WindowsCE.Forms.InputPanel)
' This method hides the InputPanel. It is implemented because of error
' handling.
Try
SIP.Enabled = False
Catch ex As Exception
End Try
End Sub
Public Sub SIPEnabledChanged(ByRef frm As Form, ByVal SIP As Microsoft.WindowsCE.Forms.InputPanel)
' Call this method from the InputPanel's EnabledChanged event.
Try
SIPMoveControl(frm, SIP)
Catch ex As Exception
End Try
End Sub
Public Sub SIPMoveControl(ByRef frm As Form, ByVal SIP As Microsoft.WindowsCE.Forms.InputPanel)
Dim p As Point
If SIP.Enabled = True Then
' try to find a textbox, which has focus
For Each c As Control In frm.Controls
If TypeOf c Is TextBox Then
If c.Focused = True Then
' calculate new coordinates o the textbox, so it's
' visible
p = c.Location
p.Y = SIP.VisibleDesktop.Height - c.Height - 2
If p.Y < 0 Then
p.Y = 0
End If
' only move textbox, if it's necessary
If p.Y < c.Location.Y Then
' save the original location in the textbox's
' Tag property
c.Tag = "Moved by SIP;" & CStr(c.Location.X) & ";" & CStr(c.Location.Y)
' move the textbox to the new visible location
c.Location = p
c.BringToFront()
frm.Refresh()
End If
Exit For
End If
End If
Next
Else
' move the textbox back to it's original location
Dim parm() As String
For Each c As Control In frm.Controls
' find the textbox, which is moved
If IsNothing(c.Tag) = False AndAlso c.Tag.ToString.Substring(0, 12) = "Moved by SIP" Then
' get the location from the Tag property
parm = c.Tag.ToString.Split(CType(";", Char))
p.X = CType(parm(1), Integer)
p.Y = CType(parm(2), Integer)
' move the textbox back and clear the Tag property
c.Location = p
c.Tag = Nothing
frm.Refresh()
Exit For
End If
Next
End If
p = Nothing
End Sub
No comments have been posted about Controlling the Soft Input Panel (SIP) in Compact framework. I wrote this code, because I was dissa. Why not be the first to post a comment about Controlling the Soft Input Panel (SIP) in Compact framework. I wrote this code, because I was dissa.