Solved

PeekMessage and accelerator keys

Posted on 2001-07-16
1
352 Views
Last Modified: 2013-12-03
I'm using the following, and it works fine for the mouse and its buttons.  But when I press an accelerator key, nothing happens.  What do I need to add?

MSG msg;
while (::PeekMessage(&msg,NULL,0,0,PM_REMOVE)) {
         TranslateMessage(&msg);
         DispatchMessage(&msg);
}
0
Comment
Question by:Ashurbanipal
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 86

Accepted Solution

by:
jkr earned 100 total points
ID: 6287439
You usually would use 'TranslateAccelerator()' (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/hh/winui/keybacel_25o2.asp) before calling 'TranslateMessage()' - see e.g. http://support.microsoft.com/support/kb/articles/Q74/0/42.ASP ('HOWTO: How to Use PeekMessage() Correctly in Windows'):

void CALLBACK MyMessagePump(LPMSG lpmsg)
{
   if(!TranslateAccelerator(hWnd, hAccel, lpsmg))
      {
         TranslateMessage(lpsmg);
         DispatchMessage(lpmsg);
      }
}

For aq MDI app, you'd use 'TranslateMDISysAccel()' instead.
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question