Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - Keyboard Customization not working 100%
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Keyboard Customization not working 100%

 Post Reply Post Reply
Author
Message
kevins View Drop Down
Newbie
Newbie
Avatar

Joined: 22 August 2006
Location: United States
Status: Offline
Points: 15
Post Options Post Options   Thanks (0) Thanks(0)   Quote kevins Quote  Post ReplyReply Direct Link To This Post Topic: Keyboard Customization not working 100%
    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.

Back to Top
Oleg View Drop Down
Admin Group
Admin Group


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: 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
Back to Top
kevins View Drop Down
Newbie
Newbie
Avatar

Joined: 22 August 2006
Location: United States
Status: Offline
Points: 15
Post Options Post Options   Thanks (0) Thanks(0)   Quote kevins Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


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: 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
Back to Top
kevins View Drop Down
Newbie
Newbie
Avatar

Joined: 22 August 2006
Location: United States
Status: Offline
Points: 15
Post Options Post Options   Thanks (0) Thanks(0)   Quote kevins Quote  Post ReplyReply Direct Link To This Post 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.

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.172 seconds.