Menu enabling/disabling (ON_UPDATE_COMMAND_UI) 
Author Message
 Menu enabling/disabling (ON_UPDATE_COMMAND_UI)

Hi. Am I missing something? I want some of my popup menu items were
enabled/disabled depending on states of variables. I read somewhere that I
may use ON_UPDATE_COMMAND_UI to accomplish it, namely,

ON_UPDATE_COMMAND_UI(ID_COMMAND1, OnUpdateCommand1);

What confuses me is that it was said this method would be called whenever a
control with ID_COMMAND1 id is about to be shown. But instead I have it
called only when I click on the menu item with ID_COMMAND1 id. Where is my
mistake?

-d



Mon, 23 May 2005 04:50:44 GMT  
 Menu enabling/disabling (ON_UPDATE_COMMAND_UI)

Quote:
>Hi. Am I missing something? I want some of my popup menu items were
>enabled/disabled depending on states of variables. I read somewhere that I
>may use ON_UPDATE_COMMAND_UI to accomplish it

Dmity,

Which window is the parent of your popup menu? For the update to work
I think you need to use the main frame window.

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq



Mon, 23 May 2005 06:16:26 GMT  
 Menu enabling/disabling (ON_UPDATE_COMMAND_UI)

Quote:
>>Hi. Am I missing something? I want some of my popup menu items were
>>enabled/disabled depending on states of variables. I read somewhere that I
>>may use ON_UPDATE_COMMAND_UI to accomplish it

> Dmity,

> Which window is the parent of your popup menu? For the update to work
> I think you need to use the main frame window.

> Dave

Well, it is actually CView child. But what difference does it make?

-d



Mon, 23 May 2005 10:00:01 GMT  
 Menu enabling/disabling (ON_UPDATE_COMMAND_UI)

Quote:
>>>Hi. Am I missing something? I want some of my popup menu items were
>>>enabled/disabled depending on states of variables. I read somewhere that I
>>>may use ON_UPDATE_COMMAND_UI to accomplish it

>> Dmity,

>> Which window is the parent of your popup menu? For the update to work
>> I think you need to use the main frame window.

>> Dave

>Well, it is actually CView child. But what difference does it make?

It determines where the notification messages are sent to.
You need to change it.

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq



Mon, 23 May 2005 15:23:41 GMT  
 Menu enabling/disabling (ON_UPDATE_COMMAND_UI)

Quote:
>>>>Hi. Am I missing something? I want some of my popup menu items were
>>>>enabled/disabled depending on states of variables. I read somewhere that I
>>>>may use ON_UPDATE_COMMAND_UI to accomplish it

>>>Dmity,

>>>Which window is the parent of your popup menu? For the update to work
>>>I think you need to use the main frame window.

>>>Dave

>>Well, it is actually CView child. But what difference does it make?

> It determines where the notification messages are sent to.
> You need to change it.

> Dave

Great! How about data incapsulation?! I do not care about MainFrame! I have
a lot of view that has nothing to do with frames - I use them in several
places. They have toolbars and other stuff... This is nonsense. Is it the
way how it is impelemented? I cannot believe that.

-d



Mon, 23 May 2005 15:56:57 GMT  
 Menu enabling/disabling (ON_UPDATE_COMMAND_UI)

Quote:
>Great! How about data incapsulation?! I do not care about MainFrame! I have
>a lot of view that has nothing to do with frames - I use them in several
>places. They have toolbars and other stuff... This is nonsense. Is it the
>way how it is impelemented? I cannot believe that.

I think you're getting upset over nothing much. Just try passing the
window handle for the main frame as the parent window to your call to
TrackPopupMenu and see if that resolves the problem.

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq



Mon, 23 May 2005 18:00:27 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Enable/Disable menus/buttons similar to MFC ON_UPDATE_COMMAND_UI

2. Enabling menu items without ON_UPDATE_COMMAND_UI

3. How to disable/enable Popup menu item of the main menu

4. Enabling/Disabling Menu items for a menu on a dialog application

5. Disable/Enable menus?

6. Enable and Disable Menu Items

7. WTL: Enabling and disabling menu items

8. How to disable/enable menu item?

9. How to disable.enable menu item?

10. Enable/Disable of top-level menu items

11. Context menu item disable/enable

12. PROBLEM IN MENU ITEM DISABLING ENABLING

 

 
Powered by phpBB® Forum Software