[Solved] Setting Checkbox Options C++ [closed]


How can I give the CreateWindowW function multiple strings for multiple checkboxes?

CreateWindow() can only create 1 window/control per call. You will have to manually split up the strings and then call CreateWindow() separately for each individual checkbox.

Assuming your vector<string> contains the checkbox strings, you can pass the vector to your window via the lpParam parameter of CreateWindow(), and then access it in your WM_CREATE message handler, eg:

void Select(vector<string>& ret)
{
    ...
    CreateWindowW(..., &ret);
    ...
}

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
    switch (msg) {
        case WM_CREATE: {
            LPCREATESTRUCT lpcs = reinterpret_cast<LPCREATESTRUCT>(lParam);
            vector<string> *strings = reinterpret_cast<vector<string>*>(lpcs->lpCreateParams);
            // use strings as needed ...
            break;
        }
        ...
    }
    ...
}

0

solved Setting Checkbox Options C++ [closed]