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

    Reading The Text from a Static Control using API

    Ive searched all the other posts of this nature and none of them seem to answer my question.

    I need to get the text out of a static text object, the problem is that it does not behave like a standard static text object. If i use an API spy it tells me its classname is Static, there are no other children of the MDI window that could be containing the text. But it wont give up the text inside no matter what i throw at it
    GetWindowText()
    WM_GETTEXT

    Nothing seems to work.

    The program I am trying to read text from is mIRC, the standard chat windows have

    a Static object where the chat is
    an Edit object where you type in cmd's / chat
    a ListBox item where other clients are listed

    there are no other children of that window.

    Anyone have any ideas? another way around?

  2. #2
    Join Date
    May 2005
    Posts
    4,954

    Re: Reading The Text from a Static Control using API

    you can try with Active Accessibility maybe it will work.
    download the AccExplorer32.exe and check if you can see the text from there.
    if you see the text with it, look at this thread to see how to use ::AccessibleObjectFromWindow(..).

    Cheers
    If a post helped you dont forget to "Rate This Post"

    My Article: Capturing Windows Regardless of Their Z-Order

    Cheers

  3. #3
    Join Date
    Jan 2006
    Posts
    2

    Re: Reading The Text from a Static Control using API

    Thats quite a handy little app, but still no response from that static object, no text in there at all.

    Looks like ill have to do it the cheap and nasty way, get the logs off the HD

  4. #4
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150

    Re: Reading The Text from a Static Control using API

    The application is probably storing the text in some internal buffer and not in the static control itself. The static control is probably ownerdrawn and the application draws the text on demand using its internal buffer. So i doubt that you can retrieve the text from the static control.
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

  5. #5
    Join Date
    Jun 2004
    Posts
    1,352

    Re: Reading The Text from a Static Control using API

    Quote Originally Posted by ShCiPwA
    Ive searched all the other posts of this nature and none of them seem to answer my question.

    I need to get the text out of a static text object, the problem is that it does not behave like a standard static text object. If i use an API spy it tells me its classname is Static, there are no other children of the MDI window that could be containing the text. But it wont give up the text inside no matter what i throw at it
    GetWindowText()
    WM_GETTEXT

    Nothing seems to work.

    The program I am trying to read text from is mIRC, the standard chat windows have

    a Static object where the chat is
    an Edit object where you type in cmd's / chat
    a ListBox item where other clients are listed

    there are no other children of that window.

    Anyone have any ideas? another way around?

    Can you post you project or a reference to it.


    Assigning it a CStatic control variable in classwizard and using:

    nt GetWindowText( LPTSTR lpszStringBuf, int nMaxCount ) const;

    void GetWindowText( CString& rString ) const;

    has always worked for me. If you want to use the Api you have to get a pointer to Static ID.

    ... maybe posting your application or a reference to it would help clarify the issue.
    Rate this post if it helped you.

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