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});

   }

}

------------------------------------------------------------------------------
Download Intel&#174; 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
Perl-Win32-GUI-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
http://perl-win32-gui.sourceforge.net/

Reply via email to