Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CComboBox problemm

1 view
Skip to first unread message

azsx

unread,
Oct 30, 2006, 3:52:09 PM10/30/06
to
Hi. I create create a ComboBox control on a Dialog resource. In the
OnInitDialog method I try cmb.AddString(L"iihaaaa!"); which doesn't
seem to work. I use visual studio 2005, c++, can you help me?

Scott McPhillips [MVP]

unread,
Oct 30, 2006, 4:20:45 PM10/30/06
to

You are not giving us much info. What does AddString return? What do
you mean by "doesn't seem to work"?

Your OnInitDialog should contain a call to CDialog::OnInitDialog. Try
putting your code after that call.

If it still doesn't work there could be something wrong with the way you
set up your cmb variable. It should be a member variable of type
CComboBox. It should be connected to the control by a line of code like
this, which should have been added automatically in DoDataExchange:

DDX_Control(pDX, IDC_COMBO1, cmb);

--
Scott McPhillips [VC++ MVP]

azsx

unread,
Oct 30, 2006, 4:56:22 PM10/30/06
to
> Your OnInitDialog should contain a call to CDialog::OnInitDialog. Try
> putting your code after that call.
>
> If it still doesn't work there could be something wrong with the way you
> set up your cmb variable. It should be a member variable of type
> CComboBox. It should be connected to the control by a line of code like
> this, which should have been added automatically in DoDataExchange:
>
> DDX_Control(pDX, IDC_COMBO1, cmb);

Visual Studio 2005 does this automatticly. So the code is just like you
described. I tested some examples and they don't work too.

Scott McPhillips [MVP]

unread,
Oct 30, 2006, 5:23:13 PM10/30/06
to
azsx wrote:
> Visual Studio 2005 does this automatticly. So the code is just like you
> described. I tested some examples and they don't work too.

How can anybody help you? - You still have not given us any information.
What does AddString return? What error or symptom do you get? Do
other controls work?

David Wilkinson

unread,
Oct 30, 2006, 5:23:33 PM10/30/06
to
azsx wrote:

azsx:

"Doesn't seem to work" is not an adequate description of the problem.

David Wilkinson

azsx

unread,
Oct 30, 2006, 5:38:49 PM10/30/06
to
I have a CEdit and a CComboBox on my DialogBox.
The effect of my code is that my combobox doesn't get initialized
(despite the AddString(..) methos I call). I tried InsertString(...). I
can see it but I can't put there any values. Please help me if you can.
Can you give me a project that 100% works?

David Wilkinson

unread,
Oct 30, 2006, 5:45:45 PM10/30/06
to
azsx wrote:

azsx:

Maybe you need to increase the height of the combo in the resource editor?

David Wilkinson

azsx

unread,
Oct 31, 2006, 12:33:53 AM10/31/06
to

> Maybe you need to increase the height of the combo in the resource editor?
Nope, the resource editor sets the height automatticly, I can't change
it. This combobox, it look OK, but is just wouldn't show anything.
Maibe I should use AddString anywhere but there (OnInitDialog)???

LiYin

unread,
Oct 31, 2006, 12:48:29 AM10/31/06
to
no exactly, You can click on the drop down button in the Combobox to change
the height.
"azsx" <radu_p...@yahoo.com> wrote in message
news:1162272833.0...@m73g2000cwd.googlegroups.com...

azsx

unread,
Oct 31, 2006, 3:56:46 AM10/31/06
to
> no exactly, You can click on the drop down button in the Combobox to change
> the height.
THANK YOU!!!
If some other problems should appear I'll ask you. Thank you!!!

Tom Serface

unread,
Nov 1, 2006, 6:34:11 PM11/1/06
to
It's amazing how many times people get caught on this one. I hope they make
this easier to figure out in a future version of the resource editor. Once
you know it you sort of slap your head and go "doh", but ...

Tom

"azsx" <radu_p...@yahoo.com> wrote in message

news:1162285006.5...@m73g2000cwd.googlegroups.com...

Ajay Kalra

unread,
Nov 1, 2006, 7:42:48 PM11/1/06
to

VS2005 does not have this problem. I had tested it earlier. IIRC, you
see all the strings you add. I think it auto adjusts the height. So I
am not sure how OP has resolved this issue by changing the height in
resource editor.

---
Ajay

azsx

unread,
Nov 2, 2006, 2:28:42 AM11/2/06
to
> VS2005 does not have this problem. I had tested it earlier. IIRC, you
> see all the strings you add. I think it auto adjusts the height. So I
> am not sure how OP has resolved this issue by changing the height in
> resource editor.
It works now!

Ajay Kalra

unread,
Nov 2, 2006, 7:45:28 AM11/2/06
to

"azsx" <radu_p...@yahoo.com> wrote in message
news:1162452522.3...@h48g2000cwc.googlegroups.com...

Why was it not working though as VS2005 does not have this issue?


--
Ajay Kalra [MVP - VC++]
ajay...@yahoo.com

azsx

unread,
Nov 2, 2006, 10:25:32 AM11/2/06
to
> Why was it not working though as VS2005 does not have this issue?
I don't know!

Tom Serface

unread,
Nov 2, 2006, 7:27:14 PM11/2/06
to
Even though the default size is set now, it is easy enough to change it
back. Could have happened by accident.

Tom

"azsx" <radu_p...@yahoo.com> wrote in message

news:1162481132.5...@i42g2000cwa.googlegroups.com...

Ajay Kalra

unread,
Nov 2, 2006, 7:35:56 PM11/2/06
to

Tom Serface wrote:
> Even though the default size is set now, it is easy enough to change it
> back. Could have happened by accident.

What I found was that it auto adjusting to the number of items in it. I
am guessing its some style or something.

---
Ajay

Tom Serface

unread,
Nov 2, 2006, 9:12:37 PM11/2/06
to
Hmmm... I haven't seen that one. It starts off being sized to hold around 3
items for me. Maybe it auto-sizes if the items are built into the control
rather than being added with AddString()?

Tom

"Ajay Kalra" <ajay...@yahoo.com> wrote in message
news:1162514156.4...@i42g2000cwa.googlegroups.com...

Ajay Kalra

unread,
Nov 2, 2006, 10:13:53 PM11/2/06
to

Tom Serface wrote:
> Hmmm... I haven't seen that one. It starts off being sized to hold around 3
> items for me. Maybe it auto-sizes if the items are built into the control
> rather than being added with AddString()?

I added items at run time as well as design time and it seems to be
auto adjusting. I tried only with 3-4 items. Its far better than
previous versions.

---
Ajay

azsx

unread,
Nov 3, 2006, 4:27:54 AM11/3/06
to
hm, it didn't work earlier and it worked after I've changed the height.
I'm glad it works, i do not ask myself questions... Maybe it worked
before (as I could see the combobox) but it just couldnt show me the
"options" as it didn't have enought space reserved for it...

0 new messages