View Single Post
Old 10-20-2019, 04:57 PM   #515
Human being with feelings
WyattRice's Avatar
Join Date: Sep 2009
Location: Virginia
Posts: 1,948
Default Win32 Api Combo Box Noob Question

I have an extension that is a dialog box with two combo boxes.

In my dlgprocess in WM_INITDIALOG:

I'm populating both combo boxes.

I want to try and join, or connect the combobox1 index to combobox2, so when I change combobox 1, combobox 2 changes too.
case IDC_COMBO1: {
		if (HIWORD(wParam) == CBN_SELCHANGE)
			int index = SendDlgItemMessage(g_hwnd, IDC_COMBO2,


		return 0;
Years ago I did this with like:
    Private Sub ComboBox2_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
        ComboBox1.SelectedIndex = ComboBox2.SelectedIndex
Was wondering if it was possible with just plain win32?
Any help would be appreciated.

Got it working. Had to get index first.
	case IDC_COMBO2: 
		HWND hwndCB1 = GetDlgItem(g_hwnd, IDC_COMBO1);
		HWND hwndCB2 = GetDlgItem(g_hwnd, IDC_COMBO2);

		if (HIWORD(wParam) == CBN_SELCHANGE && (LOWORD(wParam) == IDC_COMBO2))
			int idx;
			idx = SendMessage(hwndCB2, CB_GETCURSEL, 0, 0);
			SendMessage(hwndCB1, CB_SETCURSEL, idx, 0);

Many Thanks,

Last edited by WyattRice; 10-21-2019 at 10:38 AM.
WyattRice is online now   Reply With Quote