A: Top-level sunt toate ferestrele care nu sunt child (copil); altfel spus nu au setat stilul WS_CHILD.
Note
- spre deosebire de ferestrele copil, o fereastra top-level poate fi afisata oriunde pe ecran;
- multe definitii spun ca o fereastra top-level este "o fereastra care nu are parent (parinte)";
este corect dar aceasta poate da nastere la o confuzie: multi cred ca orice fereastra care a fost creata pasand un handle valid in argumentul hWndParent al functiei CreateWindow(Ex) "are un parinte" deci, conform cu definitia, nu este o fereastra top-level;
de fapt, hWndParent poate fi sau un handle la fereastra parinte sau un handle la fereastra owner;
daca hWndParent este un handle valid la o fereastra iar stilul WS_CHILD nu este setat, avem o fereastra top-level "owned"; - o fereastra top-level poate fi sau nu owned dar niciodata child; putem spune ca poate avea un owner dar nu poate avea niciodata un parent;
- ferestrele top-level pot fi overlapped sau pop-up;
- in functiile CreateWindow(Ex), MoveWindow, SetWindowPos etc, cordonatele sunt relative la ecran (screen coordinates);
Exemple
Code: Select all
// 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);
Code: Select all
// 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);
- [WinAPI] Ce este o fereastra "owned"?
- [WinAPI] Ce este o fereastra overlapped?
- [WinAPI] Ce este o fereastra pop-up?
<< Back to Windows API Index