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. how to send messages between diferents dialogs?

how to send messages between diferents dialogs?

Scheduled Pinned Locked Moved C / C++ / MFC
questiontutorial
14 Posts 5 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.
  • T Offline
    T Offline
    timbk
    wrote on last edited by
    #1

    Hello, in my aplication there are two dialogs CCalibracionDlg and DlgMap1 both derived from Cdialog, when I press a button in DlgMap1 i have to send a message to CCalibracionDlg, how can i do this? I've been trying to do this with PostMessage(hWnd, WM_MYCUSTOMMESSAGE,(WPARAM) wParam,(LPARAM) lParam ); or SendMessage , but in DlgMap1 how can i get the hWnd to CCalibracionDlg? Thanks in advance.

    T A C D T 5 Replies Last reply
    0
    • T timbk

      Hello, in my aplication there are two dialogs CCalibracionDlg and DlgMap1 both derived from Cdialog, when I press a button in DlgMap1 i have to send a message to CCalibracionDlg, how can i do this? I've been trying to do this with PostMessage(hWnd, WM_MYCUSTOMMESSAGE,(WPARAM) wParam,(LPARAM) lParam ); or SendMessage , but in DlgMap1 how can i get the hWnd to CCalibracionDlg? Thanks in advance.

      T Offline
      T Offline
      theCPkid
      wrote on last edited by
      #2

      How and where in the code are you creating CCalibracionDlg? You must be having the object of CCalibracionDlg in your appplication. Why cant you share it with DlgMap1 class?

      1 Reply Last reply
      0
      • T timbk

        Hello, in my aplication there are two dialogs CCalibracionDlg and DlgMap1 both derived from Cdialog, when I press a button in DlgMap1 i have to send a message to CCalibracionDlg, how can i do this? I've been trying to do this with PostMessage(hWnd, WM_MYCUSTOMMESSAGE,(WPARAM) wParam,(LPARAM) lParam ); or SendMessage , but in DlgMap1 how can i get the hWnd to CCalibracionDlg? Thanks in advance.

        A Offline
        A Offline
        Adam Roderick J
        wrote on last edited by
        #3

        well i dont think sendMessage is a good option if they are belonging to the same application and thread. one method will be use FindWindowEx, that give you the handle if you specify the name of the dialog.

        Величие не Бога может быть недооценена.

        modified on Thursday, October 22, 2009 12:53 AM

        1 Reply Last reply
        0
        • T timbk

          Hello, in my aplication there are two dialogs CCalibracionDlg and DlgMap1 both derived from Cdialog, when I press a button in DlgMap1 i have to send a message to CCalibracionDlg, how can i do this? I've been trying to do this with PostMessage(hWnd, WM_MYCUSTOMMESSAGE,(WPARAM) wParam,(LPARAM) lParam ); or SendMessage , but in DlgMap1 how can i get the hWnd to CCalibracionDlg? Thanks in advance.

          C Offline
          C Offline
          Cool_Dev
          wrote on last edited by
          #4

          CCalibracionDlg and DlgMap1 both derived from Cdialog, when I press a button in DlgMap1 i have to send a message to CCalibracionDlg, how can i do this? I've been trying to do this with PostMessage(hWnd, WM_MYCUSTOMMESSAGE,(WPARAM) wParam,(LPARAM) lParam ); or Better to have an 'object' or pointer of CCalibracionDlg in DlgMap1.U can get handle through object.GetSafeHWND(). Or Simply u can call object.SendMessage(..) or object.PostMessage() --Cool_Dev--

          T 2 Replies Last reply
          0
          • T timbk

            Hello, in my aplication there are two dialogs CCalibracionDlg and DlgMap1 both derived from Cdialog, when I press a button in DlgMap1 i have to send a message to CCalibracionDlg, how can i do this? I've been trying to do this with PostMessage(hWnd, WM_MYCUSTOMMESSAGE,(WPARAM) wParam,(LPARAM) lParam ); or SendMessage , but in DlgMap1 how can i get the hWnd to CCalibracionDlg? Thanks in advance.

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #5

            timbk wrote:

            ...when I press a button in DlgMap1 i have to send a message to CCalibracionDlg, how can i do this?

            Are they both visible? Are they modal or modelsss?

            "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

            "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

            T 1 Reply Last reply
            0
            • D David Crow

              timbk wrote:

              ...when I press a button in DlgMap1 i have to send a message to CCalibracionDlg, how can i do this?

              Are they both visible? Are they modal or modelsss?

              "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

              "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

              T Offline
              T Offline
              timbk
              wrote on last edited by
              #6

              Ies they are both visible, the one from class CCalibracionDlg is modal and the one from CDlgMap1 is no modal, why?

              D 1 Reply Last reply
              0
              • T timbk

                Ies they are both visible, the one from class CCalibracionDlg is modal and the one from CDlgMap1 is no modal, why?

                D Offline
                D Offline
                David Crow
                wrote on last edited by
                #7

                timbk wrote:

                ...the one from class CCalibracionDlg is modal and the one from CDlgMap1 is no modal, why?

                Because modal dialog boxes "block" other windows from processing messages. Your topmost dialog would need to be modeless if you want it to be able to communicate with the dialog below it.

                "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

                "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                T 1 Reply Last reply
                0
                • C Cool_Dev

                  CCalibracionDlg and DlgMap1 both derived from Cdialog, when I press a button in DlgMap1 i have to send a message to CCalibracionDlg, how can i do this? I've been trying to do this with PostMessage(hWnd, WM_MYCUSTOMMESSAGE,(WPARAM) wParam,(LPARAM) lParam ); or Better to have an 'object' or pointer of CCalibracionDlg in DlgMap1.U can get handle through object.GetSafeHWND(). Or Simply u can call object.SendMessage(..) or object.PostMessage() --Cool_Dev--

                  T Offline
                  T Offline
                  timbk
                  wrote on last edited by
                  #8

                  The objet from i'd like send the message is CDlgMap1 to the objet CCalibracionDlg, so you say that i have to put this code in the apropiate function in CDlgMap1 : CCalibracionDlg.PostMessage(...)?

                  C 1 Reply Last reply
                  0
                  • D David Crow

                    timbk wrote:

                    ...the one from class CCalibracionDlg is modal and the one from CDlgMap1 is no modal, why?

                    Because modal dialog boxes "block" other windows from processing messages. Your topmost dialog would need to be modeless if you want it to be able to communicate with the dialog below it.

                    "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

                    "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                    T Offline
                    T Offline
                    timbk
                    wrote on last edited by
                    #9

                    oh, I didn't know it , so it's imposible send and recive messages between a model and modeless? ok supose that i change the main dialog to modeless , how can i do te send or post a message between the two modeless? with PostMessage?

                    D T 2 Replies Last reply
                    0
                    • T timbk

                      oh, I didn't know it , so it's imposible send and recive messages between a model and modeless? ok supose that i change the main dialog to modeless , how can i do te send or post a message between the two modeless? with PostMessage?

                      D Offline
                      D Offline
                      David Crow
                      wrote on last edited by
                      #10

                      timbk wrote:

                      so it's imposible send and recive messages between a model and modeless?

                      No, it IS possible.

                      timbk wrote:

                      ok supose that i change the main dialog to modeless...

                      The main dialog should stay modal. Any subsequent dialogs that you want to communicate with it should be modeless.

                      timbk wrote:

                      ...with PostMessage?

                      That's a different topic altogether, and at this point does not matter to you.

                      "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

                      "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                      1 Reply Last reply
                      0
                      • T timbk

                        The objet from i'd like send the message is CDlgMap1 to the objet CCalibracionDlg, so you say that i have to put this code in the apropiate function in CDlgMap1 : CCalibracionDlg.PostMessage(...)?

                        C Offline
                        C Offline
                        Cool_Dev
                        wrote on last edited by
                        #11

                        yeaa.. exactly. As you want to send message to a window from another window in same application, u can simply use a Callback or a direct function call. But if the situation needs, such as you need to call the function many times, its better to use PostMessage or sendMessage. --Cool_Dev--

                        1 Reply Last reply
                        0
                        • T timbk

                          oh, I didn't know it , so it's imposible send and recive messages between a model and modeless? ok supose that i change the main dialog to modeless , how can i do te send or post a message between the two modeless? with PostMessage?

                          T Offline
                          T Offline
                          timbk
                          wrote on last edited by
                          #12

                          Thanks. But , wich is the correct syntax? i wrote the following code in CDlgMapa1 <code>CCalibracionDlg.PostMessage( ? , WM_MYCUSTOMMESSAGE,(WPARAM) wParam,(LPARAM) lParam);</code> Two questions: 1-What have i put in'?' ? , the handler to CCalibracionDlg (is the object that recives the message) ? in this case , how can obtain it? if you could put some code like an example , would be nice. 2- at that line of code the compiler says : error C2143: syntax error : missing ';' before '.' , sounds like the compiler doesn't recognizes that line. thanks again.

                          1 Reply Last reply
                          0
                          • C Cool_Dev

                            CCalibracionDlg and DlgMap1 both derived from Cdialog, when I press a button in DlgMap1 i have to send a message to CCalibracionDlg, how can i do this? I've been trying to do this with PostMessage(hWnd, WM_MYCUSTOMMESSAGE,(WPARAM) wParam,(LPARAM) lParam ); or Better to have an 'object' or pointer of CCalibracionDlg in DlgMap1.U can get handle through object.GetSafeHWND(). Or Simply u can call object.SendMessage(..) or object.PostMessage() --Cool_Dev--

                            T Offline
                            T Offline
                            timbk
                            wrote on last edited by
                            #13

                            Well , thanks to all, finaly i get the solution with: GetParent()->PostMessage(WM_MyMessage,NULL,NULL);

                            1 Reply Last reply
                            0
                            • T timbk

                              Hello, in my aplication there are two dialogs CCalibracionDlg and DlgMap1 both derived from Cdialog, when I press a button in DlgMap1 i have to send a message to CCalibracionDlg, how can i do this? I've been trying to do this with PostMessage(hWnd, WM_MYCUSTOMMESSAGE,(WPARAM) wParam,(LPARAM) lParam ); or SendMessage , but in DlgMap1 how can i get the hWnd to CCalibracionDlg? Thanks in advance.

                              T Offline
                              T Offline
                              timbk
                              wrote on last edited by
                              #14

                              Well , thanks to all, finaly i get the solution with: <code>GetParent()->PostMessage(WM_MyMessage,NULL,NULL);</code>

                              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