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 programatically fill data in a dialog based UI

How to programatically fill data in a dialog based UI

Scheduled Pinned Locked Moved C / C++ / MFC
designhelptutorialquestion
7 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.
  • P Offline
    P Offline
    PravinSingh
    wrote on last edited by
    #1

    I am writing a program that opens a dialog based application (for which I don't have the source code), fills data in the edit boxes there and clicks the "OK" button. I can open the application through ShellExecute function, but I am not able to fill data in the edit boxes or get the "OK" button clicked. Can anybody help?? Please...

    T 1 Reply Last reply
    0
    • P PravinSingh

      I am writing a program that opens a dialog based application (for which I don't have the source code), fills data in the edit boxes there and clicks the "OK" button. I can open the application through ShellExecute function, but I am not able to fill data in the edit boxes or get the "OK" button clicked. Can anybody help?? Please...

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

      thevoyager wrote: but I am not able to fill data in the edit boxes or get the "OK" button clicked. 1. First Find Handle to Remote Window Using FindWindow() and FindWindowEx Api's. 2. Now, Find the Edit Box and OK Button, In Which you want to fill your custom values off course using FindWindowEx or EnumChildWindow Api. 3. Using WM_SETTEXT message Fill the Edit Box of remote Window from your custom text. 4. After completing above task, Post BN_CLICKED message for OK Button to Remote Window

      "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

      cheers, Alok Gupta

      P 1 Reply Last reply
      0
      • T ThatsAlok

        thevoyager wrote: but I am not able to fill data in the edit boxes or get the "OK" button clicked. 1. First Find Handle to Remote Window Using FindWindow() and FindWindowEx Api's. 2. Now, Find the Edit Box and OK Button, In Which you want to fill your custom values off course using FindWindowEx or EnumChildWindow Api. 3. Using WM_SETTEXT message Fill the Edit Box of remote Window from your custom text. 4. After completing above task, Post BN_CLICKED message for OK Button to Remote Window

        "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

        cheers, Alok Gupta

        P Offline
        P Offline
        PravinSingh
        wrote on last edited by
        #3

        Thanks Alok, it works :) I got the Handle to Remote Window and also to the buttons on it, but... i) I'm not able to get control of the edit box (I searched for the button based on it's caption, but editboxes don't have a caption and i don't know what to give in the parameter lpszClassName). ii) Sending BN_CLICKED message for the OK Button doesn't seem to work. I'm sending you my code. Could you please figure out the problem: CWnd* pClientWnd = NULL; pClientWnd = FindWindow(NULL, "Login"); CWnd* pControl = new CWnd(); HWND hWndOk = FindWindowEx((pClientWnd->m_hWnd), NULL, NULL, "&OK"); pControl->Attach(hWndOk); pControl->EnableWindow(TRUE); pControl->PostMessage(BN_CLICKED);

        J 1 Reply Last reply
        0
        • P PravinSingh

          Thanks Alok, it works :) I got the Handle to Remote Window and also to the buttons on it, but... i) I'm not able to get control of the edit box (I searched for the button based on it's caption, but editboxes don't have a caption and i don't know what to give in the parameter lpszClassName). ii) Sending BN_CLICKED message for the OK Button doesn't seem to work. I'm sending you my code. Could you please figure out the problem: CWnd* pClientWnd = NULL; pClientWnd = FindWindow(NULL, "Login"); CWnd* pControl = new CWnd(); HWND hWndOk = FindWindowEx((pClientWnd->m_hWnd), NULL, NULL, "&OK"); pControl->Attach(hWndOk); pControl->EnableWindow(TRUE); pControl->PostMessage(BN_CLICKED);

          J Offline
          J Offline
          Jose Lamas Rios
          wrote on last edited by
          #4

          thevoyager wrote: I'm not able to get control of the edit box Try obtaining its Control ID by using Spy++ and then searching by this ID among pClientWnd's children. thevoyager wrote: pControl->PostMessage(BN_CLICKED); BN_CLICKED is not a message. It's a notification code to be used in a WM_COMMAND message. Check the documentation for both BN_CLICKED and WM_COMMAND. You should post a WM_COMMAND message to the button's parent window (not the button), indicating a BN_CLICKED code and the button's ID. In fact, for the OK button, this ID is most likely IDOK, so you wouldn't even need to search and obtain a handle to the button itself. Hope that helps, -- jlr http://jlamas.blogspot.com/[^]

          T 1 Reply Last reply
          0
          • J Jose Lamas Rios

            thevoyager wrote: I'm not able to get control of the edit box Try obtaining its Control ID by using Spy++ and then searching by this ID among pClientWnd's children. thevoyager wrote: pControl->PostMessage(BN_CLICKED); BN_CLICKED is not a message. It's a notification code to be used in a WM_COMMAND message. Check the documentation for both BN_CLICKED and WM_COMMAND. You should post a WM_COMMAND message to the button's parent window (not the button), indicating a BN_CLICKED code and the button's ID. In fact, for the OK button, this ID is most likely IDOK, so you wouldn't even need to search and obtain a handle to the button itself. Hope that helps, -- jlr http://jlamas.blogspot.com/[^]

            T Offline
            T Offline
            ThatsAlok
            wrote on last edited by
            #5

            Jose Lamas Rios wrote: You should post a WM_COMMAND message to the button's parent window (not the button), indicating a BN_CLICKED code and the button's ID. Yeap, You are Right, Thanks for Correcting me Again Mr. Rios :).

            "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

            cheers, Alok Gupta

            J 1 Reply Last reply
            0
            • T ThatsAlok

              Jose Lamas Rios wrote: You should post a WM_COMMAND message to the button's parent window (not the button), indicating a BN_CLICKED code and the button's ID. Yeap, You are Right, Thanks for Correcting me Again Mr. Rios :).

              "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

              cheers, Alok Gupta

              J Offline
              J Offline
              Jose Lamas Rios
              wrote on last edited by
              #6

              ThatsAlok wrote: Yeap, You are Right, Thanks for Correcting me Again Mr. Rios He, no problem :) But if you like my corrections, that would be "Mr. Lamas", or "Mr. Lamas Ríos" ;P Anyway, just "José" or "jlr" will do. Cheers, -- jlr http://jlamas.blogspot.com/[^]

              T 1 Reply Last reply
              0
              • J Jose Lamas Rios

                ThatsAlok wrote: Yeap, You are Right, Thanks for Correcting me Again Mr. Rios He, no problem :) But if you like my corrections, that would be "Mr. Lamas", or "Mr. Lamas Ríos" ;P Anyway, just "José" or "jlr" will do. Cheers, -- jlr http://jlamas.blogspot.com/[^]

                T Offline
                T Offline
                ThatsAlok
                wrote on last edited by
                #7

                Jose Lamas Rios wrote: But if you like my corrections, that would be "Mr. Lamas", or "Mr. Lamas Ríos" :), So i Will refer you by Jlr :)

                "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                cheers, Alok Gupta

                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