Page 1 of 1

[WinAPI] Cum aflu daca o fereastra este 'overlapped'?

Posted: 15 Aug 2007, 13:07
by Ovidiu Cucu
Problema
Exista trei categorii prinicpale de fereste:
  • overlapped - WS_OVERLAPPED
  • popup - WS_POPUP
  • child - WS_CHILD
Avand secventa de cod de mai jos

Code: Select all

   LONG nStyle = ::GetWindowLong(hWnd, GWL_STYLE);

   bool bIsChild = (WS_CHILD & nStyle) ? true : false;
   bool bIsPopup = (WS_POPUP & nStyle) ? true : false;
   bool bIsOverlapped = (WS_OVERLAPPED & nStyle) ? true : false;
Pentru bIsChild si bIsPopup se pare ca obtin valorile corecte, in schimb bIsOverlapped rezulta intotdeauna false.
Daca schimb si pun ceva de genul

Code: Select all

   // ...
   bool bIsOverlapped = WS_OVERLAPPED == (nStyle & WS_OVERLAPPED);
de data aceasta bIsOverlapped este intotdeauna true.

Rezolvare
Stilul WS_OVERLAPPED are valoarea 0 (zero). Deci pentru a afla daca o fereastra se incadreaza in prima categorie de mai sus (overlapped) ne uitam sa nu fie nici child, nici popup.

Exemplu

Code: Select all

   bool bIsOverlapped = !(WS_CHILD & nStyle) && // is not child and...
                        !(WS_POPUP & nStyle);   // ...is not popup
Nota: mai multe amanunte despre ferestre overlapped, popup si child gasiti in articolul Ferestre, ferestre.


<< Back to Windows API Index