Discussion:
OnUpdate handlers not called for toolbar buttons (repost)
(too old to reply)
pwm
2007-01-16 16:23:49 UTC
Permalink
I have menu items command and onupdate handlers that I am also using for
toolbar buttons, but the onupdate handlers only get called when I expose
the menu, so the state of my toolbar buttons are incorrect.

Any suggestions on what I might be doing wrong?

Thanks,
Phil
AliR (VC++ MVP)
2007-01-16 22:26:28 UTC
Permalink
Do the toolbar buttons have the same id as the menu items? This
toolbar/Menu is not in a dialog box by any chance?

AliR.
Post by pwm
I have menu items command and onupdate handlers that I am also using for
toolbar buttons, but the onupdate handlers only get called when I expose
the menu, so the state of my toolbar buttons are incorrect.
Any suggestions on what I might be doing wrong?
Thanks,
Phil
pwm
2007-01-17 14:39:11 UTC
Permalink
Post by AliR (VC++ MVP)
Do the toolbar buttons have the same id as the menu items? This
toolbar/Menu is not in a dialog box by any chance?
Yes, they have the same id. No, they are not in a dialog box. They are
buttons on an toolbar attached to an MDI main frame. The onupdate
handlers are called when I expose the menu items and the command states
are then correctly reflected in the toolbar buttons. But the MDI
framework does not call the onupdate handlers just because the commands
are exposed as items on a toolbar.

It seems as if I need to tickle them with a timer or somehow wire in
some onidle processing. Either way, I do not know how to do so because
the framework sets up the arguments passed into the onupdate handlers.

Thanks for your help.
Ajay Kalra
2007-01-17 23:51:46 UTC
Permalink
Post by pwm
Post by AliR (VC++ MVP)
Do the toolbar buttons have the same id as the menu items? This
toolbar/Menu is not in a dialog box by any chance?
Yes, they have the same id. No, they are not in a dialog box. They are
buttons on an toolbar attached to an MDI main frame. The onupdate
handlers are called when I expose the menu items and the command states
are then correctly reflected in the toolbar buttons. But the MDI
framework does not call the onupdate handlers just because the commands
are exposed as items on a toolbar.
It seems as if I need to tickle them with a timer or somehow wire in
some onidle processing. Either way, I do not know how to do so because
the framework sets up the arguments passed into the onupdate handlers.
Thanks for your help.
Where are the handlers of these toolbar menus? It would be wired by default
unless you do something to override the behavior. Perhaps you have handlers
in a doc or view specific to a MDI type.

--
Ajay Kalra [MVP - VC++]
***@yahoo.com
pwm
2007-01-18 14:37:50 UTC
Permalink
Post by Ajay Kalra
Where are the handlers of these toolbar menus? It would be wired by default
unless you do something to override the behavior. Perhaps you have handlers
in a doc or view specific to a MDI type.
Different toolbars are done differently. Some toolbars have the
handlers in the main frame while others have the handlers specific to a
view. Right now, I am focusing on the handlers for the main frame,
which are the ones that are not being called. Yes, the on update
handlers are wired by default, but they are called only when the menu
items are exposed.

As I understand MFC onupdate handlers for command items, the framework
calls them whenever it needs to show the command state, which is
whenever the popup menu displays the menu items. What is the mechanism
MFC uses to call on update handlers for commands that are visible via
toolbar buttons? Is it done in onidle or with a timer? Or something else?

Thanks,
Phil
Charles Wang[MSFT]
2007-01-18 12:38:01 UTC
Permalink
Hi,
From your description,
The onupdate handlers are called when I expose the menu items and the
command states
are then correctly reflected in the toolbar buttons. But the MDI framework
does not call the onupdate handlers just
because the commands are exposed as items on a toolbar.
I understand that if you hidden the menu bar, OnUpdate handlers cannot be
triggered by MDI framework.
If I have misunderstood, please let me know.

To let us better understand your issue and for further research, could you
please let me know the following questions:
1. Where did you define the OnUpdate handler?
As far as I know, OnUpdate is a method of CView. What is your meaning
that the MDI framework does not call the OnUpdate handler?
2. Did the COMMAND event handler work fine?
3. Could you reproduce your issue if you create a new simple MDI
application? If so, could you please let us know your process. If not,
could you please mail me (***@microsoft.com) your test project for
further research?

Look forward to your response.

Sincerely yours,
Charles Wang
Microsoft Online Community Support

======================================================
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
======================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
======================================================
pwm
2007-01-18 14:47:54 UTC
Permalink
Post by Charles Wang[MSFT]
I understand that if you hidden the menu bar, OnUpdate handlers cannot be
triggered by MDI framework.
If I have misunderstood, please let me know.
Well, I am not intentionally hiding the menu bar. I am trying to
develop a conventional MFC MDI application. I have a menu, with menu
items that have commands associated with them. The command handlers and
on update handlers work as they should for the menu items. I also have
toolbar buttons that use the same command IDs as the menu items. But
the onupdate handlers are called only when the menu items are exposed.
The problem is that the onupdate handlers are not called simply because
the commands are visible via a toolbar; therefore, the state of the
toolbar buttons are only correct when I expose the menu items.
Post by Charles Wang[MSFT]
To let us better understand your issue and for further research, could you
1. Where did you define the OnUpdate handler?
As far as I know, OnUpdate is a method of CView. What is your meaning
that the MDI framework does not call the OnUpdate handler?
Some handlers are on the main frame, not a view.
Post by Charles Wang[MSFT]
2. Did the COMMAND event handler work fine?
As I said above, the command event handlers and the onupdate event
handlers work fine for the menu items. And the command handlers work
fine for the toobar buttons. The onupdate handlers are simply not being
called simply because they appear as toolbar buttons. The onupdate
handlers are getting called only when the menu items are exposed.
Post by Charles Wang[MSFT]
3. Could you reproduce your issue if you create a new simple MDI
application? If so, could you please let us know your process. If not,
further research?
I have not tried to reproduce the behavior with a new simple MDI
application. I was hoping to better understand the problem and avoid
having to start over with a new app.

