Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8018317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:06:11+00:00 2026-06-04T21:06:11+00:00

I am having trouble getting Accelerators to work. I am using C++. After my

  • 0

I am having trouble getting Accelerators to work. I am using C++.

After my window is setup and shown.

MENUITEMINFOW mAbout;
mAbout.cbSize = sizeof(MENUITEMINFO);
mAbout.fMask  = MIIM_TYPE | MIIM_ID;
mAbout.wID    = (UINT) ID_ABOUT;
mAbout.fType  = MFT_STRING;
mAbout.dwTypeData = (LPWSTR)L"&About";

InsertMenuItemW(HelpMenu,   0, TRUE, &mAbout);

My menu is working just fine, and calls my “About” box, no issue there.

Now, before the message loop, I load the accelerators:

// Load accelerators.
 HACCEL hAccelerators = LoadAcceleratorsW(hInstance, MAKEINTRESOURCEW(IDR_ACCELERATOR));

Then my main message loop:

while(GetMessageW(&msg, NULL, 0, 0) > 0) {
    if (! TranslateAcceleratorW(msg.hwnd, hAccelerators, &msg)) {
        TranslateMessage(&msg);
        DispatchMessageW(&msg);
    }
}

My WndProc Message handle (Again, works from the menu)

case WM_COMMAND: {
    if (HIWORD(wParam) == 0) {
        if (LOWORD(wParam) == 101) {
            testDialog(hInstance ,hWnd,(LPSTR)"Testing");
        }
        if (LOWORD(wParam) == ID_ABOUT) {
            DialogBox(hInstance, MAKEINTRESOURCE(IDD_ABOUTDIALOG), hWnd, &AboutDialogProc);
            return 0;
        }
    }
    break;
}

My resource.rc file:

//
// Accelerator resources
//
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDR_ACCELERATOR ACCELERATORS
{
    "a",    ID_ABOUT, VIRTKEY, ALT
}

and my resource.h file:

#define IDR_ACCELERATOR                         122
#define ID_ABOUT                                401

And… well, Alt-a does not bring up the about box. I have walked all over the Microsoft
Website, and was vary careful, but I can’t find anything glaring I am doing different.

I am on Windows 7 (64bit) using MinGW and compiling in the application for Unicode.

Everything else works but this, what am I missing???

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T21:06:12+00:00Added an answer on June 4, 2026 at 9:06 pm

    Found it!

    From: http://msdn.microsoft.com/en-us/library/windows/desktop/ms646373(v=vs.85).aspx

    To differentiate the message that this function sends from messages sent by menus or controls, the high-order word of the wParam parameter of the WM_COMMAND or WM_SYSCOMMAND message contains the value 1.

    This was the issue, I was checking wParam for a value of 0, I didn’t catch that it is 1 if sent by TranslateAcceleratorW

    if (HIWORD(wParam) == 0) {
        if (LOWORD(wParam) == 101) {
            testDialog(hInstance ,hWnd,(LPSTR)"Testing");
        }
        if (LOWORD(wParam) == ID_ABOUT) {
            DialogBox(hInstance, MAKEINTRESOURCE(IDD_ABOUTDIALOG), hWnd, &AboutDialogProc);
            return 0;
        }
    } else if (HIWORD(wParam) == 1) {    // Accelerator input 
        if (LOWORD(wParam) == ID_ABOUT) {
            DialogBox(hInstance, MAKEINTRESOURCE(IDD_ABOUTDIALOG), hWnd, &AboutDialogProc);
            return 0;
        }
    }
    

    Geeze, that was a tiny detail.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having trouble getting one of my LINQ to SQL queries to work
Having trouble getting this to work. What's strange is that I have 10 bookmarks
I having trouble getting append() to work in safari for some reason, but it
I'm having trouble getting Jquery .closest() to work. Here's my code, it's simple and
I'm having trouble getting the following three-column layout to work: A B C +-------+-------------------+------------+
I'm having trouble getting client validation to work on a web form. I'm including
I'm having trouble getting the results of a has_many query using php idiorm/paris. Following
I'm having trouble getting a filter to work on a BindingSource that is the
I am having trouble getting this to work. I have variables initiated in main
I'm having trouble getting the follow code to work in Internet Explorer, it doesn't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.