Page 1 of 1

How to save RichEdit Text as file?

Posted: 21 Dec 2021 4:03
by x2060
I learned that how can load from file

Code: Select all

        B = file::readBinary("Color.rtf"),         richEditControl_ctl:setText(uncheckedConvert(string, convert(pointer, B))).
But don't know how to save a file? Can someone help me? Thank you!

Jimmy Xia

Re: How to save RichEdit Text as file?

Posted: 28 Dec 2021 21:57
by Thomas Linder Puls
It appears you can write a file like this:

Code: Select all

predicates     saveFile : (string Filaname) -> byteCount BytesWritten. clauses     saveFile(Filename) = BytesWritten :-         OS = outputStream_file::create(Filename, stream::binary),         try             Result =                 richEditControl_ctl:sendMessage(richEdit_native::em_streamout, gui_api::mkW(richEdit_native::sf_rtf),                     uncheckedConvert(gui_native::lparam, richEdit_native::editstream(OS, 0, editStreamCallback)))         finally             OS:close()         end try,         BytesWritten = gui_api::getInteger(Result).   class predicates     editStreamCallback : richEdit_native::editStreamCallback{outputStream}. clauses     editStreamCallback(OS, Buf, Count, Count) = 0 :-         OS:writeBytes(Buf, Count).

Re: How to save RichEdit Text as file?

Posted: 4 Jan 2022 3:26
by x2060
Thank you very much!