Customize Ctrl+Tab feature

7 posts, 0 answers
  1. Stefano Rivella
    Stefano Rivella avatar
    6 posts
    Member since:
    Dec 2007

    Posted 21 Dec 2007 Link to this post

    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

  2. Kiril
    Admin
    Kiril avatar
    158 posts

    Posted 28 Dec 2007 Link to this post

    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
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Stefano Rivella
    Stefano Rivella avatar
    6 posts
    Member since:
    Dec 2007

    Posted 02 Jan 2008 Link to this post

    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

  5. Dimitar Kapitanov
    Admin
    Dimitar Kapitanov avatar
    632 posts

    Posted 07 Jan 2008 Link to this post

    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
  6. Stefano Rivella
    Stefano Rivella avatar
    6 posts
    Member since:
    Dec 2007

    Posted 07 Jan 2008 Link to this post

    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

     

  7. Stefano Rivella
    Stefano Rivella avatar
    6 posts
    Member since:
    Dec 2007

    Posted 10 Jan 2008 Link to this post

    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
  8. Dimitar Kapitanov
    Admin
    Dimitar Kapitanov avatar
    632 posts

    Posted 14 Jan 2008 Link to this post

    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
Back to Top
UI for WinForms is Visual Studio 2017 Ready