Click to See Complete Forum and Search --> : ComboBox Confusion
Karen0302
August 21st, 2003, 04:54 AM
Hi Everyone!
I'm a little bit confused and hope that someone here can help me clear it up.
I am trying to add a combobox to my MFC Dialog program but can't quite figure out how to create the control variable. If it were an edit box, I would simply right click while the cursor is in the edit box and select Add Variable and then make it a control variable of the proper class. But the Add Variable function doesn't seem to be available for a ComboBox.
Could someone here point me in the right direction please?
Thanks!
Karen
Andreas Masur
August 21st, 2003, 05:15 AM
You can do this with the class wizard (CTRL+W). Select the register 'Member variables' and select your combobox control. Click on the 'Add Variable' button. In the dialog select 'Control' from the category box and 'CComboBox' from the type box (which will automatically set by default).
Karen0302
August 21st, 2003, 05:58 AM
Andreas,
Thanks very much for your reply. It does however bring up 2 questions, both of which seem to orbit around the confusion which caused my initial post.
First, what does you refer to when you say 'member variable register'. I looked all over the place and can't find anything called a register for member variables.
Second, if by some miracle, I do mamage to find this member variable register, how can I select the ComboBox Control when I can't figure out how to create the control in the first place. Or is it created automatically when I dragged the combobox in the dialog editor?
The actions you describe appear very similar to those I do when I create a control variable for an edit box, simply right clicking on the box gives me the option of Add Variable. This same process doesn't seem to work for a combobox.
Karen
Andreas Masur
August 21st, 2003, 06:47 AM
Okay...well I always use the class wizard to assign member variables to controls or their content. Thus, I basically do not know of any option 'Add Variable' from the context menu in the resource editor.
However, to answer your questions:
Originally posted by Karen0302
First, what does you refer to when you say 'member variable register'. I looked all over the place and can't find anything called a register for member variables.
Well...the class wiazrd consists of several so-called registers. These registers allow you to do different things like adding message handlers for the controls etc. Take a look at the top of the class wizard. There should be a a register named 'Member variables'.
Originally posted by Karen0302
Second, if by some miracle, I do mamage to find this member variable register, how can I select the ComboBox Control when I can't figure out how to create the control in the first place. Or is it created automatically when I dragged the combobox in the dialog editor?
Well...the control is created by simply drag and drop it into your dialog within the resource editor. It will get a default identifier which of course can (and should) be changed within the properties of the control.
Originally posted by Karen0302
The actions you describe appear very similar to those I do when I create a control variable for an edit box, simply right clicking on the box gives me the option of Add Variable. This same process doesn't seem to work for a combobox.
As I said before...I do not know of such an option (and I do not see it in my Visual Studio 6.0). It might be however, that you are using .NET instead which might have this option. And in this case it also might be that the way I described earlier (using the class wizard) does not work any longer, since there is no class wizard in .NET any longer...in this case I cannot help much since I did not dive that deep into the .NET thingie yet. However, as far as I remember these settings are all done through the properties of the control...
Karen0302
August 21st, 2003, 07:02 AM
Andreas,
Yes, you are correct, I am using .NET and at times like this, I think it causes more problems than it solves.
I do have a bit more information which unfortunately doesn't shed much light on the problem at least for me.
The dialog box that I am trying to create the combobox for is a secondary (child?) dialog that gets kicked off with the DoModal function.
Just as part of kicking the problem around, I went back and tried to create a combobox as part of the main Dialog program .... and it worked fine. I was able to add a control variable by right clicking on the box just like I do for edit boxes. I was also able to add a working combo box to the About dialog that was created as part of the initial application setup.
But for some reason, as yet unknown, when I try to create a combobox in a dialog which was added with the Add Resource function, it won't let me create a control variable for it.
That being said, it appears that I am still missing something somewhere in the process. So if anyone can point me to the missing item, I would be most appreciative.
Karen
Andreas Masur
August 21st, 2003, 07:19 AM
[Moved thread]
Andreas Masur
August 21st, 2003, 07:20 AM
Karen,
As I have said in my previous reply I cannot be of much help in this case....sorry about that.
However, I have moved the thread to a more appropriate forum for your question thus someone should be able to help you here... :cool:
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.