From: Robert May <rmay@po...> - 2005-10-05 22:12:20
I've just spent the evening tracking down this problem, as it was really
annoying me (Tracker: 1165626). The solution was simple, but finding
the information was not. It's such a surprising issue (to me anyway)
that I thought I'd share it with you.
DoModal was using GetParent() to try to find the owner window, so that
it could disable it. It turns out that despite the reference
"If the window is a top-level window, the return value is a handle to
the owner window."
the actual behaviour is somewhat more complex, and that statement does
not hold for overlapped windows, only for popup windows. The real
information can be found at
"The return value from the GetParent function is more confusing.
GetParent returns zero for overlapped windows (windows with neither the
WS_CHILD nor the WS_POPUP style). For windows with the WS_CHILD style,
GetParent returns the parent window. For windows with the WS_POPUP
style, GetParent returns the owner window."
So, the solution was simply to use GetWindow(handle, GW_OWNER) instead
I hope that this might save someone else some time in the future.