• TWAPI error

    From meshparts@alexandru.dadalau@meshparts.de to comp.lang.tcl on Fri Sep 19 08:41:36 2025
    From Newsgroup: comp.lang.tcl

    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 
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Ashok@apnmbx-public@yahoo.com to comp.lang.tcl on Sat Sep 20 08:05:43 2025
    From Newsgroup: comp.lang.tcl

    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").
    -a # \param action one of the strings "copy" or "cut"
    -a # \return
    proc ::ClipboardSetAction {action} {
    -a if {[string equal -nocase $action "copy"]} {
    -a-a-a set hex 05000000
    -a } elseif {[string equal -nocase $action "cut"]} {
    -a-a-a set hex 02000000
    -a } else {
    -a-a-a set hex 05000000
    -a }
    -a set bin [binary decode hex $hex]
    -a set id [::twapi::register_clipboard_format "Preferred DropEffect"]
    -a ::twapi::open_clipboard
    -a ::twapi::write_clipboard $id $bin
    -a ::twapi::close_clipboard
    }



    *** START OF ERROR MESSAGE ***
    Unsupported format 49474.
    *** ERROR INFO ***
    Unsupported format 49474.
    -a-a-a while executing
    "error "Unsupported format $fmt.""
    -a-a-a (procedure "_check_if_global_memory_format" line 8)
    -a-a-a invoked from within
    "_check_if_global_memory_format $fmt"
    -a-a-a (procedure "rethrow" line 2)
    -a-a-a invoked from within
    "rethrow"
    -a-a-a invoked from within
    "trap {
    -a-a-a-a-a-a-a _check_if_global_memory_format $fmt

    -a-a-a-a-a-a-a # For byte arrays, string length does return correct size
    -a-a-a-a-a-a-a # (DO NOT USE string byt..."
    -a-a-a (procedure "_write_clipboard" line 4)
    -a-a-a invoked from within
    "_write_clipboard $fmt $data"
    -a-a-a invoked from within
    "trap {
    -a-a-a-a-a-a-a _write_clipboard $fmt $data
    -a-a-a } onerror {TWAPI_WIN32 1418} {
    -a-a-a-a-a-a-a # Caller did not have clipboard open. Do it on its behalf
    -a-a-a-a-a ..."
    -a-a-a (procedure "::twapi::write_clipboard" line 2)
    -a-a-a invoked from within
    "::twapi::write_clipboard $id $bin"
    -a-a-a (procedure "::meshparts::ClipboardSetAction" line 12)
    -a-a-a invoked from within
    "::meshparts::ClipboardSetAction "copy""
    -a-a-a (procedure "::meshparts::ExplorerCopy" line 7)
    -a-a-a invoked from within
    "::meshparts::ExplorerCopy"
    -a-a-a (command bound to event)
    *** ERROR STACK ***
    INNER:returnImm {Unsupported format 49474.} {} CALL:_check_if_global_memory_format 49474
    CALL:_write_clipboard 49474 

    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From meshparts@alexandru.dadalau@meshparts.de to comp.lang.tcl on Sun Sep 21 12:38:04 2025
    From Newsgroup: comp.lang.tcl

    Am 20.09.2025 um 04:35 schrieb Ashok:
    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").
    -a-a # \param action one of the strings "copy" or "cut"
    -a-a # \return
    proc ::ClipboardSetAction {action} {
    -a-a if {[string equal -nocase $action "copy"]} {
    -a-a-a-a set hex 05000000
    -a-a } elseif {[string equal -nocase $action "cut"]} {
    -a-a-a-a set hex 02000000
    -a-a } else {
    -a-a-a-a set hex 05000000
    -a-a }
    -a-a set bin [binary decode hex $hex]
    -a-a set id [::twapi::register_clipboard_format "Preferred DropEffect"]
    -a-a ::twapi::open_clipboard
    -a-a ::twapi::write_clipboard $id $bin
    -a-a ::twapi::close_clipboard
    }



    *** START OF ERROR MESSAGE ***
    Unsupported format 49474.
    *** ERROR INFO ***
    Unsupported format 49474.
    -a-a-a-a while executing
    "error "Unsupported format $fmt.""
    -a-a-a-a (procedure "_check_if_global_memory_format" line 8)
    -a-a-a-a invoked from within
    "_check_if_global_memory_format $fmt"
    -a-a-a-a (procedure "rethrow" line 2)
    -a-a-a-a invoked from within
    "rethrow"
    -a-a-a-a invoked from within
    "trap {
    -a-a-a-a-a-a-a-a _check_if_global_memory_format $fmt

    -a-a-a-a-a-a-a-a # For byte arrays, string length does return correct size >> -a-a-a-a-a-a-a-a # (DO NOT USE string byt..."
    -a-a-a-a (procedure "_write_clipboard" line 4)
    -a-a-a-a invoked from within
    "_write_clipboard $fmt $data"
    -a-a-a-a invoked from within
    "trap {
    -a-a-a-a-a-a-a-a _write_clipboard $fmt $data
    -a-a-a-a } onerror {TWAPI_WIN32 1418} {
    -a-a-a-a-a-a-a-a # Caller did not have clipboard open. Do it on its behalf >> -a-a-a-a-a-a ..."
    -a-a-a-a (procedure "::twapi::write_clipboard" line 2)
    -a-a-a-a invoked from within
    "::twapi::write_clipboard $id $bin"
    -a-a-a-a (procedure "::meshparts::ClipboardSetAction" line 12)
    -a-a-a-a invoked from within
    "::meshparts::ClipboardSetAction "copy""
    -a-a-a-a (procedure "::meshparts::ExplorerCopy" line 7)
    -a-a-a-a invoked from within
    "::meshparts::ExplorerCopy"
    -a-a-a-a (command bound to event)
    *** ERROR STACK ***
    INNER:returnImm {Unsupported format 49474.} {}
    CALL:_check_if_global_memory_format 49474
    CALL:_write_clipboard 49474 

    Thanks Ashok!
    --- Synchronet 3.21a-Linux NewsLink 1.2