Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.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++ 删除并清除组合框win32 api中的所有项_C++_Winapi_Combobox - Fatal编程技术网

C++ 删除并清除组合框win32 api中的所有项

C++ 删除并清除组合框win32 api中的所有项,c++,winapi,combobox,C++,Winapi,Combobox,我正在构建一个windows应用程序,这个组合框拒绝清理。我希望在一个按钮单击到另一个按钮之间删除组合框项目。我试过: SendDlgItemMessage(hWnd, IDC_LIST_COMMANDS, CB_RESETCONTENT, 0, 0); 而且: SendMessage(CommandsListBox, CB_RESETCONTENT, 0, 0); 但它们都不起作用。当我在上述一次调用之后调用LB_GETCOUNT时,我没有得到0 case SOME_EVE

我正在构建一个windows应用程序,这个组合框拒绝清理。我希望在一个按钮单击到另一个按钮之间删除组合框项目。我试过:

SendDlgItemMessage(hWnd, IDC_LIST_COMMANDS, CB_RESETCONTENT, 0, 0);
而且:

SendMessage(CommandsListBox, CB_RESETCONTENT, 0, 0);
但它们都不起作用。当我在上述一次调用之后调用LB_GETCOUNT时,我没有得到0

        case SOME_EVENT:

            ProfileHandler.IdentityIndex = (int)SendMessage(ProfilesCombo, 
CB_GETCURSEL, 0, 0);
            SendMessage(ProfilesCombo, CB_GETLBTEXT, 
(WPARAM)ProfileHandler.stringIndex, (LPARAM)ProfileHandler.string);
            if (ProfileHandler.IdentityIndex == -1) {
                MessageBox(hWnd, "Invalid !", "Error !", MB_OK);
                break;
            }

            StringsSet.clear();
            if (fuc.GetStrings(string(ProfileHandler.string), &StringsSet) 
== SERVER_ERROR) {
                MessageBox(hWnd, "Error Loading strings", "Error !", MB_OK);
                break;
            }

            SendMessage(CommandsListBox, CB_RESETCONTENT, 0, 0); // reset 
content before writing strings
            it = StringsSet.begin();
            for (; it != StringsSet.end(); ++it)
            {
                    (int)SendMessage(CommandsListBox, LB_ADDSTRING, 0,
(LPARAM)(*it).c_str());
            }
            break;
因此,在通过单击收到的每个SOME_事件之间,我希望清除组合框,并再次加载字符串。 现在发生的事情是,每次我单击按钮,收到某个事件,我只是重新加载命令,导致重复。 你知道如何解决这个问题吗?

试试
发送消息(hChildWindows[1],CB_DELETESTRING,(WPARAM)0,(LPARAM)0)


此消息将只清除组合框(项目或字符串)中的一行。

它是组合框还是列表框?你需要下决心。CB_xxx消息用于组合,LB_xxx消息用于列表框。谢谢,我不知道,你解决了@JonathanPottera将其作为答案添加,以便其他人在搜索相同问题时能够更快地找到解决方案。