Writing values of a file to a text box in MFC

Posted on 2007-03-18
Last Modified: 2013-11-26
Im trying to write to an edit control window in and MFC project. Im reading values from a file into a string, and im using IDC_OUT.SetWindowText(stringtoprint). This gives me an error"CWnd::SetWindowTextA' : cannot convert parameter 1 from 'std::string' to 'LPCTSTR'".

How else can I write to the text box?Thanks!
Question by:indacrypt
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
LVL 12

Expert Comment

ID: 18746572
Use explicit std::string method:

Author Comment

ID: 18747520
Hi thanks for your reply. The following code that I have prints only the last line of the foutput file into the edit control window. How do i fix this?
      fstream foutput;"resultsfile.txt");
        if (foutput.is_open())
            while (! foutput.eof() )
                  getline (foutput,output);
LVL 12

Accepted Solution

migel earned 125 total points
ID: 18749888
Use ReplaceSel CEdit method
    fstream foutput;"resultsfile.txt");
        if (foutput.is_open())
            while (! foutput.eof() )
                  int len = IDC_OUT.GetWindowTextLength();
                  IDC_OUT.SetSel(len, len);
                  getline (foutput,output);

Featured Post

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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MailAddress in vb 4 36
Finding the IIS version 5 37
transition to visual .net from vb6 5 59
Code enhancement 4 32
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
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.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

756 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