Solved

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

Posted on 2009-05-20
2
1,126 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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 Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

895 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now