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 748327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:18:28+00:00 2026-05-14T14:18:28+00:00

I’m making a Notepad clone. Right now my text loads fine but where their

  • 0

I’m making a Notepad clone. Right now my text loads fine but where their are newline characters, they do not make newlines in the text field.

I load it like this:

void LoadText(HWND ctrl,HWND parent)
{

    int leng;
    char buf[330000];

    char FileBuffer[500];
    memset(FileBuffer,0,500);

    FileBuffer[0] = '*';
    FileBuffer[1] = '.';
    FileBuffer[2] = 't';
    FileBuffer[3] = 'x';
    FileBuffer[4] = 't';

    OPENFILENAMEA ofn;
    memset(&ofn, 0, sizeof(OPENFILENAMEA));
    ofn.lStructSize = sizeof(OPENFILENAMEA);
    ofn.hwndOwner = parent;
    ofn.lpstrFile = FileBuffer;
    ofn.nMaxFile = 500;
    ofn.lpstrFilter = "Filetype (*.txt)\0\0";
    ofn.lpstrDefExt = "txt";
    ofn.Flags = OFN_EXPLORER;

    if(!GetOpenFileNameA(&ofn))
    {
        return;
    }
    ifstream *file;
    file = new ifstream(FileBuffer,ios::in);

    int lenn;
    lenn = 0;

    while (!file->eof())
    {

        buf[lenn] = file->get();
        lenn += 1;

    }
    buf[lenn - 1] = 0;

    file->read(buf,lenn);
    SetWindowTextA(ctrl,buf);
    file->close();
}

How can I make it do the new line characters?

Thanks

(Fixed it, turns out the stream was not giving me CR’s so I had to insert them.

  • 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-14T14:18:29+00:00Added an answer on May 14, 2026 at 2:18 pm

    Ensure that you have ES_MULTILINE|ES_WANTRETURN set.

    Multiline edit controls use “soft line break characters” to force it to wrap. To indicate a “soft line break”, use CRCRLF (source). So I guess you need to replace all your CRLF’s (or whatever eol character your file uses) with CRCRLF. You’re already reading your file in character by character, so you can just insert an extra CR into the buffer.

    As a side note, you’ll eventually want to do the file IO on a separate thread (i.e. not the UI thread) so that you don’t hang the UI while you’re reading the file. It’d be nice if the UI showed some sort of loading animation, or progress bar.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
this is what i have right now Drawing an RSS feed into the php,
I need to clean up various Word 'smart' characters in user input, including but
I have a text area in my form which accepts all possible characters from
I need a function that will clean a strings' special characters. I do NOT
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into

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.