Error writing RTF to clipboard
Brought to you by:
apnadkarni
In TWAPI 5.1.0 running with Tcl 9.0.2 on Windows 11, writing RTF to the clipboard generates the following error:
Unsupported format 49311.
The following script demonstrates the error:
package require twapi
set RTF {
{\rtf1\ansi
{\fonttbl
{\f0 Segoe UI;}
}
{\colortbl
\red0\green0\blue0;
\red255\green255\blue255;
}
\ql\f0\fs20 \cf0\cb1\chcbpat1 Hello, World!}
}
::twapi::open_clipboard
::twapi::empty_clipboard
set format [::twapi::register_clipboard_format "Rich Text Format"]
::twapi::write_clipboard $format $RTF
::twapi::close_clipboard
Version 5.0.2 and 4.7.2 work as expected.
Anonymous
You need to now call clipboard_format_uses_global_heap passing it the format before the first call to read/write_clipboard. The reason for the change is at noted at https://github.com/apnadkarni/twapi/issues/16.
That worked great. Thanks!