Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Problem reserving accelerator keys
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Problem reserving accelerator keys

 Post Reply Post Reply
Author
Message
jansim View Drop Down
Groupie
Groupie


Joined: 03 November 2005
Location: Canada
Status: Offline
Points: 20
Post Options Post Options   Thanks (0) Thanks(0)   Quote jansim Quote  Post ReplyReply Direct Link To This Post Topic: Problem reserving accelerator keys
    Posted: 16 October 2006 at 4:47pm

I try to override the OnPreviewEditKey method from the shortcut manager to prevent the user fomr using some accelerators that conflicts with our built-in ones. Here it is the "Home" Key.

When the method is first called ( from the WM_KEYDOWN ), I receive the ACCEL struct with a fVirtKey, meaning that the key pressed is a virtual key-code. I return false if the key is VK_HOME. It works fine so far.
 
The problem is that the method is called a second time ( for the WM_KEYUP ) and this time, the fVirtKey is not set to TRUE. Therefore I cannot say that the key depressed is "HOME", since the non virtual key code equivalent to "Home" is "$", and I don't want to forbid that key.
 
The problem is the following, when the "HOME" key is depressed, the Preview Key mecanism thinks the user just depressed "$" and sets the EditBoxText to "$".
 
The problem happens to the VK_ESCAPE key you are blocking. But you don't see the bug since the non-virtual equivalent to "Escape" is not a displayable character.
 
Thanks
Jansim
 
Back to Top
Oleg View Drop Down
Senior Member
Senior Member


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 18 October 2006 at 1:00am

Hello,

you right. Please modify sources:
 
if (pMsg->wParam == VK_SHIFT
     || pMsg->wParam == VK_CONTROL
     || pMsg->wParam == VK_MENU
     )
   {
    // all work is already done
   }else if (bPressed)
   {
    m_hAccel.key = (WORD) pMsg->wParam;
    m_bKeyDefined = TRUE;
    SetAccelFlag (FVIRTKEY, TRUE);
   }
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
jansim View Drop Down
Groupie
Groupie


Joined: 03 November 2005
Location: Canada
Status: Offline
Points: 20
Post Options Post Options   Thanks (0) Thanks(0)   Quote jansim Quote  Post ReplyReply Direct Link To This Post Posted: 18 October 2006 at 9:52am
Thank you
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.086 seconds.