Click here to Skip to main content
15,299,443 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello colleagues,

Seems strange, but after so many years, I'm trying to use MFC Feature Pack for my old application.

I have the following problem which makes me a bit crazy:

I have a toolbar, inside the toolbar I have 2 menu-buttons with drop-down style.

Menu in each button is built like:
id = ID of record in Database
text = text from Database

Both buttons are filled from different database tables. As a result IDs can be the same inside both menus!

Currently, when user press on the down arrow, menu is built on the fly. Also it's shown with TrackPopupMenu(), so immediately I have a result.

But when moving to Feature Pack, I have to replace buttons on the toolbar with CMFCToolBarMenuButton, and this class opens menu itself. When user clicks on a menu-item, message WM_COMMAND is sent with selected menu ID. But it doesn't provide (or I don't know where to find it) information about WHICH button/menu was pressed/clicked.

What I have tried:

The only thing I have in mind how to solve the problem: build static array of IDs, and when building menus fill this array like:
[unigue ID] / [database record ID]

So, when menu item is clicked, I can understand what menu it was and also what database record ID it was.

But it seems a bit... I don't know... but I don't like this approach, especially if somebody can advise me some more nice and logical solution.

UPD. The solution I'm searching for, should also work in case there are not 2, but 3 or more menu-buttons

Thanks in advance!
Updated 9-Jun-16 4:40am

1 solution

SergejNikitin 9-Jun-16 11:10am
Richard, thanks for your reply!

But as far as I can see, CMFCPopupMenu/CMFCPopupMenuBar classes, which are used inside CMFCToolBarMenuButton, always send WM_COMMAND and never WM_MENUCOMMAND.
Richard MacCutchan 9-Jun-16 11:22am
Try setting the property to get it to use this message. I don't have MFC so cannot test it, but it's worth trying. The only alternative is to ensure that your menu items have unique ids, which you could probably do by adding some value that is derived from the table name.
SergejNikitin 9-Jun-16 11:37am
I tried, without success. It's always a chance, that I made smth wrong, but after looking through MFC code, I don't think so. Thanks anyway!
Richard MacCutchan 9-Jun-16 11:45am
It may well be that these items do not derive from the Windows Menu type, but I would be surprised.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900