Jeremy Blonde wrote:
> 
> Here's how I'm doing it.  The code is borrowed from someone else, perhaps
> Aldo's examples.
> 
> $SCR_WIDTH  = Win32::GUI::GetSystemMetrics(0);
> $SCR_HEIGHT = Win32::GUI::GetSystemMetrics(1);
> 
> $WIDTH  = 350;    # Window Width
> $HEIGHT = 250;    # Window Height
> 
> $LEFT = ($SCR_WIDTH/2) - ($WIDTH}/2);
> $TOP = ($SCR_HEIGHT/2) - ($HEIGHT}/2);
> 
> jb

Here's another way to do it.  The above code centers on the physical
window; the following code on the "logical" window after subtracting the
taskbar, application toolbars, etc.   Neither the above nor the below
code is adequate for multiple monitor support, as both assume the
primary display monitor.

#####################################
sub get_work_area;  # version 2002/03/22
{ my ( $gSystemParametersInfo );

  sub get_work_area
  { unless ( defined $gSystemParametersInfo )
    { $gSystemParametersInfo = new Win32::API ( 'user32',
        'SystemParametersInfo',
        [ 'I', 'I', 'P', 'I' ], 'I' );
    }
    my ( $rect ) = pack ( "LLLL", 0, 0, 0, 0 );
    $gSystemParametersInfo->Call ( 48, 0, $rect, 0 );
    return unpack ( "LLLL", $rect );
  }
}
#####################################
( $left, $top, $right, $bottom ) = & call_get_work_area ();
$winwid = 600;
$winheight = 400;

$mw = Win32::GUI::Window->new ( -name => 'mw', -text => 'application',
  -width => $winwid, -height => winheight,
  -left => $left + ( $right - $left - $winwid ) / 2,
  -top => $top + ( $bottom - $top - $winheight ) / 2 );

-- 
Glenn
=====
Remember, 84.3% of all statistics are made up on the spot.

Reply via email to