Solved

Accessing a MFC combo box

Posted on 2004-08-04
7
1,541 Views
Last Modified: 2013-11-20
Hi,

1. how do I get the pointer/reference of a combo box object that I added in the MS VS 2003 GUI editor and that has got the ID "IDC_COMBO1"?

2. how do put some static strings into it's list?

3. how do I restrict the combo box to allow only the strings from the list (no manual typing)?

BTW, I'm a absolutely new to MFC and win32 but have got some C++ expirience.

Thank you for efforts.
0
Comment
Question by:x4u
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 55

Assisted Solution

by:Jaime Olivares
Jaime Olivares earned 350 total points
ID: 11718075
go to ClassWizard (Ctrl-W)
select your dialog object
select the "member variables" tab
your control label will appear, select it
press the "Add variable" button, another dialog will appear
here is the trick: write a variable name and in the "category" choose "control"
now your dialog has a proper initialized member you can use to pass any message

0
 
LVL 55

Assisted Solution

by:Jaime Olivares
Jaime Olivares earned 350 total points
ID: 11718135
to avoid user to "type" another string, just go to dialog GUI editor, select combo box properties, and change style to "Drop list" (not drop down)

0
 
LVL 44

Assisted Solution

by:AndyAinscow
AndyAinscow earned 150 total points
ID: 11718236
After creating your control var - m_cmboXYZ you can add strings like this

m_cmboXYZ.AddString("One");
m_cmboXYZ.AddString("Two");

The default behaviour is to sort them, you can stop this in the resource editor - it's one of the settings.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 55

Assisted Solution

by:Jaime Olivares
Jaime Olivares earned 350 total points
ID: 11718258
2. how do put some static strings into it's list?

In the resource editor you can insert your static list in combobox properties, "data" tab.
0
 
LVL 11

Author Comment

by:x4u
ID: 11719182
Thank you, adding items works fine now.

But the drop down list height seems to be zero, it is appears only a thick black line. I can browse the items with the cursor keys but how do I resize the list box height to a reasonable height? Can I set set it to resize automatically somehow?

BTW, I get is the same behaviour with AddString and when I type the strings into data properties field.
0
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 350 total points
ID: 11719261
About the control height, it is a common error:
Comboboxes have 2 height: Edit portion height and drop-down list height. You have not resized the second.

Go to dialog GUI editor, select your combobox, the bounding rectangle will be selected, now press on the drop-down arrow, a diferent rectangle will be selected, drag lower boundary to desired size. That's all.
0
 
LVL 11

Author Comment

by:x4u
ID: 11719424
Ahh, cool thanks. I would never have figuered this out myself. ;-)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
mixString challenge 36 134
how do i create updater to My Activex application? 3 101
sameEnds challenge 3 187
modThree challenge 4 105
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

749 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