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

Greetings Monks!

I found this code on how to make a toplevel always stay on top:

use strict; use Tk; use Tk::Balloon; use Win32::API; my $mw = new MainWindow; use vars qw/$Button/; $mw->Frame(-width=>200, height =>25); $mw->update; Win32::API->new("user32","SetWindowPos",[qw(N N N N N N N)],'N')->Call(hex($mw->frame()),-1,0,0,0,0,3); $Button=$mw->Button(-text => "Button", -command => sub { &do_something; }) ->pack(); my $balloon = $mw -> Balloon(-balloonposition => 'mouse', -initwait => 10, -bg => 'white'); $balloon -> attach($Button, -balloonmsg => "Button"); MainLoop; sub do_something { #sleep(10); }

in this node, and it provided all that I needed to make my MainWindow always stay on top. However when I attach Balloon popups to the MainWindow they appear behind the MainWindow. Execute the code above for an example.

Anyone knows how to work around this?

Cheers nubb

janitored by ybiC: Prepend title with "Tk" for searchability

Replies are listed 'Best First'.
Re: Tk - always on top property 2
by PodMaster (Abbot) on Aug 28, 2003 at 08:06 UTC
Re: Tk - always on top property 2
by didier (Vicar) on Aug 28, 2003 at 12:29 UTC
    Your hexa hwnd is not the good one :)
    Here your script with a little update

    Have a nice day :)
    use Tk; use Tk::Balloon; use Win32::API; use vars qw/$Button/; my $mw = new MainWindow; $id_mw = $mw->id; $mw->Frame(-width=>200, height =>25); $mw->update; Win32::API->new("user32","SetWindowPos", [qw(N N N N N N N)],'N')->Call(hex($id_mw),-1,0,0,0,0,3); $Button=$mw->Button(-text => "Button", -command => sub { &do_something; })->pack(); my $balloon = $mw -> Balloon(-balloonposition => 'mouse', -initwait => 10, -bg => 'white'); $balloon -> attach($Button, -balloonmsg => "Button"); MainLoop; sub do_something { #sleep(10); }