Print Page | Close Window

[solved] BeforeAdd Id parameter 2-byte integer

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=23304
Printed Date: 27 November 2024 at 2:21am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: [solved] BeforeAdd Id parameter 2-byte integer
Posted By: wrecks
Subject: [solved] BeforeAdd Id parameter 2-byte integer
Date Posted: 03 April 2017 at 7:59am
For a Codejock CommandBars 17.2 Ribbon, I have been using numbers like 12300004 as my control Id numbers.  Everything is working fine until I tried to implement the Customize Keyboard facility.  When the BeforeAdd event fires, I get an Id of 44772, which did not match any of my Ids, and had no effect when I passed it along to KeyBindings.Add.  Now I realize that 44772 is the lower 2 bytes of 12300004 !  

Can you confirm that this is correct?  So I must use Id numbers < 65536 ?


Also, the BeforeAdd event Control, Shift, and Alt flags are unexpected.

For example, if I press Alt+0, I get fVirt=17 and Key=48.
The way I read the documentation, I was expecting fVirt=16.
Can you explain the extra 1 ?



Replies:
Posted By: olebed
Date Posted: 03 April 2017 at 3:17pm
17 is  FVIRTKEY & FALT

http://msdn.microsoft.com/en-us/library/windows/desktop/ms648010%28v=vs.85%29.aspx" rel="nofollow - FVIRTKEY (TRUE, 0x1) : The accelerator key is a  https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731%28v=vs.85%29.aspx" rel="nofollow - virtual-key code . If this flag is not specified, the accelerator key is assumed to specify an ASCII character code.

You should use bit-wise  operations with fVirt variable.  


Posted By: wrecks
Date Posted: 03 April 2017 at 5:10pm
Thank you, Oleksandr.  For your next release, maybe you could add that information to the help file.  Right now it only shows: 

Public Const FSHIFT = 4
Public Const FCONTROL = 8
Public Const FALT = 16


Can you comment on the short integer ID codes?  Is that a bug?


Posted By: olebed
Date Posted: 05 April 2017 at 1:31pm
Hello,

There is a real bug with getting only last 2 bytes from control ID. And only in CXTPCustomizeKeyboardPage::OnAssign() method. In other places  used whole ID.

I've fixed this. Thank you for bringing this to our attention.

Hot fix for MFC version:
void CXTPCustomizeKeyboardPage::OnAssign()
{
.....
    pAccel->cmd = pControl->GetID();    //pAccel->cmd = (WORD)pControl->GetID();
.....
}

Regards,
 Oleksandr Lebed



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