Click here to Skip to main content
15,884,995 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hey , everyone, I have a question about ctrl key, now I created a vc demo, i changed Toolbar to Ooobal with shortcut key O, if the view main-menu has pop up, it will response either you press o keypad or Ctrl+O combination keypad, and the ctrl+o is used in file main-menu, if not used, press ctrl+o is not responsed. Now, I want only o letter has a response, not ctrl+o, even if the ctrl+o is used in other sub-menu item.
The windows default demo all like this, I found that the foxit reader did not like this, it’s OK. I want how they did it?

Anyone understand it? If u know, please reply the questions.
thank you very much
Posted
Comments
Sergey Alexandrovich Kryukov 10-Feb-12 2:47am    
There are many ways to screw up thing. Now do we know which one is your favorite?
--SA

By default "Normal" keys like A to Z do not open menus, they type characters. That is why the modifier keys like CTRL and ALT exist - so that applications can tell what the user is trying to do.

If you did successfully subvert this, all you would do in practice is annoy the heck out of your users.

Do not do this, it is a stupid idea. Stick to CTRL+key or ALT+key combinations instead.
 
Share this answer
 
hi, OriginalGriff,
The customer want only "Normal" keys as short-key separately, not with CTRL key for serval short-keys, as my mentioned, The foxit reader software can support this. I capture WM_COMMAND message in mainfrm::PreTranslateMessage, get the top-level menu id, gonna simulate left-clicking of the mouse ,but has no respose, the codes as belows,

C#
if (pMsg->message == WM_COMMAND)
    {
        if (ID_ZOOMIN == LOWORD(pMsg->wParam))
        {
            if (::GetKeyState(VK_CONTROL) < 0)
            {
                if (m_pMainMenu)
                {
                    UINT n = m_pMainMenu->gt;GetMenuItemID(1);
                    ::SendMessage((HWND)m_pMainMenu->GetSubMenu(1)->gt,GetSafeHmenu(),WM_COMMAND,MAKEWPARAM(0, m_pMainMenu->GetMenuItemID(1)),0);

                }

                return TRUE;
            }
        }


    }



the ID_ZOOMIN is the sub-menu ID which short-key is "O". Now the before codes can forbid the ctrl+o keypad, but if press ctrl+o, this sub-menu has disappeared, lost focus. I am finding the reason.
Could OriginalGriff or anyboy tell me the reason or the other approach to finish this little funtion?

thanks,
waiting the reply
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900