Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to refresh menu item state?

Posted on 2000-05-18
4
Medium Priority
?
380 Views
Last Modified: 2012-06-27
Hi.
I want to get state of menu item (enabled, checked etc...) with GetMenuState() function. But when this menu item invisible, this function retrieves old value of menu state (when item was last visible). How can I refresh state of menu item without showing it.
Note: menu item message handler don't belong to my application.
0
Comment
Question by:double_axe
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 22

Expert Comment

by:nietod
ID: 2820785
Many applications will reset their menu states just prior to showing their menus.  This is what the WM_INITMENU messages is for.  So changing another application's menu is pointless, the application will change it back.  Changing another application's _____ is also unwise.  _______ belongs to another application, you shouldn't be screwing with it.  
0
 
LVL 3

Author Comment

by:double_axe
ID: 2820828
I don't want to change that menu, just want to know, if it's enabled or not. So, as I understand, I can send WM_INITMENU message to refresh menu.
1. If I send WM_INITMENU to another application's window and then will not show it's submenus, will application run normally or crash?
2. What window I must send WM_INITMENU message to? To toplevel frame?
3. Can I use SendMessage() or I must use PostMessage() or PostThreadMessage()?
0
 
LVL 22

Accepted Solution

by:
nietod earned 90 total points
ID: 2820883
You can send the message to the top-level window.  That is how it is "really" performed.

You could do that, but I still don't recomend it.  The OS is supposed to send that message, not your application.  It is supposed to be sent under a very specific circumstance, this isn't it.  It will be harmless 99 out of 100 times.  but in that 100th time, there will be a problem.  For example it is reasonable for an app to assume that the menu will be displayed after that message--that is the idea.  so an application might allocate some memory or other resource on tha message intending to free it when the menu is closed.  but the menu is never closed (its never opened) so now the app has a memory leak. But its not the apps fault....  There must be 100s of other things that you can make go wrong in this way.

Note that the problems are likely to be app specific.  i.e most apps will be fine with it, but some won't.  But the ones that aren't fine with it, might not show problems right away or ender every circumstance.  That is another thing that makes this dangerous.
0
 
LVL 3

Author Comment

by:double_axe
ID: 2824100
I'll think about another way to do this. But if I don't find it, I'll have to use this one.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

715 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