Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Finding the inner controls, when having handle of window.

44 views
Skip to first unread message

Mr. X.

unread,
May 21, 2012, 1:47:21 AM5/21/12
to
Hello.
I have an handle for window.
I want to find all of the children controls of the parent window - with
their handle
(Loop through the children, i.e for dialog box, which has some buttons, and
other elements on it - I have only the handle of the dialog box, and need
the handle of all the children of it).

Thanks :)

Mr. X.

unread,
May 21, 2012, 1:53:35 AM5/21/12
to
... This should be done, of course by some Win API functions (C# is
prefered, but no matter what language).


"Mr. X." wrote in message news:jpckt9$qpl$1...@dont-email.me...

Uwe Kotyczka

unread,
May 21, 2012, 3:50:56 AM5/21/12
to
Say hWnd is the handle to your dialog box,
then you can iterate through the (direct)
children (controls) by:

for (HWND hChild = GetWindow(hWnd, GW_CHILD); hChild != NULL; hChild =
GetNextWindow(hChild, GW_HWNDNEXT))
{
// do something with hChild
}

HTH

Mr. X.

unread,
May 21, 2012, 10:36:31 AM5/21/12
to
I have tried that.
It seems there are situation thats I cannot get the handle of inner controls
at all (maybe not all the controls can be exposed with that search. maybe I
can get them through Device-Contents handle / HDC ....).
Isn't any other way (searchControl ... or some tricky way to resolve the
inner controls)?

Thanks :)

"Uwe Kotyczka" wrote in message
news:fe24fc4f-d2d7-43a2...@b1g2000vbb.googlegroups.com...

Uwe Kotyczka

unread,
May 21, 2012, 10:41:50 AM5/21/12
to
On 21 Mai, 16:36, "Mr. X." <nospam....@gmail.com> wrote:
> I have tried that.
> It seems there are situation thats I cannot get the handle of inner controls
> at all (maybe not all the controls can be exposed with that search. maybe I
> can get them through Device-Contents handle / HDC ....).
> Isn't any other way (searchControl ... or some tricky way to resolve the
> inner controls)?

You can use Spy++ to see if the child controls
are really children of your dialog "hWnd".
Maybe they are grand children.

Or you show us some code here, so that we can see
where your problems come from. Maybe a small demo
program.

HTH

Karl E. Peterson

unread,
May 21, 2012, 3:45:54 PM5/21/12
to
on 5/20/2012, Mr. X. supposed :
> ... This should be done, of course by some Win API functions

EnumChildWindows

> (C# is prefered, but no matter what language).

Kinda weird to be asking for that in a VB group, but... <shrug>

--
.NET: It's About Trust!
http://vfred.mvps.org


0 new messages