# CodeGuru Technical FAQs > CodeGuru Individual FAQs >  Windows SDK: What is a top-level window?

## ovidiucucu

*Q*: What is a _top-level window_?

*A*: A _top-level window_ is a window that is not _child_, i.e. it has not WS_CHILD style set.

Notes
 unlike the _child windows_, a _top-level window_ can be displayed anywhere in the screen; many definitions state that a _top-level window_ is _"a window that has no parent"_; 
that is correct but can lead in a confusion: many people think that every window which is created passing a valid _hWndParent_ in CreateWindow(Ex) "has a parent" then, according to the definition it is not _top-level_; 
in fact _hWndParent_ may be either a handle to _parent_ or _owner_ window; 
if _hWndParent_ is a valid window handle and WS_CHILD style is not set, then we have a _top-level owned window_; a _top-level window_ can or can not be _owned_ but is never a _child_; further we can say that it can have an _owner_ but never has a _parent_. _top-level windows_ can be either _overlapped windows_ (having WS_OVERLAPPED style and generally used as application main window) or _popup windows_ (having WS_POPUP style, usually temporary windows like message boxes and dialogs); the coordinates used in CreateWindow(Ex), MoveWindow, SetWindowPos, and so on are always scren coordinates (relative to top-left corner of the screen).

Examples


```
// create a top-level window (not owned)
HWND hWnd = CreateWindow(szWindowClass, szTitle, 
              WS_OVERLAPPED, // WS_CHILD style is not set, so it's a top-level window.
              CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, 
              NULL,          // no handle to the owner, so it's not owned.
              NULL, hInstance, NULL);
```



```
// create a top-level window (owned)
HWND hWnd = CreateWindow(szWindowClass, szTitle, 
              WS_OVERLAPPED, // WS_CHILD style is not set, so it's a top-level window
              CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, 
              hWndParent,    // handle to the owner, so it's an owned window
              NULL, hInstance, NULL);
```

See also
Windows SDK: What is a child window?

----------

