CFMCPopupMenu is shown multiple times if the menu key (VK_APPS) is pressed multiple times

Hello,
I have a problem with the CFMCPopupMenu in a Visual Studio Professional 2013 Update 4 created MFC DLL (Regular DLL using shared MFC DLL) and in a dialog based MFC application (others I didn't test - maybe in an SDI application too).
If the menu key (VK_APPS) is pressed multiple times, the context menu is created and shown multiple times. 
When pressing the Alt (VK_MENU) key or clicking with the mouse buttons the menu is not shown multiple times. 
It seems to be bug in CDialogImpl::PreTranslateMessage case WM_CONTEXTMENU where it is tested if a popup menu is already shown 
and if there is an active popup menu this popup menu is closed, but only if the pMsg->wParam == VK_MENU.
The problem occurs in a dialog based MFC application and in dialog's in regular DLL's. 
In case of MFC MDI applications the problem does not occur, 
because in the CFrameImpl::ProcessKeyboard the key is passed to the popup menu for processing pActivePopupMenu->SendMessage(WM_KEYDOWN, nKey); and eaten up.
You can reproduce the problem in the following way:
1. Create a dialog based MFC application with the Visual Studio 2013 wizard.
2. Add a menu IDR_MENU1 to the resource.
3. Add a ON_WM_CONTEXTMENU / OnContextMenu message handler to the dialog.
4. Insert the following code into the OnContextMenu handler of the dialog:
  _ASSERT(!CMFCPopupMenu::GetSafeActivePopupMenu());
  CMenu m;
  m.LoadMenu(IDR_MENU1);
  CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu;
  pPopupMenu->SetAutoDestroy(FALSE);
  VERIFY(pPopupMenu->Create(this, 100, 100, m.GetSafeHmenu(), TRUE, TRUE));
5. Compile and start the application and press the Menu Key (VK_APPS) multiple times.
-> You run into the ASSERT.
If you press the Alt-Key or left click with the mouse multiple times all is fine.
You can also add a tracepoint in the constructor and destructor to see that the CMFCPopup menu is created multiple times if the Menu-Key is pressed.
Kind regards,
Andreas.
Andreas

Hi Andreas,
Thanks for posting in MSDN forum.
Yes, I can reproduce this issue on my side. After look into the afxdialogimpl.cpp and afxframeimpl.cpp file, It really is a issue in the dialog message translate. I have no workaround to avoid this. But maybe we can try to use
CMenu class and handle WM_RBUTTONDOWN message instead of WM_CONTEXTMENU.
void CMFCPopupMenuTestDlg::OnRButtonDown(UINT nFlags, CPoint point)
// TODO: Add your message handler code here and/or call default
CMenu menu;
VERIFY(menu.LoadMenu(IDR_MENU1)); //IDR_MENU_POPUP是新建菜单ID
CMenu* popup=menu.GetSubMenu(0);
ClientToScreen(&point);
popup->TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON, point.x, point.y, this );
CDialogEx::OnRButtonDown(nFlags, point);
By using this, we can avoid the VK_APP message caused multi pop up menu.
Also have you tried submit this issue to Microsoft connect?
https://connect.microsoft.com/VisualStudio
Best regards,
Shu Hu
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.

Similar Messages

  • Importing a lot of video clips from a Sony camera to FCE; during the Log and Transfer process, is there a way to add multiple clips to the browser instead of one at a time?

    Importing a lot of video clips from a Sony camera to FCE; during the Log and Transfer process, is there a way to add multiple clips to the browser instead of one at a time?

    Select one and click cmd-A which selects them all.
    Then click the import button if it hasn't started already.

  • Suggested edit to hint: Tip - Date and Time in the Menu Bar

    The user tip, located here, massively overcomplicates the procedure for showing the date and time in the menu bar.
    The simpler way is to do:
    1. Click >System Preferences...>International>Formats.
    2. Next to "Dates", click the "Customize" button.
    3. Arrange the date the way you want it to appear in the menu bar (don't worry about time at this point).
    4. Select everything in the date format box and copy it (⌘C).
    5. Next to "Times", click the "Customize" button.
    6. Select the "Medium" format.
    7. Paste the time format into the box (⌘V), and customize it to appear as you wish.
    8. Click OK.
    That's it. No Terminal, nothing complicated.

    Any chance you figured out how to do this for Snow Leopard?
    I did this before, and when i migrated i could see that the change i made in Tiger, carried over, (that is there was a date in my medium clock setting) but it doesn't show in the clock in my menu bar...
    Is there a fix?
    Maybe Lion will bring this back... or better still offer the ability to put what we want with less complication?

  • Why doesn't Energy Saver have an option for displaying "Time" in the menu bar?

    Why doesn't Energy Saver have an option for displaying "Time" in the menu bar?

    I'll provide some Proof
    Link 1
    Link 2
    Link 3
    you are not the only person with this problem maybe it will come back in Mountain Lion who knows. 

  • I have checked the box "display date and time on the Menu Bar" and it does not work.  Using OS X Yosemite 10.10.2  Anybody have a fix?

    I have checked the box "display date and time on the Menu Bar" and it does not work.  Using OS X Yosemite 10.10.2  Anybody have a fix?

    Please read this whole message before doing anything.
    This procedure is a test, not a solution. Don’t be disappointed when you find that nothing has changed after you complete it.
    Step 1
    The purpose of this step is to determine whether the problem is localized to your user account.
    Enable guest logins* and log in as Guest. Don't use the Safari-only “Guest User” login created by “Find My Mac.”
    While logged in as Guest, you won’t have access to any of your documents or settings. Applications will behave as if you were running them for the first time. Don’t be alarmed by this behavior; it’s normal. If you need any passwords or other personal data in order to complete the test, memorize, print, or write them down before you begin.
    Test while logged in as Guest. Same problem?
    After testing, log out of the guest account and, in your own account, disable it if you wish. Any files you created in the guest account will be deleted automatically when you log out of it.
    *Note: If you’ve activated “Find My Mac” or FileVault, then you can’t enable the Guest account. The “Guest User” login created by “Find My Mac” is not the same. Create a new account in which to test, and delete it, including its home folder, after testing.
    Step 2
    The purpose of this step is to determine whether the problem is caused by third-party system modifications that load automatically at startup or login, by a peripheral device, by a font conflict, or by corruption of the file system or of certain system caches.
    Please take this step regardless of the results of Step 1.
    Disconnect all wired peripherals except those needed for the test, and remove all aftermarket expansion cards, if applicable. Start up in safe mode and log in to the account with the problem. You must hold down the shift key twice: once when you turn on the computer, and again when you log in.
    Note: If FileVault is enabled in OS X 10.9 or earlier, or if a firmware password is set, or if the startup volume is a software RAID, you can’t do this. Ask for further instructions.
    Safe mode is much slower to start up and run than normal, with limited graphics performance, and some things won’t work at all, including sound output and Wi-Fi on certain models. The next normal startup may also be somewhat slow.
    The login screen appears even if you usually log in automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin.
    Test while in safe mode. Same problem?
    After testing, restart as usual (not in safe mode) and verify that you still have the problem. Post the results of Steps 1 and 2.

  • Problems with the BBkey (also known as the menu key)

    Sometimes when I am in an app and want to click on one of the items in the menu list (e.g., delete), when I click on the menu key, what pops up are some of the icons from the home page.  (I am getting really tired of looking at that little penguin....).  If i persist, I can usually get the menu option to pop up, but it's annoying.  I am pretty sure it is a software problem.  I had this problem after some time on my first Tour.  I had to replace that because of other issues.  I used the Device Switch Wizard to transfer everything, so I guess it also transferred whatever is causing this issue. 
    Is anyone else having this problem?  Any ideas about what to do?  I don't want to re-install the OS-- I'd rather put up with the problem.  Thanks.
    Liz
    Solved!
    Go to Solution.

    Hi again!
    The BBKey/Menu key has two functions...
    1) To bring up a context-sensitive menu for the app you are in
    2) To bring up the app-switcher ribbon (a list of all of your currently running apps so that you can quickly change to a different app)
    The difference is how long you hold the key down. For 1, it's a quick press and release. For 2, it's a hold down. Sometimes, it gets it wrong, but with practice you will be able to get what you want most of the time (not 100% though...I still get the wrong result sometimes).
    Hope that helps!
    Occam's Razor nearly always applies when troubleshooting technology issues!
    If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
    Join our BBM Channels
    BSCF General Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • Is there another way of getting to the menu, without the menu key!

    Hi Everyone
    I am embarrassed to say that I managed to drop my blackberry in a cup of tea! Thankfully, it dried out eventually. But, the menu key will now not work
    Is there a way of accessing the menu (things such as pics, clock, games etc) without using the menu key itself?
    Thanks!
    Vix

    How long, how many days did you let it dry?
    Plus if there was sugar or sweetener in the cup, it could leave gunk or something in the device, you might actually need to use rubbing alcohol to clean the contacts.
    Until you decide that....
    1. Remove the battery immediately!! Do not attempt to turn on your BlackBerry.
    2. Let the device dry in a warm, dry place for 3 to 5 days* (see below)
    3. DO NOT "check it each day" by placing the battery in. Leave it be to dry completely. This takes time. Replacing the battery to check it can only damage it more (moisture + electrical current = disaster).
    3. If the device is warm after the drying period, allow it to cool to room temperature before placing the battery back in.
    *Suggestions on drying your BlackBerry in a warm place (open, with the battery out):
    Place the BB in a container of dry UNcooked rice, and then you might also place it in any of the locations mentioned below.
    On top of any dry heat emitting electronic component: TV cabinet or CRT, LCD, cable TV/Satellite converter box or plasma monitor
    On the dashboard of your car on a sunny day
    1. If any post helps you please click the below the post(s) that helped you.
    2. Please resolve your thread by marking the post "Solution?" which solved it for you!
    3. Install free BlackBerry Protect today for backups of contacts and data.
    4. Guide to Unlocking your BlackBerry & Unlock Codes
    Join our BBM Channels (Beta)
    BlackBerry Support Forums Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • Faulty keyboard - as though the command key is permanently pressed

    My Macbook has suddenly started behaving as though the Command key is permanently pressed down. Both of the keys actually feel normal when pressed - neither of them is stuck.
    Any ideas of how to fix this problem (I've tried a shut down)?
    If I cannot fix it, is a replacement keyboard something I could fit myself - will an Apple Retail Store be able to supply a replacement keyboard? (it's the first version of the white MacBook, out of warranty).

    OK problem solved. It was a wireless keyboard that had been left switched on and had junk piled onto it so the Apple key was pressed down.
    Panic over!

  • If a reinstall my mac pro with Time Machine the sounds in the sound menu don't play if i click 2 times in the menu. if i reinstall mountain lion afther that it works normally does anyone now what the problem is?

    hay
    I working from the beginning with fcpx i have fcp3 to
    But i have a problem with the sound effects in fcpx they dont play in the menu of fcpx if i reinstall my mac pro with time machine
    It is working again afther reinstall mountain lion.
    is there someone with te same problem or dus sombody now wat the problem is of this.
    Or is this a iseu of time machine ?
    i never had that problem with OSX lion
    Thanks

    Try getting the free "Preference Manger" applicaiton from Digital Rebellion (dot com).  Use it to trash the FCP X preference files.  See if that helps.
    Also, on the new Mac, go into the App Store, under the Store menu, make sure you are signed in.

  • How can I create a hashmap() with multiple values for the same key?

    I am trying to write an application that will us something like a Map() with multiple values but some have the same key. Is this possible?

    i had the same question. just create a List, add all the values u want to it, and then put the List into the map like u would a normal single value. e.g.
    List list = new ArrayList();
    list.add(value1);
    list.add(value2);
    map.put(key, list);
    i bet u r doing the same course as i am =)

  • What to do if the menu key is not working?

    a month after i got the phone my menu key is not working properly. sometimes it works and sometimes it dont. i already tried restoring my phone and all the the possible troubleshooting but still the same. what do i have to do?. my phone still under warranty and the company i purchased the phone said they are sending an email from apple yet ive been waiting for a month already and still there is no reply

    Go to settings>icloud>storage and back up>back up
    after that preform a restore by going to
    general>reset>erase all content and settings
    this will delete everything except the enabled stuff on icloud.
    You can view whats enabled by going to icloud in settings.

  • My iPhone 5 gives a busy tone whenever someone calls the first time. The person has to call a second time for the ringtone to be heard? How o I tux this issue? I have a missed call every time and then a ringtone.

    My iPhone 5 gives the caller a busy tone the first time when the phone is actually not in use. The caller has to make another call to get the ringtone. I will get the first call as missed with no ringtone and then the second time it will ring. What can be fond to solve this problem ?

    Turn off Do Not Disturb.
    http://support.apple.com/kb/HT5463?viewlocale=en_US&locale=en_US

  • How do I get the menu bar to appear on multiple displays without mirroring displays?

    I keep finding things about the new Yosemite update that I do not like. The most recent is that apparently you can't have a menubar on multiple displays, unless you mirror the displays. This does not work for me. I want to keep my thunderbolt display as my primary display, but I am working in photoshop on my Cintiqu and I can't afford to drag my mouse all the way back to the thunderbolt display every time I need to access the photoshop menu.
    Is there some sort of fix for this that I'm not seeing?
    If not I sincerely hope that the apple engineers fix this ASAP.

    Send Apple feedback. They won't answer, but at least will know there is a problem. If enough people send feedback, it may get the problem solved sooner.
    Feedback

  • Right click mavericks must be hit up to five times before the menu stays

    EVer since i installed Mavericks, my secondary click has been wonky. As the title says it sometimes takes up to 5 mouse clicks to get context menus to remain on screen. Im using  generic USB mouse that was perfect...since always. Any ideas?

    Okay, so here is where I've gotten to now.
    Closet mouse has worked perfectly as a clicking mouse. Sadly, I believe this is a much older mouse and it's optics arn't as good senseing that i'm moving it around my physical desktop. Shame as I like the other mouse much better. Still a wonder why the old one has issues when attached in a USB chain but not to the iMac directly.(though again, the only change made was the Mavericks update so talk all you want about other possibilities - 1 change, sudden issue.... hmmmm)
    Also to be clear, it isn't that the click isn't being recognized, the context menu just disappears as soon as it comes up. But I need a working mouse and doing a fresh Mavericks install would be way too much of a pain to hunt down all the old install files I'd need not to mention the time it would take doing the actual installs.
    TL;DR version: Problem isn't solved, just sufficiently worked around.
    Thank you all for your support, ideas, and solutions!
    Long live Apple! .... usually.

  • Where is the EXACT version number shown?  Where is the menu link to the Help file?  Why is there no scroll bar?  The new iTunes is terrible in more ways than I can list... how do I switch back to version 10?

    The newest iTunes version has no Help option.  Why?  And, no ability to find out the version number.
    The new iTunes, when in album view in Windows 7, has NO SCROLLBARS, so it is impossible to scroll the albums.  Why?
    Answer these questions, as I am an AAPL shareholder and I am NOT happy with these and other changes you've made to iTunes.

    The newest iTunes version has no Help option.  Why?  And, no ability to find out the version number.
    You may need to bring up your Menu Bar to see the Help menu.
    If you're using 11.0.x, click on the wee boxy icon up in the top-left corner of your iTunes to see the "Show Menu Bar" control, as per the following screenshot:
    Once you've got your Help menu showing, go "Help > About iTunes" and wait for the version number to scroll up from the bottom of the screen, as per the previous versions.

Maybe you are looking for

  • How do I organise a photo show in file order?

    I'm trying to import a load of photos into a movie I'm making. I've named them all so they stack in the correct order, but Premier 8 seems insistant on putting them in date order, which is no good for my purposes. How do I get it to put them into the

  • How to discontinue Dual Monitor

    I can't seem to figure out how to discontinue using my dual monitors on my G4 OS 9. I installed an additional video card about a year ago for Pro Tools use. I'm now selling the G4, but can't seem to get the monitor to work without both hooked up. Oth

  • UC560 T1/E1 Noob question

    Quick question, we are installing a new UC560 e1/t1 device on our company network behind our asa 5520 firewall. We are ordering a dedicated t1 line we want to run directly into the UC560. Verzion is supply us with a Adtran router for the T1. Will the

  • Finding duplicate ranges for rows in a table

    Data in the table ROW NUM ID A_FROM A_TO B_FROM B_TO 1 1 1 10 1 10 2 1 1 20 2 20 3 1 3 30 2 20 4 2 10 20 10 20 5 2 10 30 20 30 6 3 10 20 10 20 I want to identify rows based on "ID" columns which has overlaping range of data for column A and column B.

  • ITunes won't re-download a previous purchase

    Hi all, I have particular downloads that I purchased over a year ago on an Acer laptop. I now need to re-download both however iTunes says i have not purchased the copies onto a HP laptop, however in my account settings it shows up as purchased in No