Thread Bildschirmauflösung abfragen
(5 answers)
Opened by 1860gelb at 2013-02-24 08:49
Wenn Du Tk verwendest: screenwidth und screenheight:
Code (perl): (dl
)
1 2 3 4 use Tk; my $mw = MainWindow->new(); printf ("screenwidth: %d, screenheight: %d\n", $mw->screenwidth, $mw->screenheight); Nativ für Windows (exemplarisch mit EnumDisplaySettings, alternativ per GetDeviceCaps): Code (perl): (dl
)
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); } Last edited: 2013-02-24 10:16:31 +0100 (CET) Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it? -- Brian Kernighan: "The Elements of Programming Style"
|