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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. how to send message to CCmdTarget

how to send message to CCmdTarget

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestioncareer
2 Posts 2 Posters 2 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.
  • S Offline
    S Offline
    spiritofklanawa
    wrote on last edited by
    #1

    To send a message to a CWnd derived object is easy, I use SendMessage() method. Could anyone help me understand how to send message to a CCmdTarget derived object such as CDocument which owns a message table (BEGIN_MESSAGE_MAP/END_MESSAGE_MAP) ? Perhaps I'm just going down the difficult path. Namely, I'm trying to send a "new-document" menu message to the SDI document to force cleanup and get the "option to save modified" feature. For some reason if I call OnNewDocument() method directly the framework ignors the fact that the current document is "modified". I though sending the menu message would fool the framework to do its job. Thanks bunches Alex

    R 1 Reply Last reply
    0
    • S spiritofklanawa

      To send a message to a CWnd derived object is easy, I use SendMessage() method. Could anyone help me understand how to send message to a CCmdTarget derived object such as CDocument which owns a message table (BEGIN_MESSAGE_MAP/END_MESSAGE_MAP) ? Perhaps I'm just going down the difficult path. Namely, I'm trying to send a "new-document" menu message to the SDI document to force cleanup and get the "option to save modified" feature. For some reason if I call OnNewDocument() method directly the framework ignors the fact that the current document is "modified". I though sending the menu message would fool the framework to do its job. Thanks bunches Alex

      R Offline
      R Offline
      Ryan Binns
      wrote on last edited by
      #2

      You could just call the menu handler directly - OnFileNew(). The other way (as you suggest) is to send a WM_COMMAND message with the ID_FILE_NEW command ID to your main window (not to the document directly).

      Ryan

      "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

      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