Prevent keydown event to continue in list control

P

Peter B

Hi!

I am using the keydown event on my form controls to execute certain
operations (the handheld device I am using has a full alphanumeric
keyboard). For instance Ctrl + S saves the current object. This happens
whatever control is focused on the form, so I have added keydown
eventhandler on all controls that can be focused.

The problem I have is that when a list based control such as the combobox is
focused, and the user types Ctrl + "a letter", let's say 'S', the object is
first saved, BUT then the control looks for any objects in it's list that
starts with the typed letter ('S'), and selects it (if found). This means
the next item starting with 'S' is selected, which ofcourse is
unacceptable, I need to prevent the event to continue after I process it.

From my research I have found that the easy solution would be to set the
KeyEventArgs Handled property to true. But I don't get this to work. Infact,
the Handled property doesn't seem to be usefull at all?

code snippet:

case Keys.S:
if( e.Control )
{
e.Handled = true;
this.Save();
}
break;

I was hoping this would stop the low level keydown event, but it doesn't...

Note that this is only a problem in list based controls (ComboBox and
ListView are the two controls I have tried). TextBox will not write out an
'S' if Ctrl + S is pressed.

What can I do here? Could anyone shed some light please :)

regards,

Peter
 
R

Ryan Chapman [MSFT]

Hi Peter,

Unfortunately you've bumped into a known issue in the NETCF GUI code. I
know the team is working on a number of such issues, but unfortunately we
can't commit to a release date for these and related fixes.

I hope you're able to find a way to work around this. If this proves to be
a severe limitation let me know and I'll try to track down a work-around
for you.

Thanks,

Ryan Chapman
Software Development Engineer
.NET Compact Framework

This posting is provided "AS IS" with no warranties, and confers no rights.
 
P

Peter B

