PeekMessage loop

Posted on 1999-07-28
Medium Priority
Last Modified: 2013-12-03
I've got a app whose main window I'm subclassing.  In response to a specific message, I sit in a PeekMessage loop for a while.  While in the PeekMessage loop everything is fine except for the fact that keyboard accelerators don't work.  Menus can be accessed with Alt-key combinations, general keyboard messages are processed, etc., but menu command shortcuts and other accelerators aren't getting called.  My PeekMessage loop looks similar to the following:

MSG msg;
while (bStayInLoop)

   if (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
      if (msg.message == WM_QUIT ||
          msg.message == WM_DESTROY ||
          msg.message == WM_CLOSE)
         bStayInLoop = FALSE;

      TranslateMessage (&msg);
      DispatchMessage (&msg);

What am I missing here?
Question by:The Master
LVL 23

Accepted Solution

chensu earned 400 total points
ID: 1403973
hAccelTable = LoadAccelerators (hInstance, Name);

if (!TranslateAccelerator (msg.hwnd, hAccelTable, &msg)) {

Author Comment

by:The Master
ID: 1403974
That's what it was.  Thanks!

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.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
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…
If you are looking for an automated tool which can generate reports for Outlook emails and other items from PST file, then you can go for Kernel PST Reporter tool. The reports which are created by this tool are helpful to analyze and understand PST …

621 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