ZijingWu
ZijingWu

Reputation: 3490

Why CreateWindowEx will add WS_CAPTION by default?

I'm trying to create an window by CreateWindowEx, but seams even I give both dwExStyle dwStyle value 0, the window still have WS_CAPTION style.

Code snippet as following:

   _hWnd = CreateWindowExW(iExStyle, pszClassName, pszTitle, iStyle | WS_CLIPCHILDREN, dX, dY, dWidth, dHeight,
                            hWndParent, 0, hInstance, NULL); 
   ASSERT(GetWindowLong(_hWnd, GWL_STYLE) & WS_CAPTION == 0); //<---- This will failed.

Upvotes: 0

Views: 528

Answers (2)

Anders
Anders

Reputation: 101756

As emax says, WS_OVERLAPPED (0) is the default and results in:

The window is an overlapped window. An overlapped window has a title bar and a border. Same as the WS_TILED style.

If you are creating a child window you must specify WS_CHILD and if you are creating a "popup" window you must use WS_POPUP or WS_POPUPWINDOW.

A tooltip for example would use WS_POPUP and WS_EX_TOOLWINDOW + WS_EX_TOPMOST...

Upvotes: 1

emax
emax

Reputation: 521

dwStyle = 0x00000000L means WS_OVERLAPPED or WS_TILED, this window has a title bar and a border.

Window Styles

Upvotes: 3

Related Questions