Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6069315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:48:35+00:00 2026-05-23T09:48:35+00:00

Well, that’s only half true. Newlines work fine for the most part, but when

  • 0

Well, that’s only half true. Newlines work fine for the most part, but when I load a file into it, none of the newlines are shown. Copying the text and pasting it into Notepad++ with view all characters turned on shows that the carriage return and line feed are there.

My loading code:

void open_file(HWND hwnd,const char* fname){
    SendMessage(textbox,WM_SETTEXT,(WPARAM)0,(LPARAM)"");
    FILE* file=fopen(fname,"r");
    fullpath=fname;
    filename=fullpath.substr(fullpath.rfind('\\')+1,fullpath.length());
    int pos;
    while(!feof(file)){
        pos=GetWindowTextLength(textbox);
        SendMessage(textbox,EM_SETSEL,pos,pos);
        fread(buffer,2048,sizeof(char),file);
        SendMessage(textbox,EM_REPLACESEL,false,(LPARAM)buffer);}
    fclose(file);
    SendMessage(hwnd,WM_SETTEXT,0,(LPARAM)filename.c_str());}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T09:48:35+00:00Added an answer on May 23, 2026 at 9:48 am

    Since you’re opening the file in text mode your text represents newline by \n. Possibly the text edit control requires \r\n.

    One possibility is to do like this (off the cuff)

    std::string line;
    std::ifstream file( fname );
    while( std::getline( file, line ) )
    {
        line += "\r\n";
        // Append  the line to the edit control here (use c_str() ).
    }
    

    But better, set the text all at once, like:

    std::string line;
    std::string text;
    std::ifstream file( fname );
    while( std::getline( file, line ) )
    {
        line += "\r\n";
        text += line;
    }
    SetWindowText( textbox, text.c_str() ... whatever );  // Not sure of args, check docs.
    

    Cheers & hth.,

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to make a composite key (well that's the idea but I'm open
I know very well that this question is ask many time but some how
I want to cut only ALLS WELL THAT ENDS WELL until Florentine. That mean
I need to use Sqlite, but there's a problem with my syntax (well that's
I know perfectly well that Python can handle unicode strings. But I want the
Tomcat has got that well-known memory leak problem that causes PermGen space errors after
It is well-known that monoids are stunningly ubiquitous in programing. They are so ubiquitous
It may well be that I have to write something overly complex for this
While I am well aware that it isn't possible for me to refer to
Disclaimer I am well aware that PHP might not have been the best choice

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.