Accessing the tablet buttons in IE

  • Thread starter Thread starter Peter Kron
  • Start date Start date
P

Peter Kron

I'd like to use the tablet buttons for navigation on a WinForms control I'm
writing, which will be hosted by IE.

However, the tablet buttons are typically mapped to VK_UP and VK_DOWN which
get trapped by the control for scrolling and don't generate OnKeyDown
events. To get at them, you typically override ProcessCmdKey. The problem is
that this requires UIPermission.AllWindows and you don't get that with a
control downloaded by IE.

Is there a way to handle these buttons without requiring more than the
default Internet CAS trust?

Thanks
 
Hello Peter,

you can sink the OnKeyDown in script code off your web page's body and
forward the key code to your Winforms control. Would that work for your
scenario?

See sample C# and HTML code below.

using System;
using System.Drawing;
using System.Windows.Forms;

namespace WebControl
{
public class MyControl : UserControl
{
Label label;

public MyControl()
{
label = new Label();
label.Parent = this;
}

public void ForwardKeyDown(object o)
{
label.Text = o.ToString();
}
}
}

------

<html>
<HEAD>
<script language="jscript">
function KeyDown()
{
myControl.ForwardKeyDown(event.keyCode);
}
</script>
</HEAD>
<body onkeydown="KeyDown()">
<OBJECT id="myControl" height="80%" width="80%" border="1"
classid="ClassLibrary1.dll#WebControl.MyControl"/>
</body>
</HTML>

Thanks,
Stefan Wick
 
Back
Top