CRichEditView::Stream()
-
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
-
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
-
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
-
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
-
;) 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