Click here to Skip to main content
15,888,816 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an MFC SDI project vreated within Visual Studio 8 (it is an explorer style app). It has accelerator keys defined in the resource view within the Accelerator folder. The IDs assigned to the accelerator keys match the IDs that their corresponding menu items have.

When the menu items are chosen, the message ID causes the correct method to be called. But when the accelerator keys are pressed, nothing happens.

Why is this? Am I missing something?
Posted
Updated 12-Aug-11 1:10am
v2
Comments
Slacker007 12-Aug-11 7:11am    
Edited for readability.

1 solution

case WM_COMMAND:
{
  int idCommand = LOWORD(wParam);
  int iNotifyCode = HIWORD(wParam); // 1==accelerator
  switch(idCommand)
  {
    case ID_QUIT: /* do anything */ break;
    /* do something else */
  }
}
break;

Regards.
 
Share this answer
 
Comments
Jackie Lloyd 12-Aug-11 9:38am    
I put this code in:

BOOL CMainFrame::OnCommand(WPARAM wParam, LPARAM lParam)
{
int idCommand = LOWORD(wParam);
int iNotifyCode = HIWORD(wParam); // 1==accelerator
switch(idCommand)
{
case ID_WSP_NEW_ACTIVITY:
OnActivityNew();
return true;
case ID_FILE_NEW:
OnWspNew();
return true;

}

if(CWnd::OnCommand(wParam, lParam))
{
return true;
}
else
{
return false;
}
}
but the ID_WSP_ACTIVITY_NEW was ignored, that was the one that I added to the accelerator table, whereas the ID_FILE_NEW was picked up, that one was already in the accelerator table. Why didn't mine get picked up?
mbue 14-Aug-11 13:17pm    
Enshure the function TranslateAccelerator is called. You can create the accelerator table manually by CreateAcceleratorTable. The command id must be (short) lower than 65536.
Regards.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900