Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

PeekMessage and accelerator keys

Posted on 2001-07-16
1
Medium Priority
?
357 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 400 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

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.  …
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…

927 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