473,386 Members | 1,668 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,386 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 6823
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.