Marc Fauser said:
I want to access a textbox inside the Internet Explorer
from my program. Like the search textbox from Google.
I agree with Wagner, I would use a tool like Spy ++ to determine the Class
Name & Handle of the child you are tying to find. Next, I would call
GetWindow(GW_HWNDFIRST) to get the first child, set up an infinite loop of
GetWindow(GW_HWNDNEXT), and then add a break-point or step into the code and
manually advance through each loop. Once you arrive at the Handle of the
window you are looking for, you can set a specific number of iterations to
find the child (ie. if it takes 5 loops to find the handle that you know is
good, then hard-code 5 into your infinite loop, making it not infinite
anymore).
However, this approach is *extremely* brittle, something even so minor as
changing the order of the toolbars will break your code. I would only use
this method in a closed environment, as a tool for my own personal use.
Another approach would be to find the /class name/ of the child you are
looking for- use FindWindow to find the Browser window, then make a loop
that uses GetWindow to iterate through every child, then use GetWindowClass
to get the actuall class name of the child.
This method is almost as bad as hard coding an index (as in the first
method), because if a new toolbar is added before the one that hosts your
text box, and the new toolbar also contains a text box with the same class
name (very possible), you will mistakenly get the wrong text box.
~
Jeremy