I have a function (see below) that is part of another function that puts
one of more files into the Windows clipboard.
This function used to work with Tcl 8 and TWAPI 4.6.0.
Now with Tcl 9 and TWAPI 5.1.1 it throws the error below.
Any ideas how to fix this?
## Set the action to be performed on paths in the clipboard ("copy" or "cut").
# \param action one of the strings "copy" or "cut"
# \return
proc ::ClipboardSetAction {action} {
if {[string equal -nocase $action "copy"]} {
set hex 05000000
} elseif {[string equal -nocase $action "cut"]} {
set hex 02000000
} else {
set hex 05000000
}
set bin [binary decode hex $hex]
set id [::twapi::register_clipboard_format "Preferred DropEffect"]
::twapi::open_clipboard
::twapi::write_clipboard $id $bin
::twapi::close_clipboard
}
*** START OF ERROR MESSAGE ***
Unsupported format 49474.
*** ERROR INFO ***
Unsupported format 49474.
while executing
"error "Unsupported format $fmt.""
(procedure "_check_if_global_memory_format" line 8)
invoked from within
"_check_if_global_memory_format $fmt"
(procedure "rethrow" line 2)
invoked from within
"rethrow"
invoked from within
"trap {
_check_if_global_memory_format $fmt
# For byte arrays, string length does return correct size
# (DO NOT USE string byt..."
(procedure "_write_clipboard" line 4)
invoked from within
"_write_clipboard $fmt $data"
invoked from within
"trap {
_write_clipboard $fmt $data
} onerror {TWAPI_WIN32 1418} {
# Caller did not have clipboard open. Do it on its behalf
..."
(procedure "::twapi::write_clipboard" line 2)
invoked from within
"::twapi::write_clipboard $id $bin"
(procedure "::meshparts::ClipboardSetAction" line 12)
invoked from within
"::meshparts::ClipboardSetAction "copy""
(procedure "::meshparts::ExplorerCopy" line 7)
invoked from within
"::meshparts::ExplorerCopy"
(command bound to event)
*** ERROR STACK ***
INNER:returnImm {Unsupported format 49474.} {} CALL:_check_if_global_memory_format 49474
CALL:_write_clipboard 49474
See https://sourceforge.net/p/twapi/bugs/224/.
On 9/19/2025 12:11 PM, meshparts wrote:
I have a function (see below) that is part of another function that
puts one of more files into the Windows clipboard.
This function used to work with Tcl 8 and TWAPI 4.6.0.
Now with Tcl 9 and TWAPI 5.1.1 it throws the error below.
Any ideas how to fix this?
## Set the action to be performed on paths in the clipboard ("copy" or
"cut").
# \param action one of the strings "copy" or "cut"
# \return
proc ::ClipboardSetAction {action} {
if {[string equal -nocase $action "copy"]} {
set hex 05000000
} elseif {[string equal -nocase $action "cut"]} {
set hex 02000000
} else {
set hex 05000000
}
set bin [binary decode hex $hex]
set id [::twapi::register_clipboard_format "Preferred DropEffect"]
::twapi::open_clipboard
::twapi::write_clipboard $id $bin
::twapi::close_clipboard
}
*** START OF ERROR MESSAGE ***
Unsupported format 49474.
*** ERROR INFO ***
Unsupported format 49474.
while executing
"error "Unsupported format $fmt.""
(procedure "_check_if_global_memory_format" line 8)
invoked from within
"_check_if_global_memory_format $fmt"
(procedure "rethrow" line 2)
invoked from within
"rethrow"
invoked from within
"trap {
_check_if_global_memory_format $fmt
# For byte arrays, string length does return correct size >> # (DO NOT USE string byt..."
(procedure "_write_clipboard" line 4)
invoked from within
"_write_clipboard $fmt $data"
invoked from within
"trap {
_write_clipboard $fmt $data
} onerror {TWAPI_WIN32 1418} {
# Caller did not have clipboard open. Do it on its behalf >> ..."
(procedure "::twapi::write_clipboard" line 2)
invoked from within
"::twapi::write_clipboard $id $bin"
(procedure "::meshparts::ClipboardSetAction" line 12)
invoked from within
"::meshparts::ClipboardSetAction "copy""
(procedure "::meshparts::ExplorerCopy" line 7)
invoked from within
"::meshparts::ExplorerCopy"
(command bound to event)
*** ERROR STACK ***
INNER:returnImm {Unsupported format 49474.} {}
CALL:_check_if_global_memory_format 49474
CALL:_write_clipboard 49474
Sysop: | DaiTengu |
---|---|
Location: | Appleton, WI |
Users: | 1,072 |
Nodes: | 10 (0 / 10) |
Uptime: | 129:28:08 |
Calls: | 13,772 |
Files: | 186,986 |
D/L today: |
263 files (120M bytes) |
Messages: | 2,429,796 |