This is a migrated thread and some comments may be shown as answers.

Customize Ctrl+Tab feature

6 Answers 85 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Stefano Rivella
Top achievements
Rank 1
Stefano Rivella asked on 21 Dec 2007, 03:41 PM

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

Sort by
0
Kiril
Telerik team
answered on 28 Dec 2007, 12:43 PM
Hello Stefano Rivella,

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
0
Stefano Rivella
Top achievements
Rank 1
answered on 02 Jan 2008, 12:34 PM

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

0
Dimitar Kapitanov
Telerik team
answered on 07 Jan 2008, 07:19 AM
Hello Stefano Rivella,
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
0
Stefano Rivella
Top achievements
Rank 1
answered on 07 Jan 2008, 04:48 PM

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

 

0
Stefano Rivella
Top achievements
Rank 1
answered on 10 Jan 2008, 01:33 PM

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
0
Dimitar Kapitanov
Telerik team
answered on 14 Jan 2008, 05:48 PM
Indeed, Stefano, after thorough testing we recognize this as faulty behavior. We have implemented a fix already, which will be available in the upcoming SP release (the end of January or the beginning of February). Your points have been updated.


All the best,
Dimitar Kapitanov
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Dock
Asked by
Stefano Rivella
Top achievements
Rank 1
Answers by
Kiril
Telerik team
Stefano Rivella
Top achievements
Rank 1
Dimitar Kapitanov
Telerik team
Share this question
or