URGENT: Window text location probs

This is extremely important and I cannot figure out how to do it.

I located a child window of class "Edit" by using the following code:

HWND hWnd = FindWindowEx(parentWnd, NULL, "Edit", NULL);

CWnd *editWnd = FromHandle(hWnd);

Now I have a CWnd object containing a pointer to that Edit window.

Now I need to get the text from that Edit window - not the caption (which always remains " " regardless of what it says - there is no title bar). Somehow I have to read that text into a CString without having a pointer to a CEdit (unless I can get one somehow?) This is very very important. Please help as much as you can.

Thank you SO much in advance.
-Dan
LVL 3
SuperMarioAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

vachoohoCommented:
You can get the content of Edit window using GetWindowText();

similarly SetWindowText() will set the edit content.

0
akalmaniCommented:
Hope this helps u out ?
The above answer is correct but some changes if necessary
try this out...
HWND hWnd = FindWindowEx(parentWnd, NULL, "Edit", NULL);
CEdit *editWnd = (CEdit *)FromHandle(hWnd);
CString str;
editWnd->GetWindowText(str);
 Now the str will have the contents of the text
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
vachoohoCommented:
You can GetWindowText from Cwnd too.
You do not need to cast the result to (CEdit *)
0
Starting with Angular 5

Learn the essential features and functions of the popular JavaScript framework for building mobile, desktop and web applications.

vachoohoCommented:
If you know the ID of your child control you can do easy.

CWnd * pWnd = GetDlgItem(ID_YOUR_ITEM);
if(pWnd != NULL)
{
  CString strText;
  pWnd->GetWindowText(strText);
  // strText contain the content of edit ctrl
}
0
SuperMarioAuthor Commented:
Actually, GetWindowText() doesn't work with THIS CWnd because the caption always remains " ". That's why I'm thinking if I cast it to CEdit then I'll get the text containted within the edit box.

I tried your answer, akalmani... unfortunately it still grabbed me the window caption ( " " ) instead of the contents of the box.

This is exactly my problem.

Confusing, huh?

-D
0
SuperMarioAuthor Commented:
Now I have tried using the resource ID too... but the problem is that the CAPTION differs from the actual TEXT.

See?

-D
0
vachoohoCommented:
Which edit ctrl you use?
Is it straight CEdit or derivative?

Post some code if possible
0
SuperMarioAuthor Commented:
CWnd *wnd = (CEdit *)FromHandle(hWnd);
0
SuperMarioAuthor Commented:
(CEdit, not CWnd in above example)
0
SuperMarioAuthor Commented:
Akalmani -
That last line of code was the key.

If I reward you this 50, will you refund me 20?

Thanks!
-D
0
SuperMarioAuthor Commented:
sorry that took so long ;)

-D
0
akalmaniCommented:
Thanks !!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.