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 a message to a dialog

How to send a message to a dialog

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestionlounge
4 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.
  • N Offline
    N Offline
    Nest
    wrote on last edited by
    #1

    I have a view from wh:eek:ere I call an Object A property dialog (modal). In that Dailog I call an Object B property dialog (non modal). It may happen that the Object A is destroyed in the Object B property dialog. So it looks logical to close the Object A property dialog automatically by sending it a message to close itself. OK, I know how to write and handle messages in general but i don't know how to send a message to the Object A property dialog. Should i store a pointer to this dialog and then call a SendMessage? Looks absurd... SendMessageToDescendants() called for AfxGetMainWnd() doesn't work... Any explanation would be appreciated.

    R N 2 Replies Last reply
    0
    • N Nest

      I have a view from wh:eek:ere I call an Object A property dialog (modal). In that Dailog I call an Object B property dialog (non modal). It may happen that the Object A is destroyed in the Object B property dialog. So it looks logical to close the Object A property dialog automatically by sending it a message to close itself. OK, I know how to write and handle messages in general but i don't know how to send a message to the Object A property dialog. Should i store a pointer to this dialog and then call a SendMessage? Looks absurd... SendMessageToDescendants() called for AfxGetMainWnd() doesn't work... Any explanation would be appreciated.

      R Offline
      R Offline
      Rajesh_Parameswaran
      wrote on last edited by
      #2

      Hi, you can define a public function in the ObjectA property Dialog and in the second dialog's close function, u just create a member of the first one and invoke the public function of ObjectA dialog box, which inturn calls the OnOK() function. ObjectA.cpp --------- void CADlg::Destroy() { OnOK(); } ObjectB.cpp ----------- void CBDlg::OnButton1() { // TODO: Add your control notification handler code here OnOK(); CADlg *pWnd = (CADlg*)GetParent(); pWnd->Destroy(); } or can also use this way void CBDlg::OnButton1() { // TODO: Add your control notification handler code here OnOK(); CADlg *pWnd = (CADlg*)GetParent(); pWnd->EndDialog(); } Regards, Rajesh

      N 1 Reply Last reply
      0
      • R Rajesh_Parameswaran

        Hi, you can define a public function in the ObjectA property Dialog and in the second dialog's close function, u just create a member of the first one and invoke the public function of ObjectA dialog box, which inturn calls the OnOK() function. ObjectA.cpp --------- void CADlg::Destroy() { OnOK(); } ObjectB.cpp ----------- void CBDlg::OnButton1() { // TODO: Add your control notification handler code here OnOK(); CADlg *pWnd = (CADlg*)GetParent(); pWnd->Destroy(); } or can also use this way void CBDlg::OnButton1() { // TODO: Add your control notification handler code here OnOK(); CADlg *pWnd = (CADlg*)GetParent(); pWnd->EndDialog(); } Regards, Rajesh

        N Offline
        N Offline
        Nest
        wrote on last edited by
        #3

        It's not that easy - the dialog B is a modaless dialog and its parent is a MainFrame...

        1 Reply Last reply
        0
        • N Nest

          I have a view from wh:eek:ere I call an Object A property dialog (modal). In that Dailog I call an Object B property dialog (non modal). It may happen that the Object A is destroyed in the Object B property dialog. So it looks logical to close the Object A property dialog automatically by sending it a message to close itself. OK, I know how to write and handle messages in general but i don't know how to send a message to the Object A property dialog. Should i store a pointer to this dialog and then call a SendMessage? Looks absurd... SendMessageToDescendants() called for AfxGetMainWnd() doesn't work... Any explanation would be appreciated.

          N Offline
          N Offline
          namaskaaram
          wrote on last edited by
          #4

          maybe this could help..... use GetParent() function and retrieve the pointer to the main window, then use the PostMessage(WM_CLOSE, 0, 0); hope that helpz..... cheerz :-D

          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