triumphost 120 Posting Whiz

Why can't I capture the variable Painted and change it? The second that I capture it, it throws a compile time error:

*cannot convert 'Foo()::<lambda(HWND, uint32_t, WPARAM, LPARAM)>'


'WNDPROC {aka long long int ()(HWND__, unsigned int, long long unsigned int, long long int)}' in initialization*

Yes I realize creating the Window within this function is awkward but I am threading this function and that is why I need to capture the variable Painted. I need to know when the Window has painted. That's why. I need to somehow get notified when the window in the thread has been painted so that I can do other operations in the main thread.

void Foo()
    std::atomic<bool> Painted;

    auto WindowProcedure = [&Painted](HWND window, std::uint32_t msg, WPARAM wp, LPARAM lp) -> LRESULT __stdcall
            case WM_PAINT:
                Painted = true;

            case WM_DESTROY:
                return 0;

                return DefWindowProc(window, msg, wp, lp);
        return 0;

    WNDCLASSEX WndClass =
        sizeof(WNDCLASSEX), CS_DBLCLKS, WindowProcedure,
        0, 0, GetModuleHandle(NULL), LoadIcon(NULL, IDI_APPLICATION),
        NULL, "Class", LoadIcon (NULL, IDI_APPLICATION)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.