Thread: MFC: Viewing txt files in MDI view

  1. #1
    Registered User
    Join Date
    Nov 2003
    Posts
    3

    MFC: Viewing txt files in MDI view

    Hello,

    How would I enable my MDI-view application to open *.txt files for viewing/editing, please?

    I tried changing the fields in the document template string (to include (*.txt), etc.), but all in vain.

    Thank you.

  2. #2
    Registered User The Dog's Avatar
    Join Date
    May 2002
    Location
    Cape Town
    Posts
    788
    Have a look at this.

  3. #3
    Registered User
    Join Date
    Nov 2003
    Posts
    3
    I've tried it, and it transpires that MULTIPAD can only successfully view the txt files that it had itself created (or, rather, the files that had been created within it). If we try creating and saving a (test text) file in Notepad, MULTIPAD can't open it correctly!

    Still, thanks for giving me the direction!

  4. #4
    Registered User
    Join Date
    Nov 2003
    Posts
    3
    For those still looking for the solution to my original problem (ie just being able to view txt files):

    Assuming we've got a CEditView-derived class (NOT like in the MULTIPAD sample), just over-write the code in your CDocument-derived class's Serialize() function with the following line:


    ((CEditView*)m_viewList.GetHead())->SerializeRaw(ar);



    (Source: "The MFC Answer Book" by Eugene Kain.)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Viewing header files in MS VC++
    By babu in forum C Programming
    Replies: 3
    Last Post: 07-24-2007, 05:38 AM
  2. Viewing other files... (Not Text Files)
    By Junior89 in forum C++ Programming
    Replies: 10
    Last Post: 07-05-2007, 02:30 AM
  3. Viewing .o files
    By manutd in forum Tech Board
    Replies: 2
    Last Post: 11-18-2006, 01:50 PM
  4. Viewing .lib files
    By /Muad'Dib\ in forum C++ Programming
    Replies: 4
    Last Post: 05-27-2004, 10:46 AM
  5. printing txt files
    By baphomet in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 03-10-2002, 09:53 PM