From: Christopher Writely on
Hello all,

I'm trying to find a way to determine if a specific point on the
screen is a scrollbar; or at least if the control at that point
*could* have a scrollbar, in which case I can figure that out with
GetWindowLong(hwnd, GW_STYLE) and use a rough estimate if they're in
the right area.

The thing is, ChildWindowFromPoint() returns zero. I read on MSDN that
ChildWindowFromPoint() may not be included in the Windows CE build, so
I guess that's to be expected.

I found a post that says it's possible to enumerate the child windows
of a window using GetWindow(hwnd, GW_CHILD), but that doesn't seem to
be working either.

Am I looking for the wrong thing? Would a listview or edit control be
considered a "child window" of a parent window? Is it even it possible
to get a handle to the listview/edit control at a point using some
function(s) available on Windows Mobile?

Here's the code that I've been working with:


//
// Testing. Based on code at:
// http://blogs.msdn.com/raffael/archive/2009/01/08/disable-webbrowser-s-context-menu-in-netcf-applications.aspx
//

HWND hwndUnderlyingChildWindow;
HWND hwndCopyOfCurrentChildWindow;
TCHAR tszWindowClassName[64];

do
{
if (NULL == hwndUnderlyingChildWindow)
{
//
// Get the first child
//

hwndUnderlyingChildWindow
= ::GetWindow(hwndUnderlyingWindow, GW_CHILD);
}
else
{
hwndCopyOfCurrentChildWindow =
hwndUnderlyingChildWindow;

hwndUnderlyingChildWindow
= ::GetWindow(hwndUnderlyingChildWindow, GW_CHILD);

if (NULL == hwndUnderlyingChildWindow)
{
//
// If it's not a parent window, does it have
any "brothers?"
//

hwndUnderlyingChildWindow
= ::GetWindow(hwndCopyOfCurrentChildWindow, GW_HWNDNEXT);
}
}

//
// If we found a window (child or "brother"), let's
see if it's the one
// we're looking for.
//

::GetClassName(hwndUnderlyingChildWindow,
tszWindowClassName, 64);

} while (NULL != hwndUnderlyingChildWindow);


However, running this code, I only get a handle to a SysHeader32, as
if that's the only child window there in the parent window. There's
actually a bunch of other controls in that window... I'm not
interested in them, but they don't show up in the scan which seems
peculiar to me.

Researching SysHeader32 shows that it's a part of the listview, but I
don't know how it relates to it. Getting the dimensions of that window
makes it seem as if it's invisible, since the top and bottom are the
same (e.g. 100) and the left and right values are the same (e.g. 7).

Any thoughts on how to get the handle to a control at a certain
position on the screen? Any information or advice would be very much
appreciated.

Another thought: really, the only controls I'm intersted in are ones
that could contain scrollbars. The fact that the scan doesn't show
labels is fine. So, if the solution won't work for all controls, then
it's fine as long as it works for things like scrollable listviews and
edit controls.

Thank you very much,
Chris