Win32: How to create a bordless popup window

shadeglare picture shadeglare · Nov 24, 2011 · Viewed 8.2k times · Source

Win32 API provides many styles for window creating and I'm looking for a style that can remove a one-pixel border from the window that I created with this code:

DWORD dwExtStyle = 0;
DWORD dwStyle = WS_POPUPWINDOW;

    m_hWnd = CreateWindowEx(
    dwExtStyle,
    className,
    windowName,
    dwStyle,
    300,
    300,
    100,
    100,
    NULL,
    NULL,
    hInstance,
    NULL);

ShowWindow(m_hWnd, SW_SHOW);

and I got the result:

enter image description here

What combination of flags can remove the black border from the window.

Answer

rodrigo picture rodrigo · Nov 24, 2011

Just use WS_POPUP instead of WS_POPUPWINDOW.

The macro WS_POPUPWINDOW is actually a set of flags:

#define WS_POPUPWINDOW (WS_BORDER | WS_POPUP | WS_SYSMENU)

The WS_BORDER flag is the one responsible of your black square.