Discussions related to Visual Prolog
x2060
Posts: 9
Joined: 11 Dec 2021 8:20

How to save RichEdit Text as file?

Unread post 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
User avatar
Thomas Linder Puls
VIP Member
Posts: 1395
Joined: 28 Feb 2000 0:01

Re: How to save RichEdit Text as file?

Unread post 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).
Regards Thomas Linder Puls
PDC
x2060
Posts: 9
Joined: 11 Dec 2021 8:20

Re: How to save RichEdit Text as file?

Unread post by x2060 »

Thank you very much!
Post Reply