for each control that do not catch TAB key, override IsInputKey method like
following :
protected override bool IsInputKey(Keys keyData) {
if (keyData==Keys.Tab) return true;
return base.IsInputKey (keyData);
}
Now, KeyDown event will be called if TAB key is pressed.
Hope it helps,
Ludovic Soeur.
"supster" <prelugejunk@hotmail-dot-com.no-spam.invalid> a écrit dans le
message de news:42428a06$1_1@127.0.0.1...[color=blue]
> Hello, I'm trying to capture when users press the tab key. This is
> scrolling through different fields with tab is broken in my form. I'm
> not sure why, but it may have something to do with the fact that the
> Windows Shell is creating the form (it is defined in a DLL). I copy
> and pasted the form's code over to another application which created
> the form through an executable, and tabbing worked fine - so that is
> my only guess.
>
> Anyway, I'd like to be able to manually recreate the tabbing feature
> (including shift+tab and ctrl+tab), I have no problem writing the
> functions to do this, however I cannot find out when tab (or
> shift+tab) is pressed.
>
> The KeyPressed event is not called, and the only solution I have found
> is the following:
>
> [System.Runtime.InteropServices.DllImport("User32",
> EntryPoint="GetKeyState", ExactSpelling=false,
> CharSet=System.Runtime.InteropServices.CharSet.Ans i,
> SetLastError=true)]
> private static extern int GetKeyState(long nVirtKey);
> private const int VK_TAB = 0X9;
> private const int VK_SHIFT = 0X10;
>
> ..
>
> while(true)
> {
> iRetVal = GetKeyState(VK_TAB);
> if ((iRetVal == -128 || iRetVal == -127) &&
> this.isFocused)
> {
> MessageBox.Show("Tab Key Pressed");
> }
> System.Threading.Thread.Sleep(25);
> }
>
>
> I would rather not have a thread running this the whole time the form
> is open. Also, another problem with this method is that it is called
> even when the form is not the focused window, and the &&
> this.isFocused does not seem to help this at all.
>
> If anyone has a better solution, please let me know!
>
> Thanks
>
>
> Posted Via Usenet.com Premium Usenet Newsgroup Services
> ----------------------------------------------------------
> ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
> ----------------------------------------------------------
>
http://www.usenet.com[/color]