Link to home
Start Free TrialLog in
Avatar of Deon_Ball
Deon_Ball

asked on

CRichEditCtrl's StreamIn function - How do you increase the block size for repeated calls to the Stream In callback function

Example Function
DWORD CALLBACK CXRichEdit::CBStreamIn(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
{
      // We insert the rich text here.
      CString *pstr = (CString *) dwCookie;

      // cb = 4092;
      if (pstr->GetLength() < cb)
      {
            *pcb = pstr->GetLength();
            memcpy(pbBuff, (LPCSTR) *pstr, *pcb);
            pstr->Empty();
      }
      else
      {
            *pcb = cb;
            memcpy(pbBuff, (LPCSTR) *pstr, *pcb);
            *pstr = pstr->Right(pstr->GetLength() - cb);
      }

      return 0;
}

how can you increase this block size to allow faster stream in when loading large Arrays of data
Avatar of PlanetCpp
PlanetCpp

you never set it in the first place. the pass windows the address to where the data is and it returns how big of a chunk to take in. It seems to always take 4094 bytes at a time. ive never heard of being able to change this.
Avatar of Deon_Ball

ASKER


I realize that I didn't choose this block size, it's a default for the control  I asked how I can increase it!  There may be a way to do this by using the GetNewStorage() method or by creating my own global memory and pointing the rich edit control at that location.  

Word Pad can do this quickly.
ASKER CERTIFIED SOLUTION
Avatar of DanRollins
DanRollins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
hi Deon_Ball,
Do you have any additional questions?  Do any comments need clarification?
-- Dan

Execellant reply, thanks to DanRollins

I used your example and it works great
Thanks

DanRollins,

Is there an equally fast way of then writing out the contents of the RichEdit to a plain text file?  I have a 100 MB .rtf file I would like to convert to plain text, but don't know of a faster way to accomplish this than using the RichEdit control as an intermediate step.

Thanks,
Corey
cslick,
Welcome to EE.  It is best to ask your question as a new question.  In general, once a Q is closed, it is expected to remain static... the idea of "piggybacking" a new question onto an old one is definitely frowned upon.

That said, I'll go ahead with at least a partial answer...
If it is really an RTF file, incuding all of the formatting codes, then to get plain text out, I can think of no alternative to loading it as RTF and saving it as text (I have not tried that, though).  Maybe you could select it all and copy it to the clipboard and then request the TEXT representation of the clipboard data.  I expect thaat this would be a time- and resource-consuming operation.

-- Dan