Get Text From single line CEdit control

Posted on 2005-04-14
Last Modified: 2013-11-20
I have two CEdit controls on a dialog, I have assigned CEdit variables to each.  They are used to enter a user id and password so they are only single line edit controls.  I just want to get the text out of each.  I knoow this is not difficult but I have never used CEdit's before and am in a bit of a rush.

THanks PT
Question by:ptrennum
    LVL 16

    Accepted Solution

    CEdit m_Edit1; //let's say this is one of the CEdit vars
    CString strPass = mEdit1.GetWindowText();
    LVL 16

    Expert Comment

    Sorry, that should be:

    CString strPass;
    LVL 3

    Expert Comment

    There are some options:

    1. assign a member variable (through class wizard) of type "CEdit", e.g. m_edit
    (nonubik's solution)

       CString strEdit;

    2. assign a member variable (through class wizard) of type "CString", e.g. m_strEdit  

       UpdateData(TRUE); // m_strEdit will get the current text
    3. without a member variable

       CString strEdit;
       GetDlgItemText(IDC_EDIT, strEdit);

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Suggested Solutions

    Title # Comments Views Activity
    ORA-01403: no data found 43 75
    either24  challenge 19 73
    Line meaning 9 56
    Use of condition with 'serial' in ansible 2 22
    Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
    Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
    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.
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…

    794 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

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now