A work-around would be greatly appreciated, my entire keyboard handling
fails due to this :(

/ Peter
 
T

Trollpower

As far as i know there exists some Code to catch the messages send to
your app by the OS. It is called Application Ex and it is located on
opennetcf.org.

With this code you can handle all keyevents send to your ListBox (or
what ever you want) and decide to handle it or not.

Hope this helps.

Greetz

Jens Meyer
 
P

Peter B

Thanks,

I will have a look at it!

/ Peter


Trollpower said:
As far as i know there exists some Code to catch the messages send to
your app by the OS. It is called Application Ex and it is located on
opennetcf.org.

With this code you can handle all keyevents send to your ListBox (or
what ever you want) and decide to handle it or not.

Hope this helps.

Greetz

Jens Meyer

(e-mail address removed) (Ryan Chapman [MSFT]) wrote in message
Hi Peter,

Unfortunately you've bumped into a known issue in the NETCF GUI code. I
know the team is working on a number of such issues, but unfortunately we
can't commit to a release date for these and related fixes.

I hope you're able to find a way to work around this. If this proves to be
a severe limitation let me know and I'll try to track down a work-around
for you.

Thanks,

Ryan Chapman
Software Development Engineer
.NET Compact Framework

This posting is provided "AS IS" with no warranties, and confers no
rights.
 
B

Bob Nicholls

The problem I have had for many months, and have posted here previously, is
in capturing the Tab key. This key isn't caught by the method presented in
ApplicationEx nor by the RegisterHotKey approach. I'm not sure if this will
cause a problem for Ryan.

Bob

Peter B said:
Thanks,

I will have a look at it!

/ Peter


Trollpower said:
As far as i know there exists some Code to catch the messages send to
your app by the OS. It is called Application Ex and it is located on
opennetcf.org.

With this code you can handle all keyevents send to your ListBox (or
what ever you want) and decide to handle it or not.

Hope this helps.

Greetz

Jens Meyer

(e-mail address removed) (Ryan Chapman [MSFT]) wrote in message
Hi Peter,

Unfortunately you've bumped into a known issue in the NETCF GUI code. I
know the team is working on a number of such issues, but unfortunately we
can't commit to a release date for these and related fixes.

I hope you're able to find a way to work around this. If this proves
to
rights.
 
P

Peter B

I don't think ApplicationEx is a good solution for us either. I didn't look
to deep into it but adding the class my application (and every form in it)
just to make sure Ctrl + 'S' in a combobox (and listbox) doesn't generate an
'S' to the control seems like somewhat overkill. I am not even sure it will
work.

I will wait for Ryan's answer to see what work-arounds they have at MS.

Regarding the tab key Bob, what is it you want to do? Tabbing is possible
since CF SP2, but the tab order is based on the z-order of the controls and
you can't disable tabbing to certain controls as long as they are "tabable".
Do you want to disable tabbing completely?

/ Peter


Bob Nicholls said:
The problem I have had for many months, and have posted here previously, is
in capturing the Tab key. This key isn't caught by the method presented in
ApplicationEx nor by the RegisterHotKey approach. I'm not sure if this will
cause a problem for Ryan.

Bob

Peter B said:
Thanks,

I will have a look at it!

/ Peter


Trollpower said:
As far as i know there exists some Code to catch the messages send to
your app by the OS. It is called Application Ex and it is located on
opennetcf.org.

With this code you can handle all keyevents send to your ListBox (or
what ever you want) and decide to handle it or not.

Hope this helps.

Greetz

Jens Meyer

(e-mail address removed) (Ryan Chapman [MSFT]) wrote in message
Hi Peter,

Unfortunately you've bumped into a known issue in the NETCF GUI
code.
I unfortunately
we
proves
to
rights.
 
C

Chris Tacke, eMVP

I think you misunderstand how ApplicationEx works. You would create a
simple filter to kill any Ctrl-S and use the ApplicationEx.Run instead of
the Application.Run you use now. It's probably an addition of less than 20
lines of code total for your app (all in the MessageFilter implementation).

You don't "create" an ApplicationEx class for each form, just as you don't
now create multiple Application classes.

--
Chris Tacke, eMVP
Co-Founder and Advisory Board Member
www.OpenNETCF.org
---
Windows CE Product Manager
Applied Data Systems
www.applieddata.net


Peter B said:
I don't think ApplicationEx is a good solution for us either. I didn't look
to deep into it but adding the class my application (and every form in it)
just to make sure Ctrl + 'S' in a combobox (and listbox) doesn't generate an
'S' to the control seems like somewhat overkill. I am not even sure it will
work.

I will wait for Ryan's answer to see what work-arounds they have at MS.

Regarding the tab key Bob, what is it you want to do? Tabbing is possible
since CF SP2, but the tab order is based on the z-order of the controls and
you can't disable tabbing to certain controls as long as they are "tabable".
Do you want to disable tabbing completely?

/ Peter


Bob Nicholls said:
The problem I have had for many months, and have posted here previously, is
in capturing the Tab key. This key isn't caught by the method presented in
ApplicationEx nor by the RegisterHotKey approach. I'm not sure if this will
cause a problem for Ryan.

Bob

Peter B said:
Thanks,

I will have a look at it!

/ Peter


As far as i know there exists some Code to catch the messages send to
your app by the OS. It is called Application Ex and it is located on
opennetcf.org.

With this code you can handle all keyevents send to your ListBox (or
what ever you want) and decide to handle it or not.

Hope this helps.

Greetz

Jens Meyer

(e-mail address removed) (Ryan Chapman [MSFT]) wrote in message
Hi Peter,

Unfortunately you've bumped into a known issue in the NETCF GUI
code.
I
know the team is working on a number of such issues, but unfortunately
we
can't commit to a release date for these and related fixes.

I hope you're able to find a way to work around this. If this
proves
to
be
a severe limitation let me know and I'll try to track down a work-around
for you.

Thanks,

Ryan Chapman
Software Development Engineer
.NET Compact Framework

This posting is provided "AS IS" with no warranties, and confers no
rights.
 
P

Peter B

Hmm.

Excuse my lack of knowledge, indeed I misunderstood how it works. I still am
not convinced that it would work in my application. I got the impression
that the part of ApplicationEx we are looking at here (the keyboard filter)
filters unwanted keys from the application. I want the Ctrl + KEY to be
generated, I just don't want it to generate the KEY stroke after I have
handled it, which seems to happen in list-controls even though I explicitly
use e.Handled = true.Ctrl + S is just one of many key combinations.

If ApplicationEx provides a working "e.Handled = true" functionality, i.e.
after I handle a key down of Ctrl + KEY in a combobox, I can make sure it
stops there, then I will reconsider. But I don't think it does, please prove
me wrong :)

As it seems the Alt + KEY doesn't cause this, it is only the Ctrl + Key key
combination.

Also, as MS has acknowledged this as a problem in the GUI functionality I am
interested in seeing how and if they are eager to solve it.

thanks,

Peter


Chris Tacke said:
I think you misunderstand how ApplicationEx works. You would create a
simple filter to kill any Ctrl-S and use the ApplicationEx.Run instead of
the Application.Run you use now. It's probably an addition of less than 20
lines of code total for your app (all in the MessageFilter implementation).

