use Tk; use Win32::API; ... # Windows constants my ($OnTop, $NoTop, $Top) = (-1, -2, 0); my ($SWP_NOMOVE, $SWP_NOSIZE) = (2, 1); # 'always on top' state my $isOnTop = $NoTop; ... # Create a Win32::API object for SetWindowPos my $SetWindowPos = new Win32::API("user32", "SetWindowPos", [N,N,N,N,N,N,N], N); # and one for FindWindow my $FindWindow = new Win32::API("user32", "FindWindow", [P,P], N); ... my $w = new MainWindow; ... my $aotCBut = $w->Checkbutton(-text => "Always on top", -onvalue => $OnTop, -offvalue => $NoTop, -variable => \$isOnTop, -command => sub { # get a handle to the toplevel window containing our Perl/Tk app my $class = "TkTopLevel"; my $name = $w->title; my $NULL = 0; my $topHwnd = $FindWindow->Call($class, $name); if ($topHwnd != $NULL) { # change 'always on top' state $SetWindowPos->Call($topHwnd, $isOnTop, 0, 0, 0, 0, $SWP_NOMOVE | $SWP_NOSIZE); }; }) ->pack(-side => "bottom", expand => "yes", -fill => "x"); ... # start the UI MainLoop;