InputPanel - Please Help

M

Mark Irvine

Hi,

I am trying to get the input panel to work with my app, but each time I try
an exception is thrown (no useful info included in the exception.). However
whenever I try to run the code on
http://samples.gotdotnet.com/quickstart/CompactFramework/doc/inputpanel.aspx
or the code included for chapter 4 of the .net compact framework core
reference (ms press), everything works fine. I have looked at the code
many, many time but just can't see what is causing the problem. My code is
below:

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using Microsoft.WindowsCE.Forms;
namespace Nihco.Mobile
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class frmLogon : System.Windows.Forms.Form
{
public System.Windows.Forms.TextBox txtUserName;
private System.Windows.Forms.Label lblPassword;
private System.Windows.Forms.TextBox txtPassword;
private System.Windows.Forms.Button btnLogon;
private System.Windows.Forms.Button btnCancel;
private Microsoft.WindowsCE.Forms.InputPanel inputPanel1;
private System.Windows.Forms.Label lblUserName;
public frmLogon()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.txtUserName = new System.Windows.Forms.TextBox();
this.lblUserName = new System.Windows.Forms.Label();
this.lblPassword = new System.Windows.Forms.Label();
this.txtPassword = new System.Windows.Forms.TextBox();
this.btnLogon = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
this.inputPanel1 = new Microsoft.WindowsCE.Forms.InputPanel();
//
// txtUserName
//
this.txtUserName.Location = new System.Drawing.Point(88, 8);
this.txtUserName.Text = "";
this.txtUserName.LostFocus += new
System.EventHandler(this.txtUserName_LostFocus);
this.txtUserName.GotFocus += new
System.EventHandler(this.txtUserName_GotFocus);
//
// lblUserName
//
this.lblUserName.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F,
System.Drawing.FontStyle.Bold);
this.lblUserName.Location = new System.Drawing.Point(8, 8);
this.lblUserName.Size = new System.Drawing.Size(70, 20);
this.lblUserName.Text = "Username:";
//
// lblPassword
//
this.lblPassword.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F,
System.Drawing.FontStyle.Bold);
this.lblPassword.Location = new System.Drawing.Point(8, 40);
this.lblPassword.Size = new System.Drawing.Size(70, 20);
this.lblPassword.Text = "Password:";
//
// txtPassword
//
this.txtPassword.Location = new System.Drawing.Point(88, 40);
this.txtPassword.PasswordChar = '*';
this.txtPassword.Text = "";
this.txtPassword.LostFocus += new
System.EventHandler(this.txtPassword_LostFocus);
this.txtPassword.GotFocus += new
System.EventHandler(this.txtPassword_GotFocus);
//
// btnLogon
//
this.btnLogon.Location = new System.Drawing.Point(8, 96);
this.btnLogon.Text = "Logon";
this.btnLogon.Click += new System.EventHandler(this.btnLogon_Click);
//
// btnCancel
//
this.btnCancel.Location = new System.Drawing.Point(16, 128);
this.btnCancel.Text = "Cancel";
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// inputPanel1
//
this.inputPanel1.EnabledChanged += new
System.EventHandler(this.inputPanel1_EnabledChanged);
//
// frmLogon
//
this.ClientSize = new System.Drawing.Size(216, 104);
this.ControlBox = false;
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnLogon);
this.Controls.Add(this.txtPassword);
this.Controls.Add(this.lblPassword);
this.Controls.Add(this.lblUserName);
this.Controls.Add(this.txtUserName);
this.Text = "Logon";
this.Load += new System.EventHandler(this.frmLogon_Load);
}
#endregion
private void txtUserName_GotFocus(object sender, System.EventArgs e)
{
inputPanel1.Enabled = true;
}
private void txtUserName_LostFocus(object sender, System.EventArgs e)
{
inputPanel1.Enabled = false;
}
private void txtPassword_GotFocus(object sender, System.EventArgs e)
{
inputPanel1.Enabled = true;
}
private void txtPassword_LostFocus(object sender, System.EventArgs e)
{
inputPanel1.Enabled = false;
}
private void btnLogon_Click(object sender, System.EventArgs e)
{
this.DialogResult = DialogResult.OK;
}
private void btnCancel_Click(object sender, System.EventArgs e)
{
this.DialogResult = DialogResult.Cancel;
}
private void frmLogon_Load(object sender, System.EventArgs e)
{
}
private void inputPanel1_EnabledChanged(object sender, System.EventArgs e)
{
}
}
}

Can anyone help?

Mark
 
M

Mark Irvine

Tim,

Many thanks for your reply. I followed the link and dowloaded SP2. However
the installer appeared to hang when try to connect to the PocketPC.
Although I cannot explain why, I don't think it is a problem with the
runtime - as other code works.

Mark
 
T

Tim Wilson

I pointed you to the SP2 download because it fixes a few bugs with the
InputPanel - one of which is the following:
"Setting the InputPanel.Enabled property when the form is closing throws an
exception"
Since you are using LostFocus handlers and setting the Enabled property of
the InputPanel this could be an issue that you are seeing as focus could be
getting pulled when the Form is closing.

As for the installer hanging, you will want to make sure that the ActiveSync
connection has been properly established for your device. And a reboot of
everything (your desktop PC and PPC) couldn't hurt either.
 
M

Mark Irvine

Tim, Martin,

Many thanks to both of you for your replies. I decided to use the code from
the .net CF core reference and remove the various controls one by one to see
when the code stopped working. An sure enough when I removed the MainMenu
control, it stopped working!

Thanks again to you both,

Mark
 
T

Tim Wilson

I've had no problems using the InputPanel without the MainMenu on the Form.
However, I am running SP2 and I didn't specifically check this behavior
prior to the install. Are you running SP2?
 
T

Tim Wilson

I see by your other post that you're not running SP2. If you decide to
upgrade to SP2 you might want to check to see if the InputPanel still gives
you trouble when no MainMenu is present and if so report this behavior back
to the newsgroup for investigation.
 
M

Mark Irvine

Tim,

I did upgrade to SP2, I had to do a soft reset on the device before the
install routine would work. I also noticed that I could not browse the
device from Explorer, but this too was fixed by the soft reset. I have done
as you asked and removed the MainMenu from the application, and the
InputPanel is working perfectly.

Mark
 
T

Tim Wilson

So is everything working as you expect it to now? You can get the InputPanel
to work with or without a MainMenu?
 
B

Boris Nienke

I pointed you to the SP2 download because it fixes a few bugs with the
InputPanel - one of which is the following:
"Setting the InputPanel.Enabled property when the form is closing throws an
exception"
Since you are using LostFocus handlers and setting the Enabled property of
the InputPanel this could be an issue that you are seeing as focus could be
getting pulled when the Form is closing.

i have work-around this by doing it inside a Try-Catch:

try
{
inputPanel1.enabled = false;
}
catch
{
}

Boris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top