Solved

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

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

744 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

10 Experts available now in Live!

Get 1:1 Help Now