Collapse the table of content
Expand the table of content
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer


Call this member function to retrieve the owner window that should be used for dialog boxes or other modal windows.

static CWnd* GetSafeOwner(
   CWnd* pParent = NULL,
   HWND* pWndTop = NULL



A pointer to a parent CWnd window. May be NULL.


A pointer to the window that is currently on top. May be NULL.

A pointer to the safe owner for the given window.

The safe owner is the first non-child parent window of pParent. If pParent is NULL, the thread's main window (retrieved via AfxGetMainWnd) is used to find an owner.


The framework itself uses this function to determine the correct owner window for dialog boxes and property sheets where the owner is not specified.

© 2016 Microsoft