Outputting to end of line

This is a discussion on Outputting to end of line within the Windows Programming forums, part of the Platform Specific Boards category; Ok this is MFC if it makes a difference....We have to make a text reader so to speak, and she ...

  1. #1
    Registered User
    Join Date
    Feb 2003
    Posts
    162

    Outputting to end of line

    Ok this is MFC if it makes a difference....We have to make a text reader so to speak, and she wants it to have no horizontal scrolls...She wants us to make it so that if a word is going to be split at the end of the window, to not print that word, and bring it down to the next line....I have a few ideas on how to do this but is there someone out there with a given way?

    my idea: I'll just print out 1 word at a time, and then just use the getwidth (forget the actual function), if each letter, and have that loop until the end of the word....after that...in each iteration, ill increment the count of pixels needed, then after the word is complete, simply check if its smaller then the room left, and if it is, print it out...if its not, is where i get lost....this is using files, so how exactly would i go back to the beginning of the word?

  2. #2
    Registered User
    Join Date
    Feb 2003
    Posts
    76
    You need to create an extra variable that contains the length (in letters) of the word as you're reading it. Thus, if you need to you can set the file the file pointer back to the beginning of the word, like this:

    Code:
    int WordLength;
    // ...
    if(MustStartNewLine){
     SetFilePointer(hFile,0-WordLength,NULL,SEEK_CUR);
     // ...
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Data Structure Eror
    By prominababy in forum C Programming
    Replies: 3
    Last Post: 01-06-2009, 09:35 AM
  2. Could somebody please help me with this C program
    By brett73 in forum C Programming
    Replies: 6
    Last Post: 11-25-2004, 02:19 AM
  3. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 02:27 PM
  4. end of line.
    By Unregistered in forum C++ Programming
    Replies: 2
    Last Post: 02-22-2002, 05:01 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21