Print Page | Close Window

Keyboard Customization not working 100%

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=5111
Printed Date: 04 October 2024 at 3:25pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Keyboard Customization not working 100%
Posted By: kevins
Subject: Keyboard Customization not working 100%
Date Posted: 20 September 2006 at 4:10pm
I have some tools on a toolbar that are not in any menus. So I added the ids to the CXTPCustomizeKeyboardPage page. I then make key assignments for my tools via the user interface.

Here is the problem. Some of the key assignments work and some don't. I've tracked down the difference between the tools that work and the tools that don't.

Tools that work are handled like this in the Message Map:
ON_COMMAND(IDC_PS_LEFT, OnAlignLeft)

Tools that do not work are handled like this:
ON_XTP_EXECUTE(IDC_FONT_BOLD, OnBold)

Is there a way I can solve this? I'm using ON_XTP_EXECUTE so I have the control and can get its state. I'd really don't want to bail out on using ON_XTP_EXECUTE.




Replies:
Posted By: Oleg
Date Posted: 21 September 2006 at 1:07am
Hi,
 
It is MFC thing. When User press Key, OS generates WM_COMMAND message and ON_COMMAND handler executed. You can overide OnCommand and dispatch message if it is WM_COMMAND from accelerator.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: kevins
Date Posted: 21 September 2006 at 1:00pm
If I do that, will I have the CXTPControl associated with the button I clicked on? I think not. If not, then it would be easier just to implement the ON_COMMAND handler for the button and in that routine I will have to search the toolbars for the button I'm interested in so I can get its checked state.


Posted By: Oleg
Date Posted: 21 September 2006 at 2:00pm

Accelerators it is system thing. It will executed even if you don't have any button in toolbar or menu. Seems you have problem with architecture. Instead checking all controls to find checked state, add variable in CMainFrame that will store it and just check it and switch its state in ON_COMMAND handler.

 
simple sample:
 
 ON_COMMAND(ID_THEMES_THEMES, OnSwitchCommand)
 ON_UPDATE_COMMAND_UI(ID_THEMES_THEMES, OnUpdateSwitchCommand)
 
void CMainFrame::OnSwitchCommand()
{
 m_bChecked = !m_bChecked;
}
void CMainFrame::OnUpdateSwitchCommand(CCmdUI* pCmdUI)
{
 pCmdUI->SetCheck(m_bChecked);
}


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: kevins
Date Posted: 21 September 2006 at 3:41pm
Thanks. Yes, I know I can do that. I wanted to get away without adding another variable since the button does know whether it is checked or not. I guess I will have to add the variable since the user can use customization to remove the button completely but still get the behavior with the accell

Thanks again, I think all my questions regarding this topic have been answered.




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