> -----Original Message-----
> From: owner-ptk@xxxxxxxxxxxxxxxxxx
> [mailto:owner-ptk@xxxxxxxxxxxxxxxxxx] On Behalf Of listmail
> Sent: May 19, 2006 8:27 AM
> To: ptk@xxxxxxxxxxxxxxxxxx
> Subject: MainWindow focus
>
> Pardon me for the lack of better terminology. I need to
> determine from within a Tk application if it is currently the
> top level task/process in Windows. I suppose I mean that
> MainWindow is currently focused instead of any other windows
> application. I am not finding a method that I could use such
> as in Tk:Widget. Is this something that needs/can be
> acheived with an API call?
###################################################
use Tk;
use Win32::API;
use strict;
my $fgwindow='';
my $mw=tkinit;
my $label = $mw->Label(-textvariable=>\$fgwindow)->pack;
$mw->Button(-command=>sub{$mw->destroy},-text=>'Quit')->pack;
$mw->idletasks; #necessary on win32 to get decorative frame
my $ID = hex($mw->frame);
my $API = new Win32::API('user32','GetForegroundWindow','', 'N');
$mw->repeat(500,\&getFgWindow);
MainLoop;
sub getFgWindow {
my $handle = $API->Call;
if ($handle == $ID) {
$fgwindow = "Tk Window has focus";
}
else {
$fgwindow = $handle;
}
}
###################################################
--
Jack
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server. If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to majordomo@xxxxxxxxxxxxxxxxxx
|