Solved

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

Posted on 2009-05-20
2
1,142 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
[X]
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
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

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…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

734 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