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 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With