[Date Prev][Date Next][Thread Prev][Thread Next][Thread Index]

Re: [XaraXtreme-dev] ChildWindowFromPoint and other questions



Hi !

I noticed that you implemented a recursion inside the wxChildWindowFromPoint function to go deep through all childs to find the deepest one - that might not work exactly as the native Win32 fn works. As msdn says: The ChildWindowFromPoint function determines which, if any, of the child windows belonging to a parent window contains the specified point. The search is restricted to immediate child windows, grandchildren, and deeper descendant windows are not searched.

Furthermore: The return value is a handle to the child window that contains the point, even if the child window is hidden or disabled. If the point lies outside the parent window, the return value is NULL. If the point is within the parent window but not within any child window, the return value is a handle to the parent window.

I think we have to run through childs without a recursion, don't you think ? I know these are minor things but still they can alter the intended behaviour.

Alex Bligh wrote:

The documentation for wxWidgets has (inter-alia)
  wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
which is declared extern in utils.h, so you can use it in the program.
That's what you were looking at.

But GetChildWindowFromPoint does something a bit different, in that
it ONLY looks for child windows of the HWND passed (as I understand it).
So if there is a window on top of the HWND passed, which is not a
child window, it's ignored. That's a subtle difference, but relevant
when dragging, as (e.g.) on a solid drag, the thing that's being
dragged is likely to be what's on-top, but you want the child window
of (say) some dialog underneath.

wxWidgets actually has this function internally, but it is not
declared "extern" in any of the header files, so you can't call
it. It's exactly the same, but also takes a wxWindow *, i.e. it's
overloaded. It's a pity it's not exported, as it does exactly what
you would want it to do (I needed it too for fixing dragmgr as
it happens). So what I did was duplicate the (short) function
in wxXtra, and call it wxChildWindowFromPoint (have a look at
wxXtra/cwfrompoint.h I've just checked in). I renamed it as I've
also asked the wxWidgets folks to export the function, and I
didn't want a name clash if/when they do.

Alex