You don't "create" an ApplicationEx class for each form, just as you don't
now create multiple Application classes.

--
Chris Tacke, eMVP
Co-Founder and Advisory Board Member
www.OpenNETCF.org
---
Windows CE Product Manager
Applied Data Systems
www.applieddata.net


Peter B said:
I don't think ApplicationEx is a good solution for us either. I didn't look
to deep into it but adding the class my application (and every form in it)
just to make sure Ctrl + 'S' in a combobox (and listbox) doesn't
generate
an
'S' to the control seems like somewhat overkill. I am not even sure it will
work.

I will wait for Ryan's answer to see what work-arounds they have at MS.

Regarding the tab key Bob, what is it you want to do? Tabbing is possible
since CF SP2, but the tab order is based on the z-order of the controls and
you can't disable tabbing to certain controls as long as they are "tabable".
Do you want to disable tabbing completely?

/ Peter


previously,
is
presented
in
ApplicationEx nor by the RegisterHotKey approach. I'm not sure if this will
cause a problem for Ryan.

Bob

Thanks,

I will have a look at it!

/ Peter


As far as i know there exists some Code to catch the messages send to
your app by the OS. It is called Application Ex and it is located on
opennetcf.org.

With this code you can handle all keyevents send to your ListBox (or
what ever you want) and decide to handle it or not.

Hope this helps.

Greetz

Jens Meyer

(e-mail address removed) (Ryan Chapman [MSFT]) wrote in message
Hi Peter,

Unfortunately you've bumped into a known issue in the NETCF GUI code.
I
know the team is working on a number of such issues, but unfortunately
we
can't commit to a release date for these and related fixes.

I hope you're able to find a way to work around this. If this proves
to
be
a severe limitation let me know and I'll try to track down a
work-around
for you.

Thanks,

Ryan Chapman
Software Development Engineer
.NET Compact Framework

This posting is provided "AS IS" with no warranties, and confers no
rights.
 
R

Ryan Chapman [MSFT]

Hi Peter,

I can safely say that we are both eager (if) and quite eager (how) to solve
this problem! Unfortunately, I can't commit to a particular date/release
in which you will see a fix. For now, I think the best known work-around
is the one suggested by Jens. I tried a couple of hacks myself (creating a
subclass of ComboBox that overrides OnKeyDown), but wasn't able to come up
with a simple solution...

Good luck,

Ryan

This posting is provided "AS IS" with no warranties, and confers no rights.
 
B

Bob Nicholls

Peter,

Yes I want to diasable tabbing completely due to the current lack of control
even with SP2.

Bob

Peter B said:
I don't think ApplicationEx is a good solution for us either. I didn't look
to deep into it but adding the class my application (and every form in it)
just to make sure Ctrl + 'S' in a combobox (and listbox) doesn't generate an
'S' to the control seems like somewhat overkill. I am not even sure it will
work.

I will wait for Ryan's answer to see what work-arounds they have at MS.

Regarding the tab key Bob, what is it you want to do? Tabbing is possible
since CF SP2, but the tab order is based on the z-order of the controls and
you can't disable tabbing to certain controls as long as they are "tabable".
Do you want to disable tabbing completely?

/ Peter


Bob Nicholls said:
The problem I have had for many months, and have posted here previously, is
in capturing the Tab key. This key isn't caught by the method presented in
ApplicationEx nor by the RegisterHotKey approach. I'm not sure if this will
cause a problem for Ryan.

Bob

Peter B said:
Thanks,

I will have a look at it!

/ Peter


As far as i know there exists some Code to catch the messages send to
your app by the OS. It is called Application Ex and it is located on
opennetcf.org.

With this code you can handle all keyevents send to your ListBox (or
what ever you want) and decide to handle it or not.

Hope this helps.

Greetz

Jens Meyer

(e-mail address removed) (Ryan Chapman [MSFT]) wrote in message
Hi Peter,

Unfortunately you've bumped into a known issue in the NETCF GUI
code.
I
know the team is working on a number of such issues, but unfortunately
we
can't commit to a release date for these and related fixes.

I hope you're able to find a way to work around this. If this
proves
to
be
a severe limitation let me know and I'll try to track down a work-around
for you.

Thanks,

Ryan Chapman
Software Development Engineer
.NET Compact Framework

This posting is provided "AS IS" with no warranties, and confers no
rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top