Print Page | Close Window

Problem reserving accelerator keys

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=5303
Printed Date: 11 November 2025 at 4:22pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Problem reserving accelerator keys
Posted By: jansim
Subject: Problem reserving accelerator keys
Date 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
 



Replies:
Posted By: Oleg
Date 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


Posted By: jansim
Date Posted: 18 October 2006 at 9:52am
Thank you



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net