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. MFC, Rich Edit HELP !!!

MFC, Rich Edit HELP !!!

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++
6 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.
  • L Offline
    L Offline
    lio
    wrote on last edited by
    #1

    Please help me, I've been trying to solve this problem for more than a week now: I have to open a textfile with a common dialog box, put this file in a buffer, then I have to show this text in a richeditcontrol by calling the buffer. Oh, yeah: these text files are at least 1MEG big and I'm just getting started with MFC, glups ! Thanks if you can help me...

    T P 2 Replies Last reply
    0
    • L lio

      Please help me, I've been trying to solve this problem for more than a week now: I have to open a textfile with a common dialog box, put this file in a buffer, then I have to show this text in a richeditcontrol by calling the buffer. Oh, yeah: these text files are at least 1MEG big and I'm just getting started with MFC, glups ! Thanks if you can help me...

      T Offline
      T Offline
      Tomasz Sowinski
      wrote on last edited by
      #2

      Check the 'Wordpad' MFC sample. Tomasz Sowinski -- http://www.shooltz.com

      L 1 Reply Last reply
      0
      • L lio

        Please help me, I've been trying to solve this problem for more than a week now: I have to open a textfile with a common dialog box, put this file in a buffer, then I have to show this text in a richeditcontrol by calling the buffer. Oh, yeah: these text files are at least 1MEG big and I'm just getting started with MFC, glups ! Thanks if you can help me...

        P Offline
        P Offline
        Per
        wrote on last edited by
        #3

        You could use SetText() or stream the text in with a callback function something like:

        DWORD CALLBACK readText(DWORD dwFileHandle, LPBYTE lpBuffer, LONG nbrToRead,
        LONG FAR* lpNbrRead)
        {
        BOOL file = ReadFile((HANDLE)dwFileHandle,lpBuffer, nbrToRead,
        (unsigned long*)lpNbrRead, NULL);

        if(file == FALSE ){
        	AfxMessageBox(\_T("Could'n open file!"),MB\_ICONEXCLAMATION);
        	return 1;
        }
        return 0;
        

        }

        and then call it with something like this:

        EDITSTREAM stream;
        HANDLE hFil;//file to open
        
        fFormat = SF\_TEXT;
        strom.dwCookie = (DWORD)hFil;
        strom.pfnCallback = readText;
        m\_recText.StreamIn( fFormat, strom );//RichEditCtrl
        

        /Per

        L 1 Reply Last reply
        0
        • T Tomasz Sowinski

          Check the 'Wordpad' MFC sample. Tomasz Sowinski -- http://www.shooltz.com

          L Offline
          L Offline
          lio
          wrote on last edited by
          #4

          Cannot open include file... Microsoft's products are perfect as always. What should I do? Lio.

          T 1 Reply Last reply
          0
          • L lio

            Cannot open include file... Microsoft's products are perfect as always. What should I do? Lio.

            T Offline
            T Offline
            Tomasz Sowinski
            wrote on last edited by
            #5

            mfc42ud.lib is not a header file - it's a library. Anyway, you should set the active configuration to non-unicode before building the sample. Tomasz Sowinski -- http://www.shooltz.com

            1 Reply Last reply
            0
            • P Per

              You could use SetText() or stream the text in with a callback function something like:

              DWORD CALLBACK readText(DWORD dwFileHandle, LPBYTE lpBuffer, LONG nbrToRead,
              LONG FAR* lpNbrRead)
              {
              BOOL file = ReadFile((HANDLE)dwFileHandle,lpBuffer, nbrToRead,
              (unsigned long*)lpNbrRead, NULL);

              if(file == FALSE ){
              	AfxMessageBox(\_T("Could'n open file!"),MB\_ICONEXCLAMATION);
              	return 1;
              }
              return 0;
              

              }

              and then call it with something like this:

              EDITSTREAM stream;
              HANDLE hFil;//file to open
              
              fFormat = SF\_TEXT;
              strom.dwCookie = (DWORD)hFil;
              strom.pfnCallback = readText;
              m\_recText.StreamIn( fFormat, strom );//RichEditCtrl
              

              /Per

              L Offline
              L Offline
              lio
              wrote on last edited by
              #6

              OK, I've had a better look at it now. I still have one question: how do I declare m_readText? Thanks in advance. Lio.

              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