Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to tell it's a text file or a rich text file in CRichEditView?

How to tell it's a text file or a rich text file in CRichEditView?

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    davilism
    wrote on last edited by
    #1

    Hi, all, I want to read text files for processing in my CRichEditView text editor. If I don't set the attribute m_bRTF to FALSE when loading, it can't read other text files besides my own. How to test for other text files?

    B 1 Reply Last reply
    0
    • D davilism

      Hi, all, I want to read text files for processing in my CRichEditView text editor. If I don't set the attribute m_bRTF to FALSE when loading, it can't read other text files besides my own. How to test for other text files?

      B Offline
      B Offline
      Bill Wilson
      wrote on last edited by
      #2

      rtf files are, of course, text files. There is nothing absolutely definitive. There are some 99.9999% tests you can use. Here is a sample of an rtf file. (it contains a string of 10 "a" characters. you could check for some of the first chars maybe "{\rtf" would be specific enough and yet general enough for all versions. I don't know if there are files with {\rft0 or {\rtf2.

      {\rtf1\ansi\ansicpg1252\uc1 \deff0\deflang1033\deflangfe1033{\fonttbl{\f0\froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman{\*\falt Times};}{\f55\froman\fcharset238\fprq2 Times New Roman CE{\*\falt Times};}
      {\f56\froman\fcharset204\fprq2 Times New Roman Cyr{\*\falt Times};}{\f58\froman\fcharset161\fprq2 Times New Roman Greek{\*\falt Times};}{\f59\froman\fcharset162\fprq2 Times New Roman Tur{\*\falt Times};}
      {\f60\froman\fcharset186\fprq2 Times New Roman Baltic{\*\falt Times};}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;
      \red255\green255\blue255;\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;\red192\green192\blue192;}{\stylesheet{
      \nowidctlpar\widctlpar\adjustright \fs20\cgrid \snext0 Normal;}{\*\cs10 \additive Default Paragraph Font;}}{\info{\title sfdsdfsdsdfsdff}{\author WilsonB5}{\operator WilsonB5}{\creatim\yr2001\mo12\dy12\hr15\min41}{\revtim\yr2001\mo12\dy12\hr15\min42}
      {\version2}{\edmins0}{\nofpages1}{\nofwords0}{\nofchars0}{\*\company }{\nofcharsws0}{\vern71}}\widowctrl\ftnbj\aenddoc\formshade\viewkind4\viewscale110\pgbrdrhead\pgbrdrfoot \fet0\sectd \linex0\endnhere\sectdefaultcl {\*\pnseclvl1
      \pnucrm\pnstart1\pnindent720\pnhang{\pntxta .}}{\*\pnseclvl2\pnucltr\pnstart1\pnindent720\pnhang{\pntxta .}}{\*\pnseclvl3\pndec\pnstart1\pnindent720\pnhang{\pntxta .}}{\*\pnseclvl4\pnlcltr\pnstart1\pnindent720\pnhang{\pntxta )}}{\*\pnseclvl5
      \pndec\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl6\pnlcltr\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl7\pnlcrm\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl8\pnlcltr\pnstart1\pnindent720\pnhang
      {\pntxtb (}{\pntxta )}}{\*\pnseclvl9\pnlcrm\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}\pard\plain \nowidctlpar\widctlpar\adjustright \fs20\cgrid {aaaaaaaaaa
      \par }}

      Hope this helps, Bill

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups