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 message to another program?

How to send message to another program?

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
20 Posts 2 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 Williams

    Hi, BM_SETCHECK works only to checkbox buttons!! Talk more about your last question!

    R Offline
    R Offline
    RichardWdy
    wrote on last edited by
    #7

    Thank you. I want to run another dialog program. It has several edit controls. I want to fill the edit controls automatically, which requests send message to the edit control. I tried several ways, but I couldn't get the handle of the edit control. The following is my code. HWND h = ::GetDlgItem(hDlg, ID_EDIT_START); // hDlg is the handle of the dialog. h return NULL. Could you tell me what's wrong? How can I perform that? Richard Woo No pains, no gains.

    W 1 Reply Last reply
    0
    • R RichardWdy

      Thank you. I want to run another dialog program. It has several edit controls. I want to fill the edit controls automatically, which requests send message to the edit control. I tried several ways, but I couldn't get the handle of the edit control. The following is my code. HWND h = ::GetDlgItem(hDlg, ID_EDIT_START); // hDlg is the handle of the dialog. h return NULL. Could you tell me what's wrong? How can I perform that? Richard Woo No pains, no gains.

      W Offline
      W Offline
      Williams
      wrote on last edited by
      #8

      Hello, How you get the handle to dialog? did you use the GetWindow methode described in the firts posts? To get the handle to another app(eg your another dialog app) you have to search for window´s caption and compare with your target window´s caption. Once you have the window´s handle you can call GetDlgItem to retrieve a handle to dialog items. I can send you two tests apps that explain it better.

      R 1 Reply Last reply
      0
      • W Williams

        Hello, How you get the handle to dialog? did you use the GetWindow methode described in the firts posts? To get the handle to another app(eg your another dialog app) you have to search for window´s caption and compare with your target window´s caption. Once you have the window´s handle you can call GetDlgItem to retrieve a handle to dialog items. I can send you two tests apps that explain it better.

        R Offline
        R Offline
        RichardWdy
        wrote on last edited by
        #9

        I can get the handle of the dialog and the ID of the edit control. But the edit control only has ID, not caption. I do use GetWindow() to enumerate the desktop windows. It's a good way that can replace FindWindow function. My problem is I don't know how to use ID of the control to get the handle. I tried several functions, as GetDlgItem, GetDlgCtlID,... Could you give me further information? Thanks a lot. Richard Woo No pains, no gains.

        W 1 Reply Last reply
        0
        • R RichardWdy

          I can get the handle of the dialog and the ID of the edit control. But the edit control only has ID, not caption. I do use GetWindow() to enumerate the desktop windows. It's a good way that can replace FindWindow function. My problem is I don't know how to use ID of the control to get the handle. I tried several functions, as GetDlgItem, GetDlgCtlID,... Could you give me further information? Thanks a lot. Richard Woo No pains, no gains.

          W Offline
          W Offline
          Williams
          wrote on last edited by
          #10

          Send me your two tests dialog apps.

          R 1 Reply Last reply
          0
          • W Williams

            Send me your two tests dialog apps.

            R Offline
            R Offline
            RichardWdy
            wrote on last edited by
            #11

            I send you 2 apps. Plx check. Thanks a lot. No pains, no gains.

            W 1 Reply Last reply
            0
            • R RichardWdy

              I send you 2 apps. Plx check. Thanks a lot. No pains, no gains.

              W Offline
              W Offline
              Williams
              wrote on last edited by
              #12

              you say its ok? I dont understand what do you want. whats is wrong so!?

              R 1 Reply Last reply
              0
              • W Williams

                you say its ok? I dont understand what do you want. whats is wrong so!?

                R Offline
                R Offline
                RichardWdy
                wrote on last edited by
                #13

                I don't know why it works! Just before I sent you the 2 apps, it showed "Not Found". HWND g_FindSpecialControl(LPCSTR lpWndCap, int nIDDlgItem) { HWND hWnd; int nID; hWnd = FindWindow(NULL, lpWndCap); if (hWnd == NULL) return NULL; hWnd = GetWindow(hWnd, GW_CHILD); while (hWnd != NULL) { hWnd = GetWindow(hWnd, GW_HWNDNEXT); nID = GetDlgCtrlID(hWnd); if (nID == nIDDlgItem) return hWnd; } return NULL; } It's strange! No pains, no gains.

                W 1 Reply Last reply
                0
                • R RichardWdy

                  I don't know why it works! Just before I sent you the 2 apps, it showed "Not Found". HWND g_FindSpecialControl(LPCSTR lpWndCap, int nIDDlgItem) { HWND hWnd; int nID; hWnd = FindWindow(NULL, lpWndCap); if (hWnd == NULL) return NULL; hWnd = GetWindow(hWnd, GW_CHILD); while (hWnd != NULL) { hWnd = GetWindow(hWnd, GW_HWNDNEXT); nID = GetDlgCtrlID(hWnd); if (nID == nIDDlgItem) return hWnd; } return NULL; } It's strange! No pains, no gains.

                  W Offline
                  W Offline
                  Williams
                  wrote on last edited by
                  #14

                  Its really very strange, I didn´t no changes but the path to test dialog.Now I think that there is nothing more to do!:cool:

                  R 1 Reply Last reply
                  0
                  • W Williams

                    Its really very strange, I didn´t no changes but the path to test dialog.Now I think that there is nothing more to do!:cool:

                    R Offline
                    R Offline
                    RichardWdy
                    wrote on last edited by
                    #15

                    Sorry about my troubling you. I have to send my whole project to you. Plx take some time to help me. Thanks. Richard Woo No pains, no gains.

                    W 1 Reply Last reply
                    0
                    • R RichardWdy

                      Sorry about my troubling you. I have to send my whole project to you. Plx take some time to help me. Thanks. Richard Woo No pains, no gains.

                      W Offline
                      W Offline
                      Williams
                      wrote on last edited by
                      #16

                      Ok. I will try.:)

                      R 1 Reply Last reply
                      0
                      • W Williams

                        Ok. I will try.:)

                        R Offline
                        R Offline
                        RichardWdy
                        wrote on last edited by
                        #17

                        Have you received my email with the 2 programs? No pains, no gains.

                        W 1 Reply Last reply
                        0
                        • R RichardWdy

                          Have you received my email with the 2 programs? No pains, no gains.

                          W Offline
                          W Offline
                          Williams
                          wrote on last edited by
                          #18

                          No. try again.

                          R 1 Reply Last reply
                          0
                          • W Williams

                            No. try again.

                            R Offline
                            R Offline
                            RichardWdy
                            wrote on last edited by
                            #19

                            Hi, I tried another way and it did work! I used EnumChildWindows function to enumerate all child windows of the dialog and I could get the handle of the edit control through a callback function. Thanks for help. Richard Woo No pains, no gains.

                            W 1 Reply Last reply
                            0
                            • R RichardWdy

                              Hi, I tried another way and it did work! I used EnumChildWindows function to enumerate all child windows of the dialog and I could get the handle of the edit control through a callback function. Thanks for help. Richard Woo No pains, no gains.

                              W Offline
                              W Offline
                              Williams
                              wrote on last edited by
                              #20

                              Congratulations! Glad to know you! :-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