Solved

PeekMessage and accelerator keys

Posted on 2001-07-16
1
351 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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 …
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

734 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