• 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").
      # \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 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").
       # \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 

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