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

Folosire Windows API in programe C/C++ (forum moderat)
Post Reply
User avatar
Ovidiu Cucu
Fondator
Fondator
Posts: 3778
Joined: 11 Jul 2007, 16:10
Judet: Iaşi
Location: Iasi
Contact:

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

Post by Ovidiu Cucu » 15 Aug 2007, 13:07

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



Post Reply