Top level windows can have other top level windows as "owners". They always appear in front of their owners (if they have one). Only top level windows get activated (highlighted title bars)..
Overlapped windows always have a caption bar and a border.
With popup windows, the caption bar and border are optional.
Child windows do not have menus. Child windows always appear in front of their parents and are clipped to avoid going beyond parent boundaries. Although they can have title bars, they normally don't get "activated" (highlighted title bars). Instead, when selected, their top-level parent (or ancestor) gets activated.
The following program fragment illustrates how one window class can
be used to make all three types of windows. The "main" overlapped window
is made an owner of the popup, and minimize boxes are enabled so that some
window "dependencies" can be demonstrated.
When CreateWindowEx is called, Windows will send
a WM_CREATE message. Our program creates "subsidiary" windows as a response
to this message.
We also ensure that only the main window terminates
the program when it's closed.
.data wc WNDCLASSEX <size WNDCLASSEX,CS_HREDRAW+CS_VREDRAW,WndProc,0,0, 0, \ 0,0,COLOR_WINDOW+1, 0,wndclsname,0> overlap CREATEARGS <0,wndclsname,caption,WS_OVERLAPPED+WS_CAPTION+WS_SYSMENU+\ WS_THICKFRAME+WS_MINIMIZEBOX+WS_VISIBLE,100,100,200,200,0,0,0,0> popup CREATEARGS <0,wndclsname,caption,WS_POPUP+WS_CAPTION+WS_SYSMENU+\ WS_THICKFRAME+WS_MINIMIZEBOX+WS_VISIBLE,150,150,200,200,0,0,0,0> child CREATEARGS <0,wndclsname,caption,WS_CHILD+WS_CAPTION+WS_SYSMENU+\ WS_THICKFRAME+WS_MINIMIZEBOX+WS_VISIBLE,50,50,50,50,0,0,0,0> wndclsname db 'generic',0 caption db 'Anywhere',0 .code InitApp: mov edi,offset wc mov esi,offset overlap push large IDC_ARROW push large 0 call LoadCursor mov [wc].wcxCursor,eax ret .data mainwnd dd 0 .code WndProc: mov eax,[esp+4+4] ; message cmp eax,WM_CREATE je finish_create cmp eax,WM_DESTROY je start_destroy jmp DefWindowProc extrn CreateWindowEx:near finish_create: cmp [mainwnd],0 jne create_nonmain mov eax,[esp+4+0] ; hwnd mov [mainwnd],eax ; set main window handle so we don't recurse indefinitely push esi push edi mov esi,offset popup mov [esi].cwargParent,eax ; make "overlap" an owner of "popup" mov eax,[wc].wcxInstance mov [esi].cwargInstance,eax ; set popup instance sub esp,48 ; allocate args mov edi,esp mov ecx,12 rep movsd call CreateWindowEx mov esi,offset child mov [esi].cwargParent,eax ; make "popup" a parent of "child" mov eax,[wc].wcxInstance mov [esi].cwargInstance,eax ; set child instance sub esp,48 ; allocate args mov edi,esp mov ecx,12 rep movsd call CreateWindowEx pop edi pop esi create_nonmain: xor eax,eax ; signal a successful CREATE ret 16 start_destroy: mov eax,[esp+4+0] ; hwnd cmp eax,[mainwnd] jne no_special_destroy push large 0 call PostQuitMessage no_special_destroy: xor eax,eax ret 16