win32 window won't show child windows

316 views Asked by At

I'm trying to create a window with c++ winapi (CreateWindowExW, RegisterClassExW). The window is dark, has the mica theme, and is borderless.

The window itself works fine, but when I'm trying to create any kind of child window (in this example, a button) it just won't show on the parent.

Does anyone why?

The window and button creation is as such:

WNDCLASSEXW wcx{};
wcx.cbSize = sizeof(wcx);
wcx.style = CS_HREDRAW | CS_VREDRAW;
wcx.hInstance = nullptr;
wcx.lpfnWndProc = wndproc;
wcx.lpszClassName = L"RunUIClass";
wcx.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_WINDOW + 1);
wcx.hCursor = ::LoadCursorW(nullptr, IDC_ARROW);
ATOM result = ::RegisterClassExW(&wcx);

auto handle = CreateWindowExW(
            WS_EX_NOREDIRECTIONBITMAP | WS_EX_TOPMOST, L"RunUIClass", L"RunUI Window",
            WS_POPUP | WS_THICKFRAME | WS_CAPTION | WS_SYSMENU | WS_MAXIMIZEBOX | WS_MINIMIZEBOX, GetSystemMetrics(SM_CXSCREEN) / 2 - (APP_WIDTH / 2), GetSystemMetrics(SM_CYSCREEN) / 2 - (APP_HEIGHT / 2),
            APP_WIDTH, APP_HEIGHT, nullptr, nullptr, nullptr, userdata
        );

auto button = CreateWindow(WC_BUTTON, L"Button",
        WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON,
        50, 50,
        BUTTON_SIZE, BUTTON_SIZE,
        handle, NULL, NULL, NULL);
0

There are 0 answers