Help! ON_UPDATE_COMMAND_UI Not called prior to menu display
-
I've been going round and round for a few hours now, and can't see what's wrong with my application. I have a doc/view application that uses multiple static splitter windows for the views. I created a menu and added handlers for both the command and update messages, in the view class. For some reason, the update message handler is not called prior to displaying the menu, and consequently, the menu is not set up properly (Checked items are not updated). I have verified with another application that works properly that the message maps are created properly. I realize this is a fairly wide open description of a problem, but so far, I've received excellent suggestions (solutions) for problems I've had in the past with a simple description like this. Any suggestions on where to look? Thanks in advance.
-
I've been going round and round for a few hours now, and can't see what's wrong with my application. I have a doc/view application that uses multiple static splitter windows for the views. I created a menu and added handlers for both the command and update messages, in the view class. For some reason, the update message handler is not called prior to displaying the menu, and consequently, the menu is not set up properly (Checked items are not updated). I have verified with another application that works properly that the message maps are created properly. I realize this is a fairly wide open description of a problem, but so far, I've received excellent suggestions (solutions) for problems I've had in the past with a simple description like this. Any suggestions on where to look? Thanks in advance.
At a guess, I would say that the ON_COMMAND_UI handler come through to the first view added and not those supported in the splitter windows. If you undate handlers are in the spliiter window added views then they would not be called. You have to implement some kind of mechanism which would route these checks through from the first view to these sub-views to allow them to update/act on the commands. Roger Allen Sonork 100.10016 I have a terminal disease. Its called life!
-
I've been going round and round for a few hours now, and can't see what's wrong with my application. I have a doc/view application that uses multiple static splitter windows for the views. I created a menu and added handlers for both the command and update messages, in the view class. For some reason, the update message handler is not called prior to displaying the menu, and consequently, the menu is not set up properly (Checked items are not updated). I have verified with another application that works properly that the message maps are created properly. I realize this is a fairly wide open description of a problem, but so far, I've received excellent suggestions (solutions) for problems I've had in the past with a simple description like this. Any suggestions on where to look? Thanks in advance.
See my reply to another post: http://www.codeproject.com/script/comments/forums.asp?msg=187019&forumid=1647&kw=Jonathan+Craig#xx187019xx. If each of your CView classes can handle the messages, then it is just a matter of getting the messages to the correct view. You may need to customize the CSplitterWnd::OnCmdMsg override to route the message to all the views. :) Jonathan Craig www.mcw-tech.com
-
See my reply to another post: http://www.codeproject.com/script/comments/forums.asp?msg=187019&forumid=1647&kw=Jonathan+Craig#xx187019xx. If each of your CView classes can handle the messages, then it is just a matter of getting the messages to the correct view. You may need to customize the CSplitterWnd::OnCmdMsg override to route the message to all the views. :) Jonathan Craig www.mcw-tech.com
Jonathan, Even though I see some behavior that indicates the messages are routed at some level, I'll give your suggestion a try. The behavior I'm talking about is the fact that the ON_UPDATA_COMMAND_UI handler is called after the menu is dismissed, not before. Of course it'll all probably make perfect sense once I get to the bottom of it. :) Thanks.
-
See my reply to another post: http://www.codeproject.com/script/comments/forums.asp?msg=187019&forumid=1647&kw=Jonathan+Craig#xx187019xx. If each of your CView classes can handle the messages, then it is just a matter of getting the messages to the correct view. You may need to customize the CSplitterWnd::OnCmdMsg override to route the message to all the views. :) Jonathan Craig www.mcw-tech.com
Tried overriding OnCmdMsg in CChildFrame, and my splitter window. Still no luck. Then I thought I'd try placing the menu items on the main menu bar instead of in the popup menu I was using (an important piece of information I omitted from the original problem statement). The menu bar implementation worked perfectly. It got me thinking it must have something to do with the way I implemented the popup menu. The only thing I saw was the use of the this pointer as the owner of the popup menu (my view). I changed the owner from this to GetParentFrame(), and everything started working! I suppose the mechanism that implements the ON_UPDATE_COMMAND_UI message is above the View class in this MDI multi splitter window application. Oh well, live and learn. Here's the simple change that solved the problem. was... subMenu->TrackPopupMenu(0, point.x, point.y,this, NULL); is... (works) subMenu->TrackPopupMenu(0, point.x, point.y,GetParentFrame(), NULL); Thanks anyway for taking the time to respond. Maybe this will help someone else.