Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Help! ON_UPDATE_COMMAND_UI Not called prior to menu display

Help! ON_UPDATE_COMMAND_UI Not called prior to menu display

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestionannouncement
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    work_to_live
    wrote on last edited by
    #1

    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.

    R J 2 Replies Last reply
    0
    • W work_to_live

      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.

      R Offline
      R Offline
      Roger Allen
      wrote on last edited by
      #2

      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!

      1 Reply Last reply
      0
      • W work_to_live

        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.

        J Offline
        J Offline
        Jonathan Craig
        wrote on last edited by
        #3

        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

        W 2 Replies Last reply
        0
        • J Jonathan Craig

          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

          W Offline
          W Offline
          work_to_live
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          • J Jonathan Craig

            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

            W Offline
            W Offline
            work_to_live
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups