CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2006
    Posts
    2

    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

  2. #2
    Join Date
    Sep 2004
    Location
    A Planet Called Earth... :-)
    Posts
    835

    Re: Borland + MFC, newb questions

    Try these books for a start....

    1. Charles Petzold - Programming Windows
    2. Jeff Prosise - Windows With MFC
    Last edited by Vedam Shashank; October 7th, 2006 at 05:53 AM.
    C++ program ran... C++ program crashed... C++ programmer quit !!

    Regards

    Shaq

  3. #3
    Join Date
    Feb 2005
    Location
    Normandy in France
    Posts
    4,590

    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.
    Last edited by SuperKoko; October 7th, 2006 at 06:44 AM.
    "inherit to be reused by code that uses the base class, not to reuse base class code", Sutter and Alexandrescu, C++ Coding Standards.
    Club of lovers of the C++ typecasts cute syntax: Only recorded member.

    Out of memory happens! Handle it properly!
    Say no to g_new()!

  4. #4
    Join Date
    Oct 2006
    Posts
    2

    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
    Last edited by _Arthur_; October 7th, 2006 at 05:27 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured