Combo-box - Controls

Provides the functionality of a Windows combo box.

2025-11-04

Written by: xiaobin

Place two combo box controls:

List Creation

500;1000;2000;

OnInitialUpdate()

void CSerialCommView::OnInitialUpdate()
{
    CFormView::OnInitialUpdate();
    GetParentFrame()->RecalcLayout();
    ResizeParentToFit();

    // Add String
    CArray<SSerInfo,SSerInfo&> asi;

    // Populate the list of serial ports.
    EnumSerialPorts(asi,FALSE/*include all*/);

    for (int ii = 0; ii< asi.GetSize(); ii++) {
        m_strPortNum.AddString(asi[ii].strFriendlyName);
    }
}

The Selected String

    CString strTemp;
    int nCurSel;

    nCurSel = ((CComboBox *) GetDlgItem(IDC_COMBO1Timer))->GetCurSel();
    ((CComboBox *) GetDlgItem(IDC_COMBO1Timer))->GetLBText(nCurSel, strTemp);

Ref