1 2 3 4
use Tk; my $mw = MainWindow->new(); printf ("screenwidth: %d, screenheight: %d\n", $mw->screenwidth, $mw->screenheight);
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
use warnings; use strict; use Win32::API; printf( "width: %d, height: %d, bits per pixel: %d, frequency: %d Hz\n", getDisplayMetrics() ); sub getDisplayMetrics { # per EnumDisplaySettings my $ENUM_CURRENT_SETTINGS = 0xFFFFFFFF; my $devmode = pack( "B" x 32 . "SSSSLsssssssssssss" . "B" x 32 . "SLLLLL", (0 x 32), # dmDeviceName 0, # dmSpecVersion 0, # dmDriverVersion 124, # dmSize 0, # dmDriverExtra 0, # dmFields 0, # dmOrientation 0, # dmPaperSize 0, # dmPaperLength 0, # dmPaperWidth 0, # dmScale 0, # dmCopies 0, # dmDefaultSource 0, # dmPrintQuality 0, # dmColor 0, # dmDuplex 0, # dmYResolution 0, # dmTTOption 0, # dmCollate (0 x 32), # dmFormName 0, # dmLogPixels 0, # dmBitsPerPel 0, # dmPelsWidth 0, # dmPelsHeight 0, # dmDisplayFlags 0, # dmDisplayFrequency ); my $EnumDisplaySettings = new Win32::API( "user32", "EnumDisplaySettings", "PNP", "N" ); my $res = $EnumDisplaySettings->Call(0, $ENUM_CURRENT_SETTINGS, $devmode); my ($bpp, $x, $y, undef, $hz) = unpack("x104 LLLLL", $devmode); return ($x, $y, $bpp, $hz); }
1
2
3
4
use Tk;
my $mw = MainWindow->new();
printf ("screenwidth: %d, screenheight: %d\n", $mw->screenwidth, $mw->screenheight);
1
2
3
4
5
my $breite=$mw->screenwidth;
my $hoehe=$mw->screenheight;
$my->geometry("$breitex$hoehe");