PhilChuang.com
Software Development, Politics, Football, Music, Videogames, you name it!

Automatically resizing Windows Mobile Forms when the SIP is shown

This was bugging me for awhile, but it took me until now to get around to fixing it.

I had an issue with forms with text boxes near the bottom, and when the SIP (on-screen keyboard) is shown, then it completely hides the textbox.   So I went googling and found this:

Manage soft input panel (SIP)

And with that knowledge, wrote a quick util method to automatically add this behavior:

 

public static void AddAutoInputPanelResizing (Control parent, IContainer iContainer)
{
	var p = new Panel
	{
		Height = 0,
		Visible = false,
		Name = "SIP Placeholder",
		Dock = DockStyle.Bottom,
	};
	parent.Controls.Add (p);
	p.SendToBack ();

	var ip = new InputPanel (iContainer);
	ip.EnabledChanged +=
		(sender, e) =>
		{
			parent.SuspendLayout ();
			p.Visible = ip.Enabled;
			p.Height = ip.Bounds.Height;
			parent.ResumeLayout ();
		};
}

Posted Jun 08 2010, 11:46 PM by Phil Chuang
Filed under: ,

Add a Comment

(required)  
(optional)
(required)  
Remember Me?
(c) 2008 PhilChuang.com
Powered by Community Server (Non-Commercial Edition), by Telligent Systems