all groups > dotnet windows forms > september 2004 >
You're in the

dotnet windows forms

group:

Accessing the tablet buttons in IE


Accessing the tablet buttons in IE Peter Kron
9/19/2004 2:07:40 PM
dotnet windows forms:
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

Re: Accessing the tablet buttons in IE Stefan Wick[MS]
9/25/2004 8:43:07 AM
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
--
This posting is provided "AS IS" with no warranties, and confers no
rights. Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

[quoted text, click to view]

Re: Accessing the tablet buttons in IE Peter Kron
9/26/2004 6:26:34 PM
That's what I eventually figured out. Thanks for the response!

[quoted text, click to view]

AddThis Social Bookmark Button