Borland + MFC, newb questions
Hi,
First of all I want to apologize if I'm posting this in the wrong forum, and if I'm posting questions that could be found by a simple search (I did search for a long time).
This is what I want to do:
I run a programm (I don't have the source code of the programm), this programm opens windows and has textboxes in these windows. I want to read these textboxes in a c++ programm coded in Borland. After some searching I found out that this can be done using MFC with a SendMessage, WM_GETTEXT command. To find the handle of this window I use FindWindow, and here is were is starts to get blurry. I need to find the handle of the textbox to read the text. I don't know how many textboxes the window has, so I think I can't use FindWindowex and need to use Enumchildwindows.
As you can tell I'm totaly new to MFC, I have a decent understanding of c/c++. Is there a tutorial for MFC that explains really basic stuff (like what is a LPARAM type, and how to use it for instance print it's contents in a console).
Thank in advance,
regards Arthur
Re: Borland + MFC, newb questions
Try these books for a start....
1. Charles Petzold - Programming Windows
2. Jeff Prosise - Windows With MFC
Re: Borland + MFC, newb questions
You don't need MFC for that. Just plain Win32 API.
Yes, you can use FindWindow, and then EnumChildWindows.
Now, the problem is: How to identify the right text box?
There might be an easy solution. If the window is a dialog box designed to be used with CreateDialog, then, each control of this dialog box will have an identifier (well, actually, it's the menu handle of the window).
You have two things to do:
1) Find the identifier of this window (you need to do that only once).
In order to find it, you can extract resources of this executable file (Borland has such tool).
If the dialog box is not in the resources, you'll have to use another way to identify the control: e.g. Window class and position.
2) Then, select the control with GetDlgItem, the ID being hard-coded in your executable (e.g. as a static const variable).
If the control as no ID, then, you must use EnumChildWindows and test for specific properties of the text box you want to get.
I could help you further if you attach the executable and show me which text box you want to capture.
PS: The WinAPI forum section would have been more appropriate for this thread.
Re: Borland + MFC, newb questions
Thank you for your replies. I used a programm named "WinID" to find out more about the textbox and the structure of the program I'm trying to read from.
edit: and I got it to work :)