Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/64.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在c&;中创建复选框;明_C_Mfc_Mingw - Fatal编程技术网

如何在c&;中创建复选框;明

如何在c&;中创建复选框;明,c,mfc,mingw,C,Mfc,Mingw,如何在c中创建复选框/单选按钮/数字步进器? 我可以做一个这样的按钮: CreateWindowEx(0, "BUTTON", label, WS_VISIBLE | WS_CHILD, 10, top, 100, 20, hWndDlg, NULL, hInst, NULL); 我正在使用mingw进行编译。我搜索了这个,发现这在mingw中是不可能的,因为它不支持MFC 此外,了解我想做的事情可能更容易: void renderOptionsTab (HWND hWndDlg, JSONL

如何在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\u复选框
BS\u单选按钮
样式。
见:


查看可用样式的完整列表。

这是纯WinAPI,应该可以与mingw一起使用。您能告诉我们如何使用CreateWindowEx吗?(周围的代码)嗯。。我不明白,我用了很多方法,你想知道我是如何创建的吗?是的,以及在哪里/何时创建按钮。常用的方法是使用CreateWindowEx()创建主窗口,并在WM_create with CreateWindow()上的WindowProcedure中添加按钮之类的内容。。这有点复杂。我试图添加到的窗口是由
对话框(hInst、MAKEINTRESOURCE(IDD_DLG_设置)、NULL、reinterpret_cast(settingsDlgProc))创建的其中有一个选项卡控件
CreateWindowEx(0,WC_TABCONTROL,“,WS_CHILD | WS_CLIPSIBLINGS | WS|u VISIBLE,10,10,rcClient.right-20,rcClient.bottom-42,hwndpent,NULL,hInst,NULL)
我想添加到
对话框中
以响应
案例WM\u NOTIFY:if(((LPNMHDR)lpram)->code==TCN\u SELCHANGE){
对不起,我误解了你的问题。你正在搜索类似CheckBox类的东西。哦……这似乎比我教的容易。谢谢!你有关于数字步进器的任何信息吗?(右边有两个按钮的小文本框:向上和向下)对不起,我还没有找到关于这个的任何东西。我想你必须用一个编辑控件和两个按钮自己构建它。