Solved

How to loop through IDC_CONTROLS?

Posted on 2013-06-21
2
304 Views
Last Modified: 2013-06-23
I have nine text fields, named IDC_COMBO1 to IDC_COMBO9 ( values are consecutive ).

I want to obtain the values of each and make one string.

I tried this:

char szComboBuffer[];

  // Loop through all COMBO controls,
     // build final string.
    for (int i = IDC_COMBO1; i <= IDC_COMBO9; ++i)
    {
            GetDlgItemText(gl_hWnd, i, szComboBuffer, 2);
    }
   

Open in new window


I chose 2 as last parameter because they might enter 2 digits in the text field.

If it worked as intended, szComboBuffer would hold the final string.

I am fairly new to this. Can someone help me finish this up? Thanks.
0
Comment
Question by:edvinson
[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
2 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 39268177
The easiest way would be to use a std::string for that, e.g.

#include <tchar.h>
#include <string>
usineg namespace std;
typedef basic_string<TCHAR> tstring;

TCHAR szComboBuffer[256];
tstring sAllCombos;

  // Loop through all COMBO controls,
     // build final string.
    for (int i = IDC_COMBO1; i <= IDC_COMBO9; ++i)
    {
            GetDlgItemText(gl_hWnd, i, szComboBuffer, 256);

            sAllCombos += sComboBuffer;
    }
   
    MessageBox(NULL,sAllCombos.c_str(),_T("All Together"),MB_OK)';
                                  

Open in new window

0
 
LVL 1

Author Closing Comment

by:edvinson
ID: 39270356
perfect! I ended up taking the long way, but I am rewriting using this. It's much more efficient. Again, I always learn from your solutions.
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
mixing C++ & C# in Vis Studio 2013 7 281
FMX enumerated colours 2 156
passing data from one form to another form in c++ 27 103
How do I get Window Title of all opened process? 4 61
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

751 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