Solved

How to refresh menu item state?

Posted on 2000-05-18
4
378 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 30 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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 …
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

726 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