title: The correct way of getting the parent window
body: <p>The MSDN says the following about the <code>GetParent</code> function:</p>
  
  <blockquote>
    <p>To obtain the parent window and not
    the owner, instead of using <code>GetParent</code>, use <code>GetAncestor</code> with the
    <code>GA_PARENT</code> flag.</p>
  </blockquote>
  
  <p>But when calling <code>GetAncestor(hWnd, GA_PARENT);</code> for a window that doesn't have a parent, it returns the desktop window, while <code>GetParent</code> returns <code>NULL</code>.</p>
  
  <p>So what is the correct way of getting a parent (and not the owner), and getting <code>NULL</code> if there are none?</p>
  
  <p>Of course I could check whether <code>GetAncestor</code> returns the desktop window, but that seems like a hack to me.</p>