in reply to Urgent query : PERL/Tk
Well, this isn't exactly what you're looking for, but it's close. It's somewhat similar to one of the postings in the suggested thread, but simpler.
use Tk; my $mw = MainWindow->new; my $toplevel = $mw->Toplevel; $toplevel->transient($mw); MainLoop;
You can also use overrideredirect as suggested in the thread but you will lose all window decorations, and will be forced to do something like this to move the window around:
use strict; use Tk; my $mw = MainWindow->new; $mw->overrideredirect(1); my $frame = $mw->Frame-> pack(-padx => 20, -pady => 20); $frame->Button( -text => 'Exit', -command => sub { Tk::exit } )->pack; my ($lastX, $lastY); $mw->bind('<Button1-Motion>', [\&MoveWindow, Ev('X'), Ev('Y'), \$lastX, \$lastY]); $mw->bind('<ButtonRelease-1>', [\&ClearCoords, \$lastX, \$lastY]); MainLoop; sub ClearCoords { my ($cw, $xSR, $ySR) = @_; undef($$xSR); undef($$ySR); } sub MoveWindow { my ($mw, $rootX, $rootY, $xSR, $ySR) = @_; if (!defined($$xSR) && !defined($$ySR)) { $$xSR = $rootX; $$ySR = $rootY; } else { my $xDiff = $rootX - $$xSR; my $yDiff = $rootY - $$ySR; my $x = $mw->x + $xDiff; my $y = $mw->y + $yDiff; $x = "+".$x if $x >= 0; $y = "+".$y if $y >= 0; $mw->geometry(sprintf("%dx%d%s%s", $mw->width, $mw->height, $x, $y )); $$xSR = $rootX; $$ySR = $rootY; } }
If you are working in a Win32 environment only, you might consider checking out Win32::GUI. What you're looking to do is fairly easy using it.
Rob
|
|---|