Solved

PeekMessage and accelerator keys

Posted on 2001-07-16
1
332 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
1 Comment
 
LVL 86

Accepted Solution

by:
jkr earned 100 total points
Comment Utility
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
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…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

771 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now