473,320 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 GetForegroundWindow()) and I'm using EnumChildWindows 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(hwndChild, Win32.User.EM_GETSELTEXT, 50, builder);
if (builder.Length != 0)
{
buffer = builder.ToString();
return false;
}
else
{
return true;
}
}

Nov 17 '05 #1
0 2697

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: P?l F | last post by:
How can I get a word from any window and copy it to my application? Someone have told me I possibly can use EM_GETSEL or the EM_GETSELTEXT "command" in the WinAPI. I want to select the word or get...
1
by: Ryan Ross | last post by:
Hello, I am having the oddest error with the EnumChildWindows function. Below are the imports, and the methods. public static extern int EnumChildWindows(IntPtr hWndParent, EnumChildProc...
1
by: Trancedified | last post by:
Hello, I read through this thread regarding FindWindowEx vs. EnumChildWindows: http://www.xtremevbtalk.com/showthread.php?t=130418 It looks like it was done in VB6, can this be done in...
3
by: John F | last post by:
I have a question about EnumChildWindows(). Currently I'm using this API function to iterate through all the controls in another application. In my call back function I call SendMessage() and...
6
by: Bart Burkhardt | last post by:
Hi, I could use some help in setting a C# callback function that an external unmanaged dll will call on a event. Using a delegate and use the external callback set function doesn't work. The...
1
by: pigeonrandle | last post by:
Hi, This could also be read as 'Does the EnumChildWindows callback block the rest of my application until the enumeration has finished?'. Basically i want to create a treeview similar to...
1
by: prithvis.mohanty | last post by:
using System; using System.Drawing; using System.ComponentModel; using System.Windows.Forms; using System.Runtime.InteropServices; using System.Text; using System.Collections; using...
2
by: =?Utf-8?B?c3lzdGVtQ29uc3VsdGFudA==?= | last post by:
Can I use EnumchildWindows from a windows service to find the IE windows and Solitaire windows belonging to the logged on user? And if so then I'll need to know what call to use to get the users...
0
by: Emilio | last post by:
Good morning to everyone, I've tested this "format" od this code to enumerate some controls in a window and it works fine. Private Delegate Function EnumChildProcDelegate _ (ByVal hWnd As...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.