Quote:
Originally Posted by stp
This is what I made.
ProjectDlg.h file
Code:
class CProjectDlg : public CDialog
{
private:
CComboBox *Combo;
// Construction
public:
CSixDlg(CWnd* pParent = NULL); // standard constructor
...
...
...
ProjectDlg.cpp
Code:
BOOL CProjectDlg::OnInitDialog()
{
CDialog::OnInitDialog();
SetIcon(m_hIcon, TRUE);
SetIcon(m_hIcon, FALSE);
// TODO: Add extra initialization here
Combo = new CComboBox;
Combo->Create(WS_CHILD | WS_VISIBLE |
WS_VSCROLL | CBS_DROPDOWNLIST,
CRect(10, 50, 100, 150), this, 0x1448);
Combo->AddString("First");
Combo->AddString("Second");
Combo->AddString("Third");
return TRUE; // return TRUE unless you set the focus to a control
}
Can you help me further? Or give me a link with this information
First you need to create a function for the combo box change event to hold, you can do so by going to the CProjectDlg.h (corresponding header file) and then writing a function : afx_msg void changedcombo(); where changedcombo() is the name of the combobox we will be using. Then return to the corresponding .cpp file, in your case CProjectDlg.cpp and declare the following function inside BEGIN_MESSAGE_MAP(), which should be a predefined function in the class as: ON_CBN_SELCHANGE(0x1448,&CProjectDlg::OnComboChang ed). Now is the time to define the funtion, we can do so by writing our funtion as void CProjectDlg::OnComboChanged(){ } and inside the funtion we can type int nIndex = Combo->GetCurSel();
CString str;
Combo->GetLBText(
nIndex, str);
and get the current item selected. Hope this helps.