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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. CRichEditView::Stream()

CRichEditView::Stream()

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++tutorial
5 Posts 3 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.
  • F Offline
    F Offline
    Frank Deo
    wrote on last edited by
    #1

    Hello, I need to open / save a txt file into a RichEditView at runtime without using the File -> Open / Save menu selections. ie. no user intervention. I'd like to use the Stream functions of the RichEditView, but I can't figure out how to call the function. Looking at the code in ViewRich.cpp I can see how its supposed to work, but it always fails. Can anyone give me any ideas? I'm not necessarily looking for the code, but rather some direction so that I can figure it out myself. ;) I've already got the filename, stored in a CFile. And, a pointer to a CArchive object. I have called: Stream(arLoad, FALSE); However, the function needs to know what the value of IsStoring() is. How do I set that? I've looked at the WordPad sample...it uses custom streamin / streamout functions. Thanks for any ideas you can give me! :confused: Frank

    B 1 Reply Last reply
    0
    • F Frank Deo

      Hello, I need to open / save a txt file into a RichEditView at runtime without using the File -> Open / Save menu selections. ie. no user intervention. I'd like to use the Stream functions of the RichEditView, but I can't figure out how to call the function. Looking at the code in ViewRich.cpp I can see how its supposed to work, but it always fails. Can anyone give me any ideas? I'm not necessarily looking for the code, but rather some direction so that I can figure it out myself. ;) I've already got the filename, stored in a CFile. And, a pointer to a CArchive object. I have called: Stream(arLoad, FALSE); However, the function needs to know what the value of IsStoring() is. How do I set that? I've looked at the WordPad sample...it uses custom streamin / streamout functions. Thanks for any ideas you can give me! :confused: Frank

      B Offline
      B Offline
      Baafie
      wrote on last edited by
      #2

      Don't use stream(). Use CRichEditDoc::OnFileSave("C:/yada.txt").

      F 1 Reply Last reply
      0
      • B Baafie

        Don't use stream(). Use CRichEditDoc::OnFileSave("C:/yada.txt").

        F Offline
        F Offline
        Frank Deo
        wrote on last edited by
        #3

        Thanks Baafie...I actually got it to work using streamin. I found an example on MSDN:

        static DWORD CALLBACK MyStreamInCallback(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
        {

        CFile\* pFile = (CFile\*) dwCookie;
        \*pcb = pFile->Read(pbBuff, cb);
        
        return 0;
        

        }

        void SomeFunctionThatLoadsAStringFromSomeFileOrSomethingLikeThat()
        {
        EDITSTREAM es;
        es.dwCookie = (DWORD) &myFile;
        es.pfnCallback = MyStreamInCallback;
        GetRichEditCtrl().StreamIn(SF_TEXT, es);
        }

        Thanks! Frank

        L 1 Reply Last reply
        0
        • F Frank Deo

          Thanks Baafie...I actually got it to work using streamin. I found an example on MSDN:

          static DWORD CALLBACK MyStreamInCallback(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
          {

          CFile\* pFile = (CFile\*) dwCookie;
          \*pcb = pFile->Read(pbBuff, cb);
          
          return 0;
          

          }

          void SomeFunctionThatLoadsAStringFromSomeFileOrSomethingLikeThat()
          {
          EDITSTREAM es;
          es.dwCookie = (DWORD) &myFile;
          es.pfnCallback = MyStreamInCallback;
          GetRichEditCtrl().StreamIn(SF_TEXT, es);
          }

          Thanks! Frank

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          You're welcome, but it doesn't look like my advice helped you out..

          F 1 Reply Last reply
          0
          • L Lost User

            You're welcome, but it doesn't look like my advice helped you out..

            F Offline
            F Offline
            Frank Deo
            wrote on last edited by
            #5

            ;) The reason I was looking to use Stream (In) is due to the fact that I am writing temp files outside the scope of my doc class. My app writes out temp data to a file for processing first...after processing it loads it back into the view for user intervention. From there a file save or print or print preview can be performed. I tried using a loop and loading the file 1 line at a time but it looked rather FREAKY. ;P MSDN had the example that worked (I love that)...unfortunately for me my subscription ran out in october and I cant afford another one. :(( Frank "Gumbercules? - I love that Guy!" - Dr. Zoidberg

            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