473,238 Members | 1,850 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,238 software developers and data experts.

how to override IsInputKey(..) function?

I would like to override the IsInputKey function in order
to trap the arrow up/down keys in the Key Events. I
understand that arrow keys don't have a char
representation and thus, hard to trap. Someone wrote this
override for IsInputKey in C# which apparently worked, and
I tried to convert it to VB.Net but not working. Here is
the C# version and following - my conversion. It would be
great if anyone out there knows how to do this correctly.
Do I need to import/inherit anything? Error says my
override version has different access level than the
original IsInputKey.

C# version (article at
http://www.dotnet247.com/247reference/msgs/2/14108.aspx)

const char myLeft = (char)252;
const char myRight = (char)253;
const char myUp = (char)254;
const char myDown = (char)255;

protected override bool IsInputKey(Keys key) {
switch (key) {
case Keys.Left:
OnKeyPress(new KeyPressEventArgs(myLeft));
return true;
case Keys.Right:
OnKeyPress(new KeyPressEventArgs(myRight));
return true;
case Keys.Up:
OnKeyPress(new KeyPressEventArgs(myUp));
return true;
case Keys.Down:
OnKeyPress(new KeyPressEventArgs(myDown));
return true;
default:
return base.IsInputKey(key);
}
}

My Version in VB.Net

Const myLeft = Chr(37)
Const myRight = Chr(39)
Const myUp = Chr(38)
Const myDown = Chr(40)

Overrides Function IsInputKey(ByVal key As Keys) As Boolean
Select Case key
Case Keys.Left
OnKeyPress(New KeyPressEventArgs(myLeft))
Return True
Case Keys.Right
OnKeyPress(New KeyPressEventArgs(myRight))
Return True
Case Keys.Up
OnKeyPress(New KeyPressEventArgs(myUp))
Return True
Case Keys.Down
OnKeyPress(New KeyPressEventArgs(myDown))
Return True
Case Else
Return True
End Select
End Function
Nov 20 '05 #1
1 6813
instead of using KeyPress event, have a look at KeyUp event
that one is raised just after keypress and holds the keycode in het
eventArgs
there you can check for special keys (esc, arrows, function keys,...)
Dominique
"Steve" <an*******@discussions.microsoft.com> wrote in message
news:6b****************************@phx.gbl...
I would like to override the IsInputKey function in order
to trap the arrow up/down keys in the Key Events. I
understand that arrow keys don't have a char
representation and thus, hard to trap. Someone wrote this
override for IsInputKey in C# which apparently worked, and
I tried to convert it to VB.Net but not working. Here is
the C# version and following - my conversion. It would be
great if anyone out there knows how to do this correctly.
Do I need to import/inherit anything? Error says my
override version has different access level than the
original IsInputKey.

C# version (article at
http://www.dotnet247.com/247reference/msgs/2/14108.aspx)

const char myLeft = (char)252;
const char myRight = (char)253;
const char myUp = (char)254;
const char myDown = (char)255;

protected override bool IsInputKey(Keys key) {
switch (key) {
case Keys.Left:
OnKeyPress(new KeyPressEventArgs(myLeft));
return true;
case Keys.Right:
OnKeyPress(new KeyPressEventArgs(myRight));
return true;
case Keys.Up:
OnKeyPress(new KeyPressEventArgs(myUp));
return true;
case Keys.Down:
OnKeyPress(new KeyPressEventArgs(myDown));
return true;
default:
return base.IsInputKey(key);
}
}

My Version in VB.Net

Const myLeft = Chr(37)
Const myRight = Chr(39)
Const myUp = Chr(38)
Const myDown = Chr(40)

Overrides Function IsInputKey(ByVal key As Keys) As Boolean
Select Case key
Case Keys.Left
OnKeyPress(New KeyPressEventArgs(myLeft))
Return True
Case Keys.Right
OnKeyPress(New KeyPressEventArgs(myRight))
Return True
Case Keys.Up
OnKeyPress(New KeyPressEventArgs(myUp))
Return True
Case Keys.Down
OnKeyPress(New KeyPressEventArgs(myDown))
Return True
Case Else
Return True
End Select
End Function

Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Josh Lessard | last post by:
Hi all. I'm maintaining a C++ program and I've come across a nasty piece of code that works, but I just don't understand why. I'm not actually this part of the program, but I really want to know...
6
by: Angus Comber | last post by:
Hello I have a base class a bit like this: class CTapiCall { // Constructor public: CTapiCall(); virtual ~CTapiCall();
6
by: Angus Comber | last post by:
Hello I have a base class a bit like this: class CTapiCall { // Constructor public: CTapiCall(); virtual ~CTapiCall();
3
by: programmer.py | last post by:
Suppose I have this module `mymodule.py' - # mymodule.py - begin def test(): print "original" # mymodule.py - end Now assume that I do this in some arbitrary module -> def override():
4
by: abcpp | last post by:
Please help: class B { public: void operator()(){ cout<<"in B()"<<endl;} }; class D : public B { public: void operator()() {
2
by: win | last post by:
My form has a dropdown combox and function key "F4" is used for save information. When I press "F4", the combox display the options and then exec. save coding. Can I skip the display options of...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.