J
JDeats
I'm trying to figure out how best to handle a combination of key
events for WinFoms (C# 2.0 VS.NET 2005). I have
created a MessageFilter to parse out parameters from the API
WM_KEYDOWN message and I am applying in Program.cs Main() with:
Application.AddMessageFilter(... See below for partial source code for
my message filter.
My problem is with this method there are a few keys I can trap on.
Specifically the 'Alt' key and the 'Fn' key found on my notebook
computers is a real problem. I need my WinForms application to trap on
the keyboard sequence a user would go through to trigger the Windows
OS screen capture function (Fn + PrtSc on notebook or just Alt PrtScr
on Desktop). What would be the best method to do this?
public class KeyboardMsgFilter : IMessageFilter
{
public delegate void KeyboardEvent(object source, string
keyVal);
public event KeyboardEvent KeyPressed;
public bool PreFilterMessage(ref Message m)
{
string key = "";
const int WM_KEYDOWN = 0x0100;
// Blocks all the messages relating to the left mouse
button.
if (m.Msg == WM_KEYDOWN)
{
int keycode = Convert.ToInt32(m.LParam.ToString());
switch (keycode)
{
case 1179649 :
key = "E";
break;
case 1245185 :
key = "R";
break;
events for WinFoms (C# 2.0 VS.NET 2005). I have
created a MessageFilter to parse out parameters from the API
WM_KEYDOWN message and I am applying in Program.cs Main() with:
Application.AddMessageFilter(... See below for partial source code for
my message filter.
My problem is with this method there are a few keys I can trap on.
Specifically the 'Alt' key and the 'Fn' key found on my notebook
computers is a real problem. I need my WinForms application to trap on
the keyboard sequence a user would go through to trigger the Windows
OS screen capture function (Fn + PrtSc on notebook or just Alt PrtScr
on Desktop). What would be the best method to do this?
public class KeyboardMsgFilter : IMessageFilter
{
public delegate void KeyboardEvent(object source, string
keyVal);
public event KeyboardEvent KeyPressed;
public bool PreFilterMessage(ref Message m)
{
string key = "";
const int WM_KEYDOWN = 0x0100;
// Blocks all the messages relating to the left mouse
button.
if (m.Msg == WM_KEYDOWN)
{
int keycode = Convert.ToInt32(m.LParam.ToString());
switch (keycode)
{
case 1179649 :
key = "E";
break;
case 1245185 :
key = "R";
break;