|
From: Ken S. <kl...@ps...> - 2010-03-05 20:36:51
|
Hello,
Let me preface my question by saying that I haven't used Win32::GUI very
much, so I might be missing something obvious.
I want to create a borderless window (splash screen) and have done so using
the -style option when creating the new window.
Unfortunately, this option is deprecated, and I get a message informing me
of that fact whenever I run the application.
Looking at the documentation, it appeared that I could use the -pushstyle of
-addstyle option when creating the window. However, the window has a border
when either of these options is used.
Can anyone point out the error of my ways? Actual code is below.
Thanks, Ken Slater
use strict;
use warnings;
use File::Basename;
use Getopt::Long;
use Win32::API;
use Win32::GUI();
use Win32::GUI::Constants;
use Win32::OLE('in');
my ( $runDir );
BEGIN
{
$runDir = Win32::GetFullPathName(dirname($0));
}
my ($help, %options, %overridingOptions);
$options{iniFile} = "$runDir/stayOnTop.ini";
my ($execname) = fileparse( "$0", '' );
sub usage
{
print STDERR <<USAGE;
$execname ...
USAGE
return 0;
} # end sub usage
GetOptions( "ini=s" => \$options{iniFile},
"bg=s" => \$overridingOptions{backgroundFile},
"t=i" => \$overridingOptions{timeout},
"h!" => \$help,
"help!" => \$help);
if ( $help )
{
usage;
exit 0;
}
pullSettings();
use constant wbemFlagReturnImmediately => 0x10;
use constant wbemFlagForwardOnly => 0x20;
#------------------------------------------------------------
# Get height and width of display
#------------------------------------------------------------
my $computer = ".";
my $objWMIService = Win32::OLE->GetObject
("winmgmts:\\\\$computer\\root\\CIMV2")
or die "WMI connection failed.\n";
my $colItems = $objWMIService->ExecQuery
("SELECT * FROM Win32_VideoController","WQL",
wbemFlagReturnImmediately | wbemFlagForwardOnly);
my ( $screenWidth, $screenHeight );
foreach my $objItem (in $colItems)
{
$screenWidth = $objItem->{CurrentHorizontalResolution};
$screenHeight = $objItem->{CurrentVerticalResolution};
}
#------------------------------------------------------------
# Create GUI Window
#------------------------------------------------------------
my $WS_POPUP = Win32::GUI::Constants::constant('WS_POPUP');
my $mw = Win32::GUI::Window->new(
-title => 'NOBORDER (I hope)',
-bg => 'black',
-pos => [0,0],
-size => [$screenWidth,$screenHeight],
# The -stype option was added to make borderless
# windows. Get a warning that this option is deprecated.
-style => $WS_POPUP,
#
# Neither addstyle or pushstyle seem to get rid of the border
#-addstyle => $WS_POPUP,
#-pushstyle => $WS_POPUP,
);
#------------------------------------------------------------
# Force this window to stay on top of other windows.
#------------------------------------------------------------
my $HWND_TOPMOST = Win32::GUI::Constants::constant('HWND_TOPMOST');
my $SWP_NOSIZE = Win32::GUI::Constants::constant('SWP_NOSIZE');
my $SWP_NOMOVE = Win32::GUI::Constants::constant('SWP_NOMOVE');
$mw->SetWindowPos($HWND_TOPMOST,0,0,$screenWidth,$screenHeight,
$SWP_NOSIZE|$SWP_NOMOVE);
#------------------------------------------------------------
# Set the timer to exit this application after the specified
# number of milliseconds.
#------------------------------------------------------------
$options{timeout} = 5000 unless defined($options{timeout});
my $t1 = $mw->AddTimer('T1', $options{timeout});
#------------------------------------------------------------
# Set up the image to be displayed on the screen
#------------------------------------------------------------
my $bitmap = Win32::GUI::Bitmap->new($options{backgroundFile},
0,$screenWidth,$screenHeight);
#create a label in which the bitmap will be placed
my $bitmapLabel = $mw->AddLabel(
-name => "Bitmap",
-left => 0,
-top => 0,
-width => $screenWidth,
-height => $screenHeight,
-bitmap => $bitmap,
);
#------------------------------------------------------------
# Display the window
#------------------------------------------------------------
$mw->Show();
Win32::GUI::Dialog();
#------------------------------------------------------------
# Subroutine called when timer expires
#------------------------------------------------------------
sub T1_Timer
{
exit;
}
sub pullSettings
{
local $/ = undef;
open my $INIFH, '<', $options{iniFile} or do
{
Win32::MsgBox("FATAL: Unable to open $options{iniFile}: $^E",
0, "StayOnTop.pl");
exit;
};
my $lines = <$INIFH>;
close $INIFH;
my $re = qr{<([^/][^>]+)>\s*([^<]+)};
%options = $lines =~ /$re/gs;
foreach my $key ( keys %options )
{
$options{$key} = $overridingOptions{$key}
if defined($overridingOptions{$key});
}
}
|
|
From: Kevin M. <kej...@ho...> - 2010-03-06 02:53:56
|
Ken,
Instead of using -pushstyle, you need to use -popstyle. As for the constants needed, you will need to use WS_CAPTION to remove the title bar and WS_THICKFRAME to remove the window's sizing border. Here is an example:
$splash = Win32::GUI::Window->new(
-name => 'splash',
-size => [200,200],
-popstyle => WS_CAPTION | WS_THICKFRAME,
);
__END__
There are a number of other window constants that can be used when creating a splash window. If you have the Windows SDK, you can check the documentation for a full list.
Hope this helps,
Kevin.
Date: Fri, 5 Mar 2010 14:44:24 -0500
From: kl...@ps...
To: per...@li...
Subject: [perl-win32-gui-users] Borderless Main Window
Hello,
Let me preface my question by saying that I haven’t used Win32::GUI very much, so I might be missing something obvious.
I want to create a borderless window (splash screen) and have done so using the –style option when creating the new window.
Unfortunately, this option is deprecated, and I get a message informing me of that fact whenever I run the application.
Looking at the documentation, it appeared that I could use the –pushstyle of –addstyle option when creating the window. However, the window has a border when either of these options is used.
Can anyone point out the error of my ways? Actual code is below.
Thanks, Ken Slater
use strict;
use warnings;
use File::Basename;
use Getopt::Long;
use Win32::API;
use Win32::GUI();
use Win32::GUI::Constants;
use Win32::OLE('in');
my ( $runDir );
BEGIN
{
$runDir = Win32::GetFullPathName(dirname($0));
}
my ($help, %options, %overridingOptions);
$options{iniFile} = "$runDir/stayOnTop.ini";
my ($execname) = fileparse( "$0", '' );
sub usage
{
print STDERR <<USAGE;
$execname ...
USAGE
return 0;
} # end sub usage
GetOptions( "ini=s" => \$options{iniFile},
"bg=s" => \$overridingOptions{backgroundFile},
"t=i" => \$overridingOptions{timeout},
"h!" => \$help,
"help!" => \$help);
if ( $help )
{
usage;
exit 0;
}
pullSettings();
use constant wbemFlagReturnImmediately => 0x10;
use constant wbemFlagForwardOnly => 0x20;
#------------------------------------------------------------
# Get height and width of display
#------------------------------------------------------------
my $computer = ".";
my $objWMIService = Win32::OLE->GetObject
("winmgmts:\\\\$computer\\root\\CIMV2")
or die "WMI connection failed.\n";
my $colItems = $objWMIService->ExecQuery
("SELECT * FROM Win32_VideoController","WQL",
wbemFlagReturnImmediately | wbemFlagForwardOnly);
my ( $screenWidth, $screenHeight );
foreach my $objItem (in $colItems)
{
$screenWidth = $objItem->{CurrentHorizontalResolution};
$screenHeight = $objItem->{CurrentVerticalResolution};
}
#------------------------------------------------------------
# Create GUI Window
#------------------------------------------------------------
my $WS_POPUP = Win32::GUI::Constants::constant('WS_POPUP');
my $mw = Win32::GUI::Window->new(
-title => 'NOBORDER (I hope)',
-bg => 'black',
-pos => [0,0],
-size => [$screenWidth,$screenHeight],
# The -stype option was added to make borderless
# windows. Get a warning that this option is deprecated.
-style => $WS_POPUP,
#
# Neither addstyle or pushstyle seem to get rid of the border
#-addstyle => $WS_POPUP,
#-pushstyle => $WS_POPUP,
);
#------------------------------------------------------------
# Force this window to stay on top of other windows.
#------------------------------------------------------------
my $HWND_TOPMOST = Win32::GUI::Constants::constant('HWND_TOPMOST');
my $SWP_NOSIZE = Win32::GUI::Constants::constant('SWP_NOSIZE');
my $SWP_NOMOVE = Win32::GUI::Constants::constant('SWP_NOMOVE');
$mw->SetWindowPos($HWND_TOPMOST,0,0,$screenWidth,$screenHeight,
$SWP_NOSIZE|$SWP_NOMOVE);
#------------------------------------------------------------
# Set the timer to exit this application after the specified
# number of milliseconds.
#------------------------------------------------------------
$options{timeout} = 5000 unless defined($options{timeout});
my $t1 = $mw->AddTimer('T1', $options{timeout});
#------------------------------------------------------------
# Set up the image to be displayed on the screen
#------------------------------------------------------------
my $bitmap = Win32::GUI::Bitmap->new($options{backgroundFile},
0,$screenWidth,$screenHeight);
#create a label in which the bitmap will be placed
my $bitmapLabel = $mw->AddLabel(
-name => "Bitmap",
-left => 0,
-top => 0,
-width => $screenWidth,
-height => $screenHeight,
-bitmap => $bitmap,
);
#------------------------------------------------------------
# Display the window
#------------------------------------------------------------
$mw->Show();
Win32::GUI::Dialog();
#------------------------------------------------------------
# Subroutine called when timer expires
#------------------------------------------------------------
sub T1_Timer
{
exit;
}
sub pullSettings
{
local $/ = undef;
open my $INIFH, '<', $options{iniFile} or do
{
Win32::MsgBox("FATAL: Unable to open $options{iniFile}: $^E",
0, "StayOnTop.pl");
exit;
};
my $lines = <$INIFH>;
close $INIFH;
my $re = qr{<([^/][^>]+)>\s*([^<]+)};
%options = $lines =~ /$re/gs;
foreach my $key ( keys %options )
{
$options{$key} = $overridingOptions{$key}
if defined($overridingOptions{$key});
}
}
_________________________________________________________________
Link all your email accounts and social updates with Hotmail. Find out now.
http://windowslive.ninemsn.com.au/oneinbox?ocid=T162MSN05A0710G |
|
From: Glenn M. <gwm...@gm...> - 2010-03-08 15:40:26
|
Ken, Rob May has written a module for creating splash screens that you may find useful: http://search.cpan.org/~robertmay/Win32-GUI-SplashScreen-0.04/<http://search.cpan.org/%7Erobertmay/Win32-GUI-SplashScreen-0.04/> Regards, Glenn Munroe On 5 March 2010 23:53, Kevin Marshall <kej...@ho...> wrote: > Ken, > > Instead of using -pushstyle, you need to use -popstyle. As for the > constants needed, you will need to use WS_CAPTION to remove the title bar > and WS_THICKFRAME to remove the window's sizing border. Here is an example: > > $splash = Win32::GUI::Window->new( > -name => 'splash', > -size => [200,200], > -popstyle => WS_CAPTION | WS_THICKFRAME, > ); > __END__ > > There are a number of other window constants that can be used when creating > a splash window. If you have the Windows SDK, you can check the > documentation for a full list. > > Hope this helps, > > Kevin. > > ------------------------------ > Date: Fri, 5 Mar 2010 14:44:24 -0500 > From: kl...@ps... > To: per...@li... > Subject: [perl-win32-gui-users] Borderless Main Window > > > Hello, > > Let me preface my question by saying that I haven’t used Win32::GUI very > much, so I might be missing something obvious. > > > > I want to create a borderless window (splash screen) and have done so using > the –style option when creating the new window. > > Unfortunately, this option is deprecated, and I get a message informing me > of that fact whenever I run the application. > > Looking at the documentation, it appeared that I could use the –pushstyle > of –addstyle option when creating the window. However, the window has a > border when either of these options is used. > > Can anyone point out the error of my ways? Actual code is below. > > Thanks, Ken Slater > > > > use strict; > > use warnings; > > use File::Basename; > > use Getopt::Long; > > use Win32::API; > > use Win32::GUI(); > > use Win32::GUI::Constants; > > > > use Win32::OLE('in'); > > > > my ( $runDir ); > > BEGIN > > { > > $runDir = Win32::GetFullPathName(dirname($0)); > > } > > > > my ($help, %options, %overridingOptions); > > $options{iniFile} = "$runDir/stayOnTop.ini"; > > > > > > my ($execname) = fileparse( "$0", '' ); > > > > sub usage > > { > > print STDERR <<USAGE; > > > > $execname ... > > > > USAGE > > return 0; > > } # end sub usage > > > > > > GetOptions( "ini=s" => \$options{iniFile}, > > "bg=s" => \$overridingOptions{backgroundFile}, > > "t=i" => \$overridingOptions{timeout}, > > "h!" => \$help, > > "help!" => \$help); > > if ( $help ) > > { > > usage; > > exit 0; > > } > > > > pullSettings(); > > > > use constant wbemFlagReturnImmediately => 0x10; > > use constant wbemFlagForwardOnly => 0x20; > > > > #------------------------------------------------------------ > > # Get height and width of display > > #------------------------------------------------------------ > > my $computer = "."; > > my $objWMIService = Win32::OLE->GetObject > > ("winmgmts:\\\\$computer\\root\\CIMV2") > > or die "WMI connection failed.\n"; > > my $colItems = $objWMIService->ExecQuery > > ("SELECT * FROM Win32_VideoController","WQL", > > wbemFlagReturnImmediately | wbemFlagForwardOnly); > > > > my ( $screenWidth, $screenHeight ); > > > > foreach my $objItem (in $colItems) > > { > > $screenWidth = $objItem->{CurrentHorizontalResolution}; > > $screenHeight = $objItem->{CurrentVerticalResolution}; > > } > > > > #------------------------------------------------------------ > > # Create GUI Window > > #------------------------------------------------------------ > > my $WS_POPUP = Win32::GUI::Constants::constant('WS_POPUP'); > > my $mw = Win32::GUI::Window->new( > > -title => 'NOBORDER (I hope)', > > -bg => 'black', > > -pos => [0,0], > > -size => [$screenWidth,$screenHeight], > > # The -stype option was added to make borderless > > # windows. Get a warning that this option is deprecated. > > -style => $WS_POPUP, > > # > > # Neither addstyle or pushstyle seem to get rid of the border > > #-addstyle => $WS_POPUP, > > #-pushstyle => $WS_POPUP, > > ); > > > > #------------------------------------------------------------ > > # Force this window to stay on top of other windows. > > #------------------------------------------------------------ > > my $HWND_TOPMOST = Win32::GUI::Constants::constant('HWND_TOPMOST'); > > my $SWP_NOSIZE = Win32::GUI::Constants::constant('SWP_NOSIZE'); > > my $SWP_NOMOVE = Win32::GUI::Constants::constant('SWP_NOMOVE'); > > > > $mw->SetWindowPos($HWND_TOPMOST,0,0,$screenWidth,$screenHeight, > > $SWP_NOSIZE|$SWP_NOMOVE); > > > > #------------------------------------------------------------ > > # Set the timer to exit this application after the specified > > # number of milliseconds. > > #------------------------------------------------------------ > > $options{timeout} = 5000 unless defined($options{timeout}); > > my $t1 = $mw->AddTimer('T1', $options{timeout}); > > > > #------------------------------------------------------------ > > # Set up the image to be displayed on the screen > > #------------------------------------------------------------ > > my $bitmap = Win32::GUI::Bitmap->new($options{backgroundFile}, > > 0,$screenWidth,$screenHeight); > > > > #create a label in which the bitmap will be placed > > my $bitmapLabel = $mw->AddLabel( > > -name => "Bitmap", > > -left => 0, > > -top => 0, > > -width => $screenWidth, > > -height => $screenHeight, > > -bitmap => $bitmap, > > ); > > > > #------------------------------------------------------------ > > # Display the window > > #------------------------------------------------------------ > > $mw->Show(); > > Win32::GUI::Dialog(); > > > > #------------------------------------------------------------ > > # Subroutine called when timer expires > > #------------------------------------------------------------ > > sub T1_Timer > > { > > exit; > > } > > > > sub pullSettings > > { > > local $/ = undef; > > open my $INIFH, '<', $options{iniFile} or do > > { > > Win32::MsgBox("FATAL: Unable to open $options{iniFile}: $^E", > > 0, "StayOnTop.pl"); > > exit; > > }; > > my $lines = <$INIFH>; > > close $INIFH; > > > > my $re = qr{<([^/][^>]+)>\s*([^<]+)}; > > %options = $lines =~ /$re/gs; > > > > foreach my $key ( keys %options ) > > { > > $options{$key} = $overridingOptions{$key} > > if defined($overridingOptions{$key}); > > } > > } > > ------------------------------ > Find out now. Link all your email accounts and social updates with > Hotmail. <http://windowslive.ninemsn.com.au/oneinbox?ocid=T162MSN05A0710G> > > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > Perl-Win32-GUI-Users mailing list > Per...@li... > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users > http://perl-win32-gui.sourceforge.net/ > -- Glenn |
|
From: Ken S. <kl...@ps...> - 2010-03-08 14:21:15
|
Kevin,
Thanks for the information. For some reason I had to use both -popstyle
(WS_CAPTION | WS_THICKFRAME) and -pushstyle (WS_POPUP) to get it to work.
Ken
From: Kevin Marshall [mailto:kej...@ho...]
Sent: Friday, March 05, 2010 9:54 PM
To: kl...@ps...; Perl-Win32-GUI-Users List
Subject: RE: [perl-win32-gui-users] Borderless Main Window
Ken,
Instead of using -pushstyle, you need to use -popstyle. As for the constants
needed, you will need to use WS_CAPTION to remove the title bar and
WS_THICKFRAME to remove the window's sizing border. Here is an example:
$splash = Win32::GUI::Window->new(
-name => 'splash',
-size => [200,200],
-popstyle => WS_CAPTION | WS_THICKFRAME,
);
__END__
There are a number of other window constants that can be used when creating
a splash window. If you have the Windows SDK, you can check the
documentation for a full list.
Hope this helps,
Kevin.
_____
Date: Fri, 5 Mar 2010 14:44:24 -0500
From: kl...@ps...
To: per...@li...
Subject: [perl-win32-gui-users] Borderless Main Window
Hello,
Let me preface my question by saying that I haven't used Win32::GUI very
much, so I might be missing something obvious.
I want to create a borderless window (splash screen) and have done so using
the -style option when creating the new window.
Unfortunately, this option is deprecated, and I get a message informing me
of that fact whenever I run the application.
Looking at the documentation, it appeared that I could use the -pushstyle of
-addstyle option when creating the window. However, the window has a border
when either of these options is used.
Can anyone point out the error of my ways? Actual code is below.
Thanks, Ken Slater
use strict;
use warnings;
use File::Basename;
use Getopt::Long;
use Win32::API;
use Win32::GUI();
use Win32::GUI::Constants;
use Win32::OLE('in');
my ( $runDir );
BEGIN
{
$runDir = Win32::GetFullPathName(dirname($0));
}
my ($help, %options, %overridingOptions);
$options{iniFile} = "$runDir/stayOnTop.ini";
my ($execname) = fileparse( "$0", '' );
sub usage
{
print STDERR <<USAGE;
$execname ...
USAGE
return 0;
} # end sub usage
GetOptions( "ini=s" => \$options{iniFile},
"bg=s" => \$overridingOptions{backgroundFile},
"t=i" => \$overridingOptions{timeout},
"h!" => \$help,
"help!" => \$help);
if ( $help )
{
usage;
exit 0;
}
pullSettings();
use constant wbemFlagReturnImmediately => 0x10;
use constant wbemFlagForwardOnly => 0x20;
#------------------------------------------------------------
# Get height and width of display
#------------------------------------------------------------
my $computer = ".";
my $objWMIService = Win32::OLE->GetObject
("winmgmts:\\\\$computer\\root\\CIMV2")
or die "WMI connection failed.\n";
my $colItems = $objWMIService->ExecQuery
("SELECT * FROM Win32_VideoController","WQL",
wbemFlagReturnImmediately | wbemFlagForwardOnly);
my ( $screenWidth, $screenHeight );
foreach my $objItem (in $colItems)
{
$screenWidth = $objItem->{CurrentHorizontalResolution};
$screenHeight = $objItem->{CurrentVerticalResolution};
}
#------------------------------------------------------------
# Create GUI Window
#------------------------------------------------------------
my $WS_POPUP = Win32::GUI::Constants::constant('WS_POPUP');
my $mw = Win32::GUI::Window->new(
-title => 'NOBORDER (I hope)',
-bg => 'black',
-pos => [0,0],
-size => [$screenWidth,$screenHeight],
# The -stype option was added to make borderless
# windows. Get a warning that this option is deprecated.
-style => $WS_POPUP,
#
# Neither addstyle or pushstyle seem to get rid of the border
#-addstyle => $WS_POPUP,
#-pushstyle => $WS_POPUP,
);
#------------------------------------------------------------
# Force this window to stay on top of other windows.
#------------------------------------------------------------
my $HWND_TOPMOST = Win32::GUI::Constants::constant('HWND_TOPMOST');
my $SWP_NOSIZE = Win32::GUI::Constants::constant('SWP_NOSIZE');
my $SWP_NOMOVE = Win32::GUI::Constants::constant('SWP_NOMOVE');
$mw->SetWindowPos($HWND_TOPMOST,0,0,$screenWidth,$screenHeight,
$SWP_NOSIZE|$SWP_NOMOVE);
#------------------------------------------------------------
# Set the timer to exit this application after the specified
# number of milliseconds.
#------------------------------------------------------------
$options{timeout} = 5000 unless defined($options{timeout});
my $t1 = $mw->AddTimer('T1', $options{timeout});
#------------------------------------------------------------
# Set up the image to be displayed on the screen
#------------------------------------------------------------
my $bitmap = Win32::GUI::Bitmap->new($options{backgroundFile},
0,$screenWidth,$screenHeight);
#create a label in which the bitmap will be placed
my $bitmapLabel = $mw->AddLabel(
-name => "Bitmap",
-left => 0,
-top => 0,
-width => $screenWidth,
-height => $screenHeight,
-bitmap => $bitmap,
);
#------------------------------------------------------------
# Display the window
#------------------------------------------------------------
$mw->Show();
Win32::GUI::Dialog();
#------------------------------------------------------------
# Subroutine called when timer expires
#------------------------------------------------------------
sub T1_Timer
{
exit;
}
sub pullSettings
{
local $/ = undef;
open my $INIFH, '<', $options{iniFile} or do
{
Win32::MsgBox("FATAL: Unable to open $options{iniFile}: $^E",
0, "StayOnTop.pl");
exit;
};
my $lines = <$INIFH>;
close $INIFH;
my $re = qr{<([^/][^>]+)>\s*([^<]+)};
%options = $lines =~ /$re/gs;
foreach my $key ( keys %options )
{
$options{$key} = $overridingOptions{$key}
if defined($overridingOptions{$key});
}
}
_____
Find out now. Link all your email accounts and social updates with Hotmail.
<http://windowslive.ninemsn.com.au/oneinbox?ocid=T162MSN05A0710G>
|