ListView windowsmessages

B

Brofalad

Hi,

How do I inhibit the Arrow down keypress from changing
the row in a listview? I have given the Arrow down keypress a
different meaning and I don’t want the row to be changed if a listview
is in focus.

I think I have to override the control's WndProc somehow, but I don’t
know what windowmessage to handle and not how to handle it.
/Brofalad
 
K

Kerem Gümrükcü

Hi,

no there is no need override the WndProc, not for
something simple like that. Just have a look at the
Events like KeyPress, KeyDown,KeyUp,PreviewKeyDown.
I am pretty sure you will solve your problem with that.
Have a closer look at the KeyEventArgs and

e.SuppressKeyPress;
e.Handled;

Good Luck!

regards

Kerem
 
M

Moty Michaely

Hi,

How do I inhibit the Arrow down keypress from changing
the row in a listview? I have given the Arrow down keypress a
different meaning and I don’t want the row to be changed if a listview
is in focus.

I think I have to override the control's WndProc somehow, but I don’t
know what windowmessage to handle and not how to handle it.
/Brofalad

Hi,

I think the events raised are sufficient enough. You can look on
events starting with Key (KeyPress etc.).

Feel free to ask any further questions.

M
 
K

Kerem Gümrükcü

Thanks!
You saved a me a couple of hours there!

You are welcome! Keep in your mind that
this will work for other controls as well!
Hooking is only indicated in scenarios when
..NET Events do not cover that area, and even
then you have the WndProc to handle and if
this isnt enough, then you can use global
hooks,...

If you wanna see what global hooks can do
for you, have a look at one of my applications:

http://www.pro-it-education.de/software/deviceremover

Its a powerful and very verbose device manager for windows.
Install and run it, then enter in the lower command text box
"privdlg on" to enable the securty dialog on low-level operations.
Now try to disable, enable, eject, etc. on one device or service/driver.
You will get the extra security dialog, that hooks the windows key,
control+Esc, etc,... Control+Alt+Del is still allowed for security reasons,
though the kernel level driver could filter even this out, but this is very
advanced stuff and has absolutely nothing to do with C# anymore!

Thats what Low-Level Hooks can do for you: A complete hook into the
Systems Keyboard to filter (or modify) out anything you want,
"privdlg off" will remove the hook from the application,...

Here are some examples if you are interested:

[Low-Level Mouse Hook in C#]
http://blogs.msdn.com/toub/archive/2006/05/03/589468.aspx

[A Simple C# Global Low Level Keyboard Hook]
http://www.codeproject.com/KB/cs/CSLLKeyboardHook.aspx

Have fun!

Regards

Kerem
 

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