gpt4 book ai didi

c - 如何在c和mingw中创建复选框

转载 作者:行者123 更新时间:2023-11-30 15:45:29 25 4
gpt4 key购买 nike

如何在 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);
}

按钮有效,不知道如何解决其余问题。

最佳答案

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获取可用样式的完整列表。

关于c - 如何在c和mingw中创建复选框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19013708/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com