[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Writing values of a file to a text box in MFC

Posted on 2007-03-18
3
Medium Priority
?
1,143 Views
Last Modified: 2013-11-26
Hi,
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!
-D
0
Comment
Question by:indacrypt
[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
3 Comments
 
LVL 12

Expert Comment

by:migel
ID: 18746572
Use explicit std::string method:
IDC_OUT.SetWindowText(stringtoprint.c_str()).
0
 

Author Comment

by:indacrypt
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?
THanks!
___
      fstream foutput;

      foutput.open("resultsfile.txt");
        if (foutput.is_open())
        {
            while (! foutput.eof() )
            {
                  getline (foutput,output);
                  IDC_OUT.SetWindowText(output.c_str());
            }
            foutput.close();
      }
___
0
 
LVL 12

Accepted Solution

by:
migel earned 375 total points
ID: 18749888
Hello
Use ReplaceSel CEdit method
example
{
    fstream foutput;

      foutput.open("resultsfile.txt");
        if (foutput.is_open())
        {
            while (! foutput.eof() )
            {
                  int len = IDC_OUT.GetWindowTextLength();
                  IDC_OUT.SetSel(len, len);
                  getline (foutput,output);
                  IDC_OUT.ReplaceSel(output.c_str());
            }
            foutput.close();
      }}
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

649 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