开发者

How to fill combobox in a Visual Studio C++ Win32 project

开发者 https://www.devze.com 2023-03-30 09:58 出处:网络
How can I fill a combobox in a Visual Studio C++ Win32 project. And how can check that which word was selected by the user.

How can I fill a combobox in a Visual Studio C++ Win32 project. And how can check that which word was selected by the user.

I mean I want a comboxbox for example filled with these: One, Two, Three. And I want to do different events depends开发者_JAVA技巧 on which one was chosen by the user.

Edit: The windows was created as a dialogbox in the resource editor and the message thread runs like this:

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
    return DialogBox(hInst, MAKEINTRESOURCE(IDD_MAIN), NULL, DlgProc);
}

Thank you in advance!


In the WM_INITDIALOG handler for the dialog, you can initialize the combo box with the strings you wish to select with the CB_ADDSTRING message:

SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM) L"one");

Now you can respond to the CBN_SELENDOK message to respond to user changes to the dropdown.

0

精彩评论

暂无评论...
验证码 换一张
取 消