Simple Windows application

Discussion in 'C++' started by Nicolae Fieraru, Aug 14, 2004.

  1. Hi All,

    I just start using MS Visual C++ 6.0 and I try to make a very simple
    application
    I created a dialog application and I added two controls (Edit boxes).
    Using ClassWizard I added a CString member variable to each edit box.
    Now, I want to create the code that when I press on a button, I should read
    the number I type in the first Edit Box (an integer) and to display the
    double of that number in Edit Box no 2.
    I am not sure if I should create String variables for each Edit Box or an
    Integer variable.

    Any help appreciated

    Regards,
    Nicolae
    Nicolae Fieraru, Aug 14, 2004
    #1
    1. Advertising

  2. Nicolae Fieraru wrote:
    > I just start using MS Visual C++ 6.0 and I try to make a very simple
    > application
    > I created a dialog application and I added two controls (Edit boxes).
    > Using ClassWizard I added a CString member variable to each edit box.
    > Now, I want to create the code that when I press on a button, I should read
    > the number I type in the first Edit Box (an integer) and to display the
    > double of that number in Edit Box no 2.
    > I am not sure if I should create String variables for each Edit Box or an
    > Integer variable.


    Are you sure you need the CString member variable for each edit box?
    It's much easier if you do integer member variables instead, like this:

    void CMyDialogBox::OnButton1()
    {
    UpdateData(true);
    m_int2 = 2 * m_int1;
    UpdateData(false);
    }

    Otherwise you would have to convert between string an integer yourself.
    For instance:

    #include <boost/lexical_cast.hpp> // From www.boost.org

    void CMyDialogBox::OnButton1()
    {
    try
    {
    UpdateData(true);
    const TCHAR *const psz = m_string1;
    const int i = 2 * boost::lexical_cast<int>(psz);
    m_string2.Format(_T("%d"), i);
    UpdateData(false);
    }
    catch(...)
    {
    // TODO Exception handling...
    }
    }

    If you wanna know more about converting strings to integers, this is the
    right newsgroup for you! But if you have more questions on MFC,
    ClassWizard, CString, UpdateData, and edit boxes, you'd better try
    another newsgroup, for instance: microsoft.public.vc.mfc

    Niels Dekker
    www.xs4all.nl/~nd/dekkerware
    Niels Dekker - no reply address, Aug 14, 2004
    #2
    1. Advertising

  3. Hi Niels,

    Thank you very much for your answer, it is helpful. I will use integer
    variables for this project.
    I was also looking for the proper NG, but I couldn't find it before. I will
    post my future questions related to Visual C++ on microsoft.public.vc.mfc

    Best regards,
    Nicolae
    Nicolae Fieraru, Aug 16, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guest
    Replies:
    1
    Views:
    2,414
    Alvin Bruney
    Nov 2, 2003
  2. Amaryllis
    Replies:
    1
    Views:
    514
    Mark Rae
    Aug 10, 2004
  3. Web learner
    Replies:
    1
    Views:
    1,588
    =?Utf-8?B?Q2hhc2U=?=
    Jan 27, 2006
  4. =?Utf-8?B?SHVzYW0=?=

    From Windows application to ASP.Net Web Application

    =?Utf-8?B?SHVzYW0=?=, Mar 12, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    549
    =?Utf-8?B?SHVzYW0=?=
    Mar 12, 2006
  5. geoffbache
    Replies:
    5
    Views:
    890
    geoffbache
    Jun 13, 2008
Loading...

Share This Page