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. Pls Help how to read from windows(edit box)

Pls Help how to read from windows(edit box)

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorial
11 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 tejaswi teja

    hello friend, i want a help regarding retrieving data from a Window's Edit boxes. The situation is like this:There is a window( seems to be a dialog box produced by some Application). The window is containing many sub windows(controls inside it). my requirement is to read the data present in those controls/sub windows/edit boxes. The extent to which i have come is, able to get a handle to that edit box( of class CWND). with that handle it is also working if i try to enable/disable all windows/controls present in a maibn parent window . if i am using the function ::GetWindowText(), i am not getting the text in that edit box( where as for all button window i am getting their captions like &OK,&Edit e.t.c). please tell me how to access the text present in the editboxes. and my problem is like this said above in last paragraph.

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

    please post the code where you are using GetWindowText() because it should work.

    CEdit* pEdit = /*...*/;
    CString strText = "";

    pEdit->GetWindowText(strText);

    // strText contains here the text of the EditBox


    TOXCCT >>> GEII power
    [toxcct][VisualCalc]

    T K 2 Replies Last reply
    0
    • T toxcct

      please post the code where you are using GetWindowText() because it should work.

      CEdit* pEdit = /*...*/;
      CString strText = "";

      pEdit->GetWindowText(strText);

      // strText contains here the text of the EditBox


      TOXCCT >>> GEII power
      [toxcct][VisualCalc]

      T Offline
      T Offline
      tejaswi teja
      wrote on last edited by
      #3

      please validate the code here if sth is wrong. Only the case for edit box controls it is not working , i am tinking if any locking they have done there. have tried many other options also all of them commented in the below code. the main window therei is 'System Event" from which i anm trying to read the contents of all its sub windows( edit boxes e.t.c) void WManip(CWnd *WndActiveChild ,CWnd *WndParent) { CWnd * WndActiveChildRead; CEdit *WndEdit; LPTSTR EditText; COleDataObject ClipObj; tagSTGMEDIUM *strVar; LPCTSTR lpctFormat; int ControlID,WinCount = 0; CString rString,temprString,text; WndActiveChild->SetForegroundWindow(); WndActiveChild->SetFocus(); // WndActiveChild->OpenClipboard(); // if (( (WndActiveChild->GetClipboardOwner()) ->GetWindowText(rString) ) != 0 ) // (WndActiveChild->GetClipboardOwner()) ->GetWindowText(rString); // if (rString != "") // AfxMessageBox("some thingn hapend "+rString); ControlID = WndActiveChild->GetDlgCtrlID(); WndActiveChild->GetWindowText(rString); AfxMessageBox(rString); //WndEdit = WndActiveChild ; // ClipObj.AttachClipboard(); // strVar = new tagSTGMEDIUM; // ClipObj.GetData(CF_TEXT, strVar,NULL); // WndActiveChild ->GetLine(0,EditText); // WndParent ->GetDlgItemText(ControlID,rString); // temprString.Format("%s%d%s", (LPCTSTR) rString,ControlID, (LPCTSTR)EditText ); //(LPCTSTR) rString, AfxMessageBox(temprString); // the following code is just for testing i have put. if (rString.Compare("&Edit") == 0) { WndActiveChild->PostMessage(WM_LBUTTONDOWN,0,0); Sleep(50); WndActiveChild->PostMessage(WM_LBUTTONUP,0,0); // WndParent->CheckDlgButton(i,1); } // WndActiveChild->EnableWindow(false); WinCount ++; } void CConfigTool_AutomateDlg::OnOK() { int i,WinCount = 0; CString rString,temprString,text; CEdit EControl; CWnd * pActWindow,*pActChildWindow,*pActChild1Window, *pActChild2Window ; // pActWindow = CWnd::GetActiveWindow(); pActWindow = CWnd::FindWindow(NULL ,"System Event"); pActWindow->SetForegroundWindow(); // pActWindow->ShowWindow(SW_SHOWMAXIMIZED); pActChildWindow = pActWindow->GetTopWindow(); while (pActChildWindow != NULL) { WinCount ++; pActChild1Window = pActChildWindow->GetTopWindow(); while(pActCh

      T L 2 Replies Last reply
      0
      • T tejaswi teja

        please validate the code here if sth is wrong. Only the case for edit box controls it is not working , i am tinking if any locking they have done there. have tried many other options also all of them commented in the below code. the main window therei is 'System Event" from which i anm trying to read the contents of all its sub windows( edit boxes e.t.c) void WManip(CWnd *WndActiveChild ,CWnd *WndParent) { CWnd * WndActiveChildRead; CEdit *WndEdit; LPTSTR EditText; COleDataObject ClipObj; tagSTGMEDIUM *strVar; LPCTSTR lpctFormat; int ControlID,WinCount = 0; CString rString,temprString,text; WndActiveChild->SetForegroundWindow(); WndActiveChild->SetFocus(); // WndActiveChild->OpenClipboard(); // if (( (WndActiveChild->GetClipboardOwner()) ->GetWindowText(rString) ) != 0 ) // (WndActiveChild->GetClipboardOwner()) ->GetWindowText(rString); // if (rString != "") // AfxMessageBox("some thingn hapend "+rString); ControlID = WndActiveChild->GetDlgCtrlID(); WndActiveChild->GetWindowText(rString); AfxMessageBox(rString); //WndEdit = WndActiveChild ; // ClipObj.AttachClipboard(); // strVar = new tagSTGMEDIUM; // ClipObj.GetData(CF_TEXT, strVar,NULL); // WndActiveChild ->GetLine(0,EditText); // WndParent ->GetDlgItemText(ControlID,rString); // temprString.Format("%s%d%s", (LPCTSTR) rString,ControlID, (LPCTSTR)EditText ); //(LPCTSTR) rString, AfxMessageBox(temprString); // the following code is just for testing i have put. if (rString.Compare("&Edit") == 0) { WndActiveChild->PostMessage(WM_LBUTTONDOWN,0,0); Sleep(50); WndActiveChild->PostMessage(WM_LBUTTONUP,0,0); // WndParent->CheckDlgButton(i,1); } // WndActiveChild->EnableWindow(false); WinCount ++; } void CConfigTool_AutomateDlg::OnOK() { int i,WinCount = 0; CString rString,temprString,text; CEdit EControl; CWnd * pActWindow,*pActChildWindow,*pActChild1Window, *pActChild2Window ; // pActWindow = CWnd::GetActiveWindow(); pActWindow = CWnd::FindWindow(NULL ,"System Event"); pActWindow->SetForegroundWindow(); // pActWindow->ShowWindow(SW_SHOWMAXIMIZED); pActChildWindow = pActWindow->GetTopWindow(); while (pActChildWindow != NULL) { WinCount ++; pActChild1Window = pActChildWindow->GetTopWindow(); while(pActCh

        T Offline
        T Offline
        toxcct
        wrote on last edited by
        #4

        did you really think that i was going to read that entiere code ? first of all, if you one anyone reading and validating it, put it into <pre></pre> tags to be more readable. moreover, i just asked for the code where you were using the GetWindowText(), not the whole one... so, please use the [modify] link at the bottom of your post...


        TOXCCT >>> GEII power
        [toxcct][VisualCalc]

        T 1 Reply Last reply
        0
        • T tejaswi teja

          please validate the code here if sth is wrong. Only the case for edit box controls it is not working , i am tinking if any locking they have done there. have tried many other options also all of them commented in the below code. the main window therei is 'System Event" from which i anm trying to read the contents of all its sub windows( edit boxes e.t.c) void WManip(CWnd *WndActiveChild ,CWnd *WndParent) { CWnd * WndActiveChildRead; CEdit *WndEdit; LPTSTR EditText; COleDataObject ClipObj; tagSTGMEDIUM *strVar; LPCTSTR lpctFormat; int ControlID,WinCount = 0; CString rString,temprString,text; WndActiveChild->SetForegroundWindow(); WndActiveChild->SetFocus(); // WndActiveChild->OpenClipboard(); // if (( (WndActiveChild->GetClipboardOwner()) ->GetWindowText(rString) ) != 0 ) // (WndActiveChild->GetClipboardOwner()) ->GetWindowText(rString); // if (rString != "") // AfxMessageBox("some thingn hapend "+rString); ControlID = WndActiveChild->GetDlgCtrlID(); WndActiveChild->GetWindowText(rString); AfxMessageBox(rString); //WndEdit = WndActiveChild ; // ClipObj.AttachClipboard(); // strVar = new tagSTGMEDIUM; // ClipObj.GetData(CF_TEXT, strVar,NULL); // WndActiveChild ->GetLine(0,EditText); // WndParent ->GetDlgItemText(ControlID,rString); // temprString.Format("%s%d%s", (LPCTSTR) rString,ControlID, (LPCTSTR)EditText ); //(LPCTSTR) rString, AfxMessageBox(temprString); // the following code is just for testing i have put. if (rString.Compare("&Edit") == 0) { WndActiveChild->PostMessage(WM_LBUTTONDOWN,0,0); Sleep(50); WndActiveChild->PostMessage(WM_LBUTTONUP,0,0); // WndParent->CheckDlgButton(i,1); } // WndActiveChild->EnableWindow(false); WinCount ++; } void CConfigTool_AutomateDlg::OnOK() { int i,WinCount = 0; CString rString,temprString,text; CEdit EControl; CWnd * pActWindow,*pActChildWindow,*pActChild1Window, *pActChild2Window ; // pActWindow = CWnd::GetActiveWindow(); pActWindow = CWnd::FindWindow(NULL ,"System Event"); pActWindow->SetForegroundWindow(); // pActWindow->ShowWindow(SW_SHOWMAXIMIZED); pActChildWindow = pActWindow->GetTopWindow(); while (pActChildWindow != NULL) { WinCount ++; pActChild1Window = pActChildWindow->GetTopWindow(); while(pActCh

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #5

          please look into the below code equivalent to then pvevious one after removing all the redundant lines. please let meknow about: given any window how to obtain information of all the data present in the window. please suggest me a method or any example code to do the following requirement is as below: input: window Output: details of various items present in the window and their content as far as possible. Maincallingfunction() { WND * wndparent,*wndchild1,*wndchild2; wndparent = Findwindow("WindowName"); cwndchild1= wndparent->GetTopWindow(); while(wncdhild1!= NULL) { GetWindowContent(wndchild,wndparent); wndchild2= wndchild1->GetTopWindow(); while(wncdhild2!= NULL) { GetWindowContent(wndchild,wndparent); wndchild2= wndchild2->GetNextWindow() } wndchild1= wndchild1->GetNextWindow(); } } void GetWindowContent(CWnd *WndActiveChild ,CWnd *WndParent) { CWnd * WndActiveChildRead; CEdit *WndEdit; LPTSTR EditText; COleDataObject ClipObj; tagSTGMEDIUM *strVar; LPCTSTR lpctFormat; int ControlID,WinCount = 0; CString rString,temprString,text; // code starting from here WndActiveChild->SetForegroundWindow(); WndActiveChild->SetFocus(); ControlID = WndActiveChild->GetDlgCtrlID(); WndActiveChild->GetWindowText(rString); AfxMessageBox(rString); } -- modified at 7:13 Wednesday 14th September, 2005

          T 1 Reply Last reply
          0
          • L Lost User

            please look into the below code equivalent to then pvevious one after removing all the redundant lines. please let meknow about: given any window how to obtain information of all the data present in the window. please suggest me a method or any example code to do the following requirement is as below: input: window Output: details of various items present in the window and their content as far as possible. Maincallingfunction() { WND * wndparent,*wndchild1,*wndchild2; wndparent = Findwindow("WindowName"); cwndchild1= wndparent->GetTopWindow(); while(wncdhild1!= NULL) { GetWindowContent(wndchild,wndparent); wndchild2= wndchild1->GetTopWindow(); while(wncdhild2!= NULL) { GetWindowContent(wndchild,wndparent); wndchild2= wndchild2->GetNextWindow() } wndchild1= wndchild1->GetNextWindow(); } } void GetWindowContent(CWnd *WndActiveChild ,CWnd *WndParent) { CWnd * WndActiveChildRead; CEdit *WndEdit; LPTSTR EditText; COleDataObject ClipObj; tagSTGMEDIUM *strVar; LPCTSTR lpctFormat; int ControlID,WinCount = 0; CString rString,temprString,text; // code starting from here WndActiveChild->SetForegroundWindow(); WndActiveChild->SetFocus(); ControlID = WndActiveChild->GetDlgCtrlID(); WndActiveChild->GetWindowText(rString); AfxMessageBox(rString); } -- modified at 7:13 Wednesday 14th September, 2005

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

            teja_tejaswi wrote: WND * wndparent,*wndchild1,*wndchild2; wndparent = Findwindow("WindowName"); cwndchild1= wndparent->GetTopWindow(); If you trying to retrieve content from Window/Edit box thats belong to some other process... then GetWindowText(..) api will not work.. You have to use WM_GETTEXT and WM_GETTEXTLENGTH message to reterive the text of that 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 VC Forum Q&A :- I/ IV

            1 Reply Last reply
            0
            • T toxcct

              did you really think that i was going to read that entiere code ? first of all, if you one anyone reading and validating it, put it into <pre></pre> tags to be more readable. moreover, i just asked for the code where you were using the GetWindowText(), not the whole one... so, please use the [modify] link at the bottom of your post...


              TOXCCT >>> GEII power
              [toxcct][VisualCalc]

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

              toxcct wrote: did you really think that i was going to read that entiere code ? Cool Down brother....

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

              cheers, Alok Gupta VC Forum Q&A :- I/ IV

              T 1 Reply Last reply
              0
              • T ThatsAlok

                toxcct wrote: did you really think that i was going to read that entiere code ? Cool Down brother....

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

                cheers, Alok Gupta VC Forum Q&A :- I/ IV

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

                hum, yes, i know i must calm down, but it's really bothering to see how many people post so useless questions... we are obliged to ask one more question and overload the servers to try to understand what the guy wanted us to solve... OT: i'm really really really sorry for series II && III ; i'm ending my classes in one week, and i have to prepared hard my next job (and i'm not even sure where i will work at this date !)


                TOXCCT >>> GEII power
                [toxcct][VisualCalc]

                T 1 Reply Last reply
                0
                • T toxcct

                  please post the code where you are using GetWindowText() because it should work.

                  CEdit* pEdit = /*...*/;
                  CString strText = "";

                  pEdit->GetWindowText(strText);

                  // strText contains here the text of the EditBox


                  TOXCCT >>> GEII power
                  [toxcct][VisualCalc]

                  K Offline
                  K Offline
                  ky_rerun
                  wrote on last edited by
                  #9

                  You cant read the edit box because it not in you process however do not fret lResult = SendMessage( // returns LRESULT in lResult (HWND) hWndControl, // handle to destination control (UINT) WM_GETTEXT, // message ID (WPARAM) wParam, // = (WPARAM) () wParam; (LPARAM) lParam // = (LPARAM) () lParam; ); Look up further documentation on the web but this will take care of your problem.:)

                  T 1 Reply Last reply
                  0
                  • K ky_rerun

                    You cant read the edit box because it not in you process however do not fret lResult = SendMessage( // returns LRESULT in lResult (HWND) hWndControl, // handle to destination control (UINT) WM_GETTEXT, // message ID (WPARAM) wParam, // = (WPARAM) () wParam; (LPARAM) lParam // = (LPARAM) () lParam; ); Look up further documentation on the web but this will take care of your problem.:)

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

                    ky_rerun wrote: WM_GETTEXT, Sorry if I sound Rude.., I believe same thing is mentioned by me around 15 hr prior to your post.... Please check other comments before posting..

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

                    cheers, Alok Gupta VC Forum Q&A :- I/ IV

                    1 Reply Last reply
                    0
                    • T toxcct

                      hum, yes, i know i must calm down, but it's really bothering to see how many people post so useless questions... we are obliged to ask one more question and overload the servers to try to understand what the guy wanted us to solve... OT: i'm really really really sorry for series II && III ; i'm ending my classes in one week, and i have to prepared hard my next job (and i'm not even sure where i will work at this date !)


                      TOXCCT >>> GEII power
                      [toxcct][VisualCalc]

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

                      toxcct wrote: : i'm really really really sorry for series II && III ; i'm ending my classes in one week, and i have to prepared hard my next job No Problem Buddy, I will Manage :)

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

                      cheers, Alok Gupta VC Forum Q&A :- I/ IV

                      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