JamesNC has asked for the wisdom of the Perl Monks concerning the following question:

Win32 Perl 5.8 Tk 800.024
The following code demonstrates drag drop from a remote source. If you drag a file over the text widget and drop, the text box will display the file name.
When the file is dropped, a callback sends a message to the console. I would like to disable that message. Does anyone know how?
use strict; use Tk; use Tk::DropSite; my $mw = tkinit; my $txt = $mw->Text(-font, ['Lucida Sans Unicode', '8'], -height, 4, - +width, 60)->pack(); my $drop = $txt->DropSite(-droptypes,'Win32', -dropcommand, [\&dropCmd +, $txt]); MainLoop; sub dropCmd { my ($widget, $selection) = @_; my $filename = $widget->SelectionGet(-selection => $selection,'STR +ING'); if (defined $filename) { $widget->insert('end', $filename."\n"); } }

Thanks,
JamesNC

Replies are listed 'Best First'.
Re: How to disable Tk DragDrop console messages?
by pg (Canon) on Nov 19, 2003 at 07:33 UTC

    I think the hope to remove that debug message alone, without modifying source code, is slight.

    But I can explain that magic number, 563, showed on the screen. That's a window message id. It is defined as a constant in winuser.h, identifier WM_DROPFILES, value 0x233, which is 563.

    It is a windows message being sent to the receiver of the drop action. If you debug your code into a little bit more detail, you will see that the message bothered you shows up, right before entering your dropCmd sub. The sequence makes sense, as once the receiver got notified by receiving that message 563, it then calls your dropCmd sub.

Re: How to disable Tk DragDrop console messages?
by doran (Deacon) on Nov 19, 2003 at 05:33 UTC
    I'm not sure (yet) what's causing the message, but you can get rid of it by redirecting or closing STDERR. Probably not The Right Answer, but it gets the job done.
      FYI, the messages are showing up on STDERR and STDIN.

      MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
      I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
      ** The third rule of perl club is a statement of fact: pod is sexy.

      I don't want to close STDERR ( which may not help anyway if the message is being sent to STDOUT which is what I kind of suspect ), but thanks
        Did you check that? I tested it and close STDERR worked for me. Still, if you (understandably) don't want to close STDERR, this won't help.
Re: How to disable Tk DragDrop console messages?
by PodMaster (Abbot) on Nov 19, 2003 at 07:46 UTC
    Hmm, I'd call this a bug. Tk::DragDrop::Win32Site is to blame.

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.