Solved

PeekMessage and accelerator keys

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
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 Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
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…

776 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