Solved

Status Bar text not updated with context menu

Posted on 2004-10-29
251 Views
Last Modified: 2013-11-20
I have a MDI project that has a right-click context menu. I went to the properties of one of the menu items, and added some text in the prompt. When I right click and move my mouse over the menu item, the status bar isn't updated with the text from my menu item. I am loading my context menu in the OnRButtonUp function in my View class. I am assuming this is the expected behavior and I'll probably need to add some extra code to have my menu update the text on the status bar. Can someone help me understand where that text that I filled into the prompt field goes and how I can update my status bar with that text?
Thanks
0
Question by:Nhl2k
    8 Comments
     
    LVL 19

    Expert Comment

    by:mrwad99
    0
     

    Author Comment

    by:Nhl2k
    This question deals with sending text to the status bar on a popup menu item. I am trying to get text on the status bar from a menu item that's in a context menu when I right click.
    0
     
    LVL 19

    Expert Comment

    by:mrwad99
    Ah yes; appologies.

    I will try and find a way to do this later.
    0
     
    LVL 19

    Expert Comment

    by:mrwad99
    Hi Nhl2k.

    Sorry about the delay.  I have looked into this problem a little more, and found that you can get the status bar text to appear if the items in the context menu are also in the main application menu.  For example, you could have the option to create a new window in your context menu and also in the File menu; if both menus have the same ID (eg ID_CREATE_NEW_WINDOW) then the text specified as the prompt for the top level menu will also appear in that for the context menu.  However, adding a new item to the context menu that is not in the top level menu still refuses to show the status bar text.  This is annoying, and I will look into this even further as I cannot see why it should refuse to work.

    Hope this update is of use; feel free to close this question you want.
    0
     

    Author Comment

    by:Nhl2k
    No problem. I'll leave the question open for a while and if you don't think you have an answer, just let me know and I'll close the question. I found it annoying too and it made me wonder how other applications do it. Even in Internet Explorer, if you right click and move your mouse over an item, it shows the status bar text, and I don't see why it's so hard to find documentation on this subject.
    0
     
    LVL 19

    Accepted Solution

    by:
    I have just created a simple MDI app that has a context menu; the status bar text is now updated fine !

    See http://homepage.ntlworld.com/d.billingham/R/Test.zip

    I think the problem lies in where you are invoking the menu; it should be in

    OnContextMenu(CWnd* pWnd, CPoint point)

    not

    OnRButtonUp(....)
    0
     

    Author Comment

    by:Nhl2k
    Actually, you helped me solve the problem but it wasn't because the menu wasn't in the OnContextMenu function. For some reason, the book I am referencing passed the "this" pointer in the view class as the pWnd parameter to the TrackPopupMenu function, when I needed to use AfxGetApp()->m_pMainWnd to get the main window's pointer. I guess I should have posted the code I had for loading the menu but I didn't think that was the problem.
    Thanks for the help!
    0
     
    LVL 19

    Expert Comment

    by:mrwad99
    Ah right, I had that problem too.  I think in the source code I referred to the question on EE that got me sorted; it is
    http:Q_20285802.html for future reference.

    Glad to help overall :)
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
    Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    856 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

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now