0

如何在 c 中创建复选框/单选按钮/数字步进器?我可以制作这样的按钮:

CreateWindowEx(0, "BUTTON", label, WS_VISIBLE | WS_CHILD, 10, top, 100, 20, hWndDlg, NULL, hInst, NULL);

我正在使用mingw进行编译。我对此进行了搜索,发现 mingw 无法做到这一点,因为它不支持 MFC?

此外,可能更容易理解我正在尝试做的事情:

void renderOptionsTab (HWND hWndDlg, JSONLinkElement *tab) {
    int top = 35;
    do {
        std::string type = std::string((char *)((JSONObject *)tab->value)->getValue("type"));
        char *label = (char *)((JSONObject *)tab->value)->getValue("label");
        void *value = (char *)((JSONObject *)tab->value)->getValue("value");

        char *forComponent = (char *)((JSONObject *)tab->value)->getValue("for");
        char *idComponent = (char *)((JSONObject *)tab->value)->getValue("id");
        char *group = (char *)((JSONObject *)tab->value)->getValue("group");


        char *display = (char *)((JSONObject *)tab->value)->getValue("display");

        if (type == std::string("checkbox")) {
            CreateWindowEx(0, "Button", label, WS_VISIBLE | WS_CHILD, 10, top, 100, 20, hWndDlg, NULL, hInst, NULL);
        } else if (type == std::string("br")) {

        } else if (type == std::string("buildID")) {
            CreateWindowEx(0, "Static", VERSION.c_str(), WS_VISIBLE | WS_CHILD, 10, top, 100, 20, hWndDlg, NULL, hInst, NULL);
        } else if (type == std::string("browse")) {

        } else if (type == std::string("label")) {

        } else if (type == std::string("radio")) {

        } else if (type == std::string("number")) {

        } else if (type == std::string("button")) {
            CreateWindowEx(0, "BUTTON", label, WS_VISIBLE | WS_CHILD, 10, top, 100, 20, hWndDlg, NULL, hInst, NULL);
        }

        if (display != NULL) {
            if (std::string(display) == std::string("inline")) {
                top -= 30;
            }
        }

        top += 30;
        tab = tab->next;
    } while (tab->next != NULL);
}

按钮工作,不知道如何解决其余的。

4

1 回答 1

1
CreateWindowEx(0, "BUTTON", label, WS_VISIBLE | WS_CHILD | BS_CHECKBOX, 10, top, 100, 20, hWndDlg, NULL, hInst, NULL);

您只需要添加BS_CHECKBOXBS_RADIOBUTTON样式。
看:

http://msdn.microsoft.com/en-us/library/windows/desktop/bb775951%28v=vs.85%29.aspx 获取可用样式的完整列表。

于 2013-09-25T20:04:38.887 回答