Thanks,
Phil
Charles Wang[MSFT]
2007-01-19 10:17:16 UTC
Permalink
Hi Phil,
I created a simple MDI project in VS2003 and tried to reproduce your issue,
however I could not reproduce your issue at my side. I used the default
menu loaded by main frame, associated the ID_FILE_NEW to the
OnUpdateFileNew event handler. However I found that it was always invoked.
The handler will not be invoked when I deleted the menu items (New) and the
tool bar button (New). Then I added a tool bar button and named it
ID_FILE_NEW. When I clicked it, the OnUpdateFileNew event was invoked
again and again.

I think that this should not be a difficult issue, however if we could not
reproduce your issue, it is hard for us to go further.
Could you please mail me (***@microsoft.com) your project so that I
can perform further research?

If it is not convenient for you to send your project via internet, I would
like to provide a senior support channel for you. Please contact Microsoft
Customer Support Services (CSS) via telephone so that a dedicated Support
Professional can assist you recover the server in a more efficient manner.
Please be advised that contacting phone support will be a charged call.

To obtain the phone numbers for specific technology request please take a
look at the web site listed below.
http://support.microsoft.com/default.aspx?scid=fh;EN-US;PHONENUMBERS

If you are outside the US please see http://support.microsoft.com for
regional support phone numbers.

Sincerely yours,
Charles Wang
Microsoft Online Community Support

======================================================
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
======================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
======================================================
Ajay Kalra
2007-01-19 01:41:32 UTC
Permalink
Post by Charles Wang[MSFT]
Hi,
From your description,
The onupdate handlers are called when I expose the menu items and the
command states
are then correctly reflected in the toolbar buttons. But the MDI framework
does not call the onupdate handlers just
because the commands are exposed as items on a toolbar.
I understand that if you hidden the menu bar, OnUpdate handlers cannot be
triggered by MDI framework.
How do you hide a menu bar? AFAIK, You can only destroy/recreate it. MFC
doesnt have any support for this.

--
Ajay Kalra [MVP - VC++]
***@yahoo.com
Charles Wang[MSFT]
2007-01-19 09:22:57 UTC
Permalink
Hi,
Well, my original meaning is that. Sorry for misusing the word here.
Thanks for your pointing out.


Charles Wang
Microsoft Online Community Support

======================================================
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
======================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
======================================================
Charles Wang[MSFT]
2007-01-23 14:51:46 UTC
Permalink
Hi, Phil,
Just check with you if you need further assistance on this issue.

I would like your posting back at your convenience. If you have any other
questions or concerns, please feel free to let us know.

Sincerely yours,
Charles Wang
Microsoft Online Community Support
pwm
2007-01-23 15:54:09 UTC
Permalink
Post by Charles Wang[MSFT]
Hi, Phil,
Just check with you if you need further assistance on this issue.
I would like your posting back at your convenience. If you have any other
questions or concerns, please feel free to let us know.
Sincerely yours,
Charles Wang
Microsoft Online Community Support
Charles,
Thanks for you help. I am unable to fix the problem, and I am unable to
package up my code to send to you. I will try to start over and see if
the problem goes away. I expect it will and will let you know if it
does not. It will take me a while to get around to it.

Phil
Charles Wang[MSFT]
2007-01-30 08:49:04 UTC
Permalink
Hi,
Just check with you to see if you need further assistance on this issue.
We appreciate your posting back at your convenience.

Sincerely yours,
Charles Wang
Microsoft Online Community Support

======================================================
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
======================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
======================================================
Charles Wang[MSFT]
2007-02-01 12:25:45 UTC
Permalink
Hi Phil,
I am intrested in this issue. Could you please let me know the issue status?
If this issue has not been fixed, I would like to assist you further.
Since it is not convenient for you to mail me the project for further
research, could you please leave me (***@microsoft.com) your email? I
can send my test project to you so that you can check if my test project
can suit your situation.

If that is still not convenient for you, I would like to provide you a
senior support channel. You can contact Microsoft Customer Support Services
(CSS) via telephone so that a dedicated Support Professional can assist you
recover the server in a more efficient manner. Please be advised that
contacting phone support will be a charged call.

To obtain the phone numbers for specific technology request please take a
look at the web site listed below.
http://support.microsoft.com/default.aspx?scid=fh;EN-US;PHONENUMBERS

If you are outside the US please see http://support.microsoft.com for
regional support phone numbers.

Sincerely yours,
Charles Wang
Microsoft Online Community Support

======================================================
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
======================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
======================================================

Loading...