Menu Resource ID and Buttons

Dear Dr. GUI:

Somewhere I read or was told that if you want a dialog box button (for example, Exit) to do the same thing as a menu item (File Exit), just give the button the same resource ID as the menu item (ID_APP_EXIT). Then the Microsoft Foundation Class Library (MFC) message machinery will cause the menu item command handler to get called magically when the button is clicked. I tried this long ago and gave up when it just didn't work. I tried it again today and it still doesn't work. Now I'd like to know why.

Dr. GUI replies:

I just tried it. It worked. For fun, add a button to a default AppWizard application's About box. Use ID_APP_EXIT as the ID for the button. Run the application, choose the About dialog box, click the button, and the application exits.

This works so well in App Studio 1.0 that, if you place a button on your own dialog box in the dialog editor, go into test mode, and click the newly created ID_APP_EXIT button, App Studio will exit!

One thing that may be causing your problems: This is designed to work only for IDs with the high bit set.