Thread: Putting CView text into a buffer

  1. #1
    CodeMonkey
    Guest

    Putting CView text into a buffer

    I'm creating a program (MFC MSVC++6) that opens a text file (viao CView Class) and then gives you the option to encode it and/or decode it by the program's own encoding algorithm. How do I load the text currently showing on the editable part of the window (it's a single document program) into a buffer.

  2. #2
    kuphryn
    Guest
    I assume you mean CEditView.

    -----
    CEdit &rE = GetEditCtrl();
    int currentIndex = rE.LineFromChar(-1);
    const int MAXSIZE = 256;
    TCHAR updatedText[MAXSIZE * sizeof(TCHAR)];
    rE.GetLine(currentIndex, updatedText, MAXSIZE);
    -----

    UpdatedText should now hold one line of the text. You can go through a for-loop to get all lines, but the idea is to use GetLine().

    Kuphryn

  3. #3
    Kiss the monkey. CodeMonkey's Avatar
    Join Date
    Sep 2001
    Posts
    937
    Compiler didn't recognize GetEditCtrl(). Is there another way to do this? Perhaps the whole display at once, also. I really don't know what to do here. The book "Using Visual C++ 6" doesn't cover this one.
    "If you tell the truth, you don't have to remember anything"
    -Mark Twain

  4. #4
    kuphryn
    Guest
    Microsoft does not provide MFC tools to edit data in an edit view and save the data to a file in real-time. In other words, you have to program your own algorithm that work with the edit view. If MFC does have the feature to load and save data from and to an edit view, then that means you could basically derive a working text editor just via AppWizard and/or ClassWizard.

    Kuphryn

  5. #5
    Kiss the monkey. CodeMonkey's Avatar
    Join Date
    Sep 2001
    Posts
    937
    I've been looking through my project files (most created for me by the wizard) for a variable or something where the information being viewed for edit is. Does anyone know what kind of variable this is and/or where it is located?
    "If you tell the truth, you don't have to remember anything"
    -Mark Twain

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Text adventure engine idea. thoughts?
    By suzakugaiden in forum Game Programming
    Replies: 16
    Last Post: 01-15-2006, 05:13 AM
  2. A bunch of Linker Errors...
    By Junior89 in forum Windows Programming
    Replies: 4
    Last Post: 01-06-2006, 02:59 PM
  3. DirectSound - multiple sounds
    By Magos in forum Game Programming
    Replies: 9
    Last Post: 03-03-2004, 04:33 PM
  4. Tetris Questions
    By KneeGrow in forum Game Programming
    Replies: 19
    Last Post: 10-28-2003, 11:12 PM
  5. getline problem
    By Unregistered in forum C++ Programming
    Replies: 4
    Last Post: 10-06-2001, 09:28 AM