EnumChildWindows and EM_GETSELTEXT

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • kinryuu@gmail.com

    EnumChildWindows and EM_GETSELTEXT

    I'm trying to write a program that captures selected text from the
    active window. I have everything setup as far as getting the foreground
    window (with GetForegroundWi ndow()) and I'm using EnumChildWindow s to
    iterate through the child windows until I get something useful.

    The problem is that every single child window of the foreground window
    returns a single space as the selected text, even if I know that a
    control on that window has highlighted text.

    Is EM_GETSELTEXT not the right message? I've also tried WM_GETTEXT and
    that simply returns an empty string for each child window.

    Here's the pertinent code:

    public static bool Enum(int hwndChild, int lParam)
    {
    StringBuilder builder = new StringBuilder() ;
    SendMessage(hwn dChild, Win32.User.EM_G ETSELTEXT, 50, builder);
    if (builder.Length != 0)
    {
    buffer = builder.ToStrin g();
    return false;
    }
    else
    {
    return true;
    }
    }

Working...