Hi all,
this is my question,
if I press Ctrl+Tab, I can browse through the opened documents/panels.
I can disable this feature by "dockingManager.UseQuickNavigator = false" property); I would like to assign this shortcut key (Ctrl+tab) to a custom function written by me, but I'm not able to catch this event (Ctrl+tab does not reach the keydown event).
How can I assign the Ctrl+tab shortcut to a function written by me?
Thanks in advance for the answer.
Stefano
6 Answers, 1 is accepted
Thank you for writing.
We need some clarification on this topic:
1. You want the fast access list to respond to different shortcut (say like Alt+Tab)?
or
2. You want different functionality attached to Ctrl+Tab in the docking component?
or
3. You have a general question on how to capture the Ctrl+Tab combination?
If your case is the third one you can use an IMessageFilter implementation like the one inside the docking control, here is the sample code:
class AccessManager : IMessageFilter |
{ |
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)] |
public static extern short GetKeyState(int keyCode); |
public bool PreFilterMessage(ref Message m) |
{ |
if ((m.Msg == 0x100) && |
(m.WParam == (IntPtr)Keys.Tab) && |
(GetKeyState(0x11) < 0)) |
{ |
// Your method call goes here |
return true; |
} |
return false; |
} |
} |
If you have any additional questions, please do not hesitate to contact us.
Sincerely yours,
Kiril
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Hi Kiril,
My case is the second.
I would like to have another functionality (like a call to a function written by me) attached to Ctrl+Tab instead of the QuickNavigator now attached to that shortcut.
How can I do that?
Thanks,
Stefano
You can set the dockingManager.UseQuickNavigator = false, thus the docking manager will not handle the Ctrl+Tab combination. Then you must add an IMessageFilter implementation to the message loop of the application like:
Application.AddMessageFilter(this.yourManager);
By doing so you will have access to all input events. You can use then code like the one we provided in the previous post to catch and process the key combination.
Sincerely yours,
Dimitar Kapitanov
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Hello again,
I still can't catch the Ctrl+Tab event.
This is my code
... |
this.dockingManager1.UseQuickNavigator = false; |
this.keyCatcher = new KeyCatcher(); |
Application.AddMessageFilter(this.keyCatcher); |
... |
class KeyCatcher : IMessageFilter |
{ |
[DllImport("user32.dll", CharSetCharSet = CharSet.Auto, ExactSpelling = true)] |
public static extern short GetKeyState(int keyCode); |
public bool PreFilterMessage(ref Message m) |
{ |
const int WM_KEYDOWN = 0x100; |
if ((m.Msg == WM_KEYDOWN) && |
(m.WParam == (IntPtr)Keys.Tab) && (GetKeyState(0x11) < 0)) |
{ |
MessageBox.Show("My method call goes here"); |
// Your method call goes here |
return true; |
} |
return false; |
} |
} |
using the above code, I'm able to catch other keyboard events (the code works), such as Ctrl+Space
(m.WParam == (IntPtr)Keys.Space) && (GetKeyState(0x11) < 0)) |
Ctrl+U
(m.WParam == (IntPtr)Keys.U) && (GetKeyState(0x11) < 0)) |
but I can't catch the Ctrl+Tab event (if I try, nothing happens).
Maybe disabling "UseQuickNavigator" feature is then impossible to process the Ctrl+Tab?
Am I doing something wrong?
Is there another way to attach a custom funtionality to the Ctrl+Tab event?
Thanks,
Stefano
I found a way to process the Ctrl+Tab event, modifying Telerik source code.
QuickAccessmanager.cs, lines 58-75
I changed the code as follows
public bool PreFilterMessage(ref Message m) |
{ |
switch (m.Msg) |
{ |
case NativeMethods.WM_KEYDOWN: |
if (m.WParam == (IntPtr)Keys.Tab && |
UnsafeNativeMethods.GetKeyState(NativeMethods.VK_CONTROL) < 0) |
{ |
if (this.manager.UseQuickNavigator == false) |
{ |
return false; |
} |
and then I followed your suggestion about IMessageFilter Implementation.
Now it works!
Thanks
Stefano
All the best,
Dimitar Kapitanov
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center