Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How to get values from MFC dialog box comboboxes and give to another class variable

Posted on 2009-05-20
2
1,135 Views
Last Modified: 2012-05-07
How to get values from MFC dialog box
comboboxes and give to another class variable

How can i access the selected value

please specify how to set and get value from controls in mfc dialog boxes.
0
Comment
Question by:PBCHANDRAN
2 Comments
 
LVL 16

Accepted Solution

by:
HooKooDooKu earned 200 total points
ID: 24431433
Try the following where IDC_CMB is what ever dialog ID value you've assigned the combo box control.
(Logic assumes it's being executed from within the dialog box, if not, change GetDlgItem() to something like MyDlg.GetDlgItem())
CString str; 
CComboBox* pCB = (CComboBox*) GetDlgItem( IDC_CMB );
int nCurSel = pCB->GetCurSel();
if( nCurSel != CB_ERR )
{
    pCB->GetLBText( nCurSel, str ); 
}
else
{
    pCB->GetWindowText( str );
}

Open in new window

0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
In Easy String Encryption Using CryptoAPI in C++ (http://www.experts-exchange.com/viewArticle.jsp?aid=1193) I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question