Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ MFC dialog GUI
Hey TCP,
 
So I want to make an application where I use a combo box for the user to choose various conversion options. I don't know how it works or what to code when the user clicks an option and then button's show up to convert. Anyone have a specific tutorial on this or how I can get started on the first one? I've looked through about 5 tutorials and all they tell me are functions but not exactly pertaining to what I'm trying to do.
 
(or do combo boxes not apply to my situation..?)
 
Thanks in advance.
 
Picture provided.
 
Posted 1-Nov-10 13:10pm
Edited 1-Nov-10 13:31pm
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Add a handler for the CBN_SELCHANGE event. You can do this via the designer. Select your combobox, and select the Control Events tab in the Properties panel, and choose CBN_SELCHANGE. The auto-added handler will look like this:
 
void CYourDlg::OnCbnSelchangeCombo1()
{
    int sel = m_combobox.GetCurSel(); // code to add
}
 
The variable sel will be the 0 based index of the user's selection
  Permalink  
Comments
Paul Camantigue at 1-Nov-10 18:57pm
   
Thanks for your reply, but what do I do from there? Is it possible for me to show different buttons when a different selection is met?
Nishant Sivakumar at 1-Nov-10 20:10pm
   
Why show different buttons? Show the same button, but just change its text based on what the user selected.
«_Superman_» at 1-Nov-10 20:12pm
   
I presume you want to show different text based on the selection.
For this you can change the text on the controls using SetWindowText.
To show entirely different control based on the selection, you could hide irrelevant controls and show relevant ones using ShowWindow.
You can also create controls dynamically using CreateWindow, but that is not recommended.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 George Jonsson 215
1 Kornfeld Eliyahu Peter 169
2 OriginalGriff 120
3 PIEBALDconsult 110
4 Zoltán Zörgő 99
0 OriginalGriff 6,165
1 DamithSL 4,658
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,649
4 Sergey Alexandrovich Kryukov 3,294


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 1 Nov 2010
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100