×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

combo box, extremely simple

combo box, extremely simple

combo box, extremely simple

(OP)
Visual Studio 2008, MFC, Windows XP
I created a combo box with a drop down that displays the numbers 01 through 12.  The range will never change.  The name is IDC_STREAM_NUMBER.    After creating an even handler the name IDS_STREAM_NUMBER doesn't like putting the -> or . (dot) notation after it.  

I cannot figure out how to get the selected number from the combo box into my code.
Its the simple stuff that eats my lunch.

Thank you

We need to know what a dragon is
before we study its anatomy.
(Bryan Kelly, 2010)
 

RE: combo box, extremely simple

You probably need to get the handle first with GetDlgItem(IDC_STREAM_NUMBER).  If you assign that to a CComboBox (or something very similar in spelling), then you can access the methods from the combo box.

RE: combo box, extremely simple

(OP)
Thank you for that tip, so armed I was able to figure some things out.  But I am not quite there yet.

I created the combo box and hardcoded the display values as: 1;2;3;4;  and up through 12.  When the code runs the combo box is displayed and the drop down shows the available selection. So far so good.

To add a varible I right clicked on the combo box, selected add variable, and changed to not be a control variable.  Then I added an event handler and in there wrote:

CODE

void COMEGAUserApplicationExampleDlg::OnCbnSelchangeIdcStreamSelect()
{
   // TODO: Add your control notification handler code here
   BOOL translated_ok = true;
   BOOL is_signed     = false;
   CWnd *temp = GetDlgItem( IDC_IDC_STREAM_SELECT );
   m_stream_selection = temp->GetDlgItemInt( IDC_IDC_STREAM_SELECT,
                                          &translated_ok,
                                          is_signed );
   

}
After setting a break point at the exit brace, ran the code.  After selecting "2" from the combo box the value of m_stream_selection is 0 and variable translated_ok is 0.  (It was initialized to true to verify that the function really was changing the value.)

The goal is to wind up with the user's selection number in variable m_stream_selection.  What do I have wrong here?

Before posting it occurred to me:  Should I delete temp before exiting this method?

We need to know what a dragon is
before we study its anatomy.
(Bryan Kelly, 2010)
 

RE: combo box, extremely simple

Try
[CODE]
   BOOL translated_ok = true;
   BOOL is_signed     = false;
   m_stream_selection = GetDlgItemInt( IDC_IDC_STREAM_SELECT,
                                          &translated_ok,
                                          is_signed );
   
[/CODE}

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close