GUI/Maximum window dimensions: Difference between revisions
Content added Content deleted
(→{{header|Lua}}: added Lua solution) |
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
||
Line 22: | Line 22: | ||
{{libheader|GTK}} |
{{libheader|GTK}} |
||
{{libheader|GtkAda}} |
{{libheader|GtkAda}} |
||
< |
<syntaxhighlight lang="ada">with Gtk.Main; |
||
with Glib; |
with Glib; |
||
with Gtk.Window; use Gtk.Window; |
with Gtk.Window; use Gtk.Window; |
||
Line 48: | Line 48: | ||
New_Line; |
New_Line; |
||
Hid := Gtk.Main.Quit_Add_Destroy (0, Win); |
Hid := Gtk.Main.Quit_Add_Destroy (0, Win); |
||
end Max_Size;</ |
end Max_Size;</syntaxhighlight> |
||
Output (on a 1280 x 800 screen with Windows XP): |
Output (on a 1280 x 800 screen with Windows XP): |
||
<pre>Maximum dimensions of window : W 1280 x H 734 |
<pre>Maximum dimensions of window : W 1280 x H 734 |
||
Line 56: | Line 56: | ||
This is a modified example taken from the AutoHotkey documentation for the [http://ahkscript.org/docs/commands/SysGet.htm SysGet] command. |
This is a modified example taken from the AutoHotkey documentation for the [http://ahkscript.org/docs/commands/SysGet.htm SysGet] command. |
||
Also, the built in variables [http://ahkscript.org/docs/Variables.htm#Screen A_ScreenHeight] and [http://ahkscript.org/docs/Variables.htm#Screen A_ScreenWidth] contain the width and height of the primary monitor, in pixels. |
Also, the built in variables [http://ahkscript.org/docs/Variables.htm#Screen A_ScreenHeight] and [http://ahkscript.org/docs/Variables.htm#Screen A_ScreenWidth] contain the width and height of the primary monitor, in pixels. |
||
< |
<syntaxhighlight lang="autohotkey">SysGet, MonitorCount, MonitorCount |
||
SysGet, MonitorPrimary, MonitorPrimary |
SysGet, MonitorPrimary, MonitorPrimary |
||
MsgBox, Monitor Count:`t%MonitorCount%`nPrimary Monitor:`t%MonitorPrimary% |
MsgBox, Monitor Count:`t%MonitorCount%`nPrimary Monitor:`t%MonitorPrimary% |
||
Line 70: | Line 70: | ||
. "`nRight:`t" MonitorRight " (" MonitorWorkAreaRight " work)" |
. "`nRight:`t" MonitorRight " (" MonitorWorkAreaRight " work)" |
||
. "`nBottom:`t" MonitorBottom " (" MonitorWorkAreaBottom " work)" |
. "`nBottom:`t" MonitorBottom " (" MonitorWorkAreaBottom " work)" |
||
}</ |
}</syntaxhighlight> |
||
'''Output:''' |
'''Output:''' |
||
<pre>Monitor Count: 1 |
<pre>Monitor Count: 1 |
||
Line 88: | Line 88: | ||
=={{header|BaCon}}== |
=={{header|BaCon}}== |
||
Requires BaCon version 4.0.1 or higher, using GTK3. |
Requires BaCon version 4.0.1 or higher, using GTK3. |
||
< |
<syntaxhighlight lang="bacon">OPTION GUI TRUE |
||
PRAGMA GUI gtk3 |
PRAGMA GUI gtk3 |
||
Line 115: | Line 115: | ||
gui = Define_Window() |
gui = Define_Window() |
||
ALARM Print_Dimensions, 500 |
ALARM Print_Dimensions, 500 |
||
event$ = GUIEVENT$(gui)</ |
event$ = GUIEVENT$(gui)</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Result when executed using my 1600x900 screen: |
Result when executed using my 1600x900 screen: |
||
Line 122: | Line 122: | ||
=={{header|BBC BASIC}}== |
=={{header|BBC BASIC}}== |
||
{{works with|BBC BASIC for Windows}} |
{{works with|BBC BASIC for Windows}} |
||
< |
<syntaxhighlight lang="bbcbasic"> SPI_GETWORKAREA = 48 |
||
DIM rc{l%,t%,r%,b%} |
DIM rc{l%,t%,r%,b%} |
||
SYS "SystemParametersInfo", SPI_GETWORKAREA, 0, rc{}, 0 |
SYS "SystemParametersInfo", SPI_GETWORKAREA, 0, rc{}, 0 |
||
PRINT "Maximum width = " ; rc.r% - rc.l% |
PRINT "Maximum width = " ; rc.r% - rc.l% |
||
PRINT "Maximum height = " ; rc.b% - rc.t%</ |
PRINT "Maximum height = " ; rc.b% - rc.t%</syntaxhighlight> |
||
'''Output:''' |
'''Output:''' |
||
<pre> |
<pre> |
||
Line 136: | Line 136: | ||
===Windows=== |
===Windows=== |
||
The following implementation has been tested on Windows 8.1, may not work on Linux systems. |
The following implementation has been tested on Windows 8.1, may not work on Linux systems. |
||
<syntaxhighlight lang="c"> |
|||
<lang C> |
|||
#include<windows.h> |
#include<windows.h> |
||
#include<stdio.h> |
#include<stdio.h> |
||
Line 145: | Line 145: | ||
return 0; |
return 0; |
||
} |
} |
||
</syntaxhighlight> |
|||
</lang> |
|||
Output : |
Output : |
||
<pre> |
<pre> |
||
Line 162: | Line 162: | ||
Bounds are the screen's dimensions; working area is the is the region that excludes "taskbars, docked windows, and docked tool bars" (from Framework documentation). |
Bounds are the screen's dimensions; working area is the is the region that excludes "taskbars, docked windows, and docked tool bars" (from Framework documentation). |
||
< |
<syntaxhighlight lang="csharp">using System; |
||
using System.Drawing; |
using System.Drawing; |
||
using System.Windows.Forms; |
using System.Windows.Forms; |
||
Line 176: | Line 176: | ||
Console.WriteLine($"Primary screen working area: {workingArea.Width}x{workingArea.Height}"); |
Console.WriteLine($"Primary screen working area: {workingArea.Width}x{workingArea.Height}"); |
||
} |
} |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 184: | Line 184: | ||
Alternatively, use the dimensions of a borderless form with WindowState set to FormWindowState.Maximized (i.e. a full-screen window that is shown above the taskbar). |
Alternatively, use the dimensions of a borderless form with WindowState set to FormWindowState.Maximized (i.e. a full-screen window that is shown above the taskbar). |
||
< |
<syntaxhighlight lang="csharp">using System; |
||
using System.Drawing; |
using System.Drawing; |
||
using System.Windows.Forms; |
using System.Windows.Forms; |
||
Line 198: | Line 198: | ||
} |
} |
||
} |
} |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 204: | Line 204: | ||
=={{header|Creative Basic}}== |
=={{header|Creative Basic}}== |
||
<syntaxhighlight lang="creative basic"> |
|||
<lang Creative Basic> |
|||
DEF Win:WINDOW |
DEF Win:WINDOW |
||
DEF Close:CHAR |
DEF Close:CHAR |
||
Line 239: | Line 239: | ||
Output: Maximum drawing area values: width is 1280 and height is 749. |
Output: Maximum drawing area values: width is 1280 and height is 749. |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Delphi}}== |
=={{header|Delphi}}== |
||
{{libheader| Winapi.Windows}} |
{{libheader| Winapi.Windows}} |
||
{{libheader| System.SysUtils}} |
{{libheader| System.SysUtils}} |
||
{{libheader| Vcl.Forms}} |
{{libheader| Vcl.Forms}} |
||
<syntaxhighlight lang="delphi"> |
|||
<lang Delphi> |
|||
unit Main; |
unit Main; |
||
Line 274: | Line 274: | ||
end; |
end; |
||
end.</ |
end.</syntaxhighlight> |
||
Resources from form: |
Resources from form: |
||
< |
<syntaxhighlight lang="delphi">object Form1: TForm1 |
||
OnCreate = FormCreate |
OnCreate = FormCreate |
||
end</ |
end</syntaxhighlight> |
||
=={{header|EGL}}== |
=={{header|EGL}}== |
||
Line 310: | Line 310: | ||
</pre> |
</pre> |
||
Usage of the Browser external type in a RuiHandler. |
Usage of the Browser external type in a RuiHandler. |
||
<syntaxhighlight lang="egl"> |
|||
<lang EGL> |
|||
browser Browser{}; |
browser Browser{}; |
||
bvh int = browser.getViewportHeight(); |
bvh int = browser.getViewportHeight(); |
||
Line 316: | Line 316: | ||
SysLib.writeStdout("ViewportHeight: " + bvh); |
SysLib.writeStdout("ViewportHeight: " + bvh); |
||
SysLib.writeStdout("ViewportWidth: " + bvw); |
SysLib.writeStdout("ViewportWidth: " + bvw); |
||
</syntaxhighlight> |
|||
</lang> |
|||
Output |
Output |
||
<pre> |
<pre> |
||
Line 325: | Line 325: | ||
=={{header|FBSL}}== |
=={{header|FBSL}}== |
||
In the graphics mode, Windows does it all automatically and displays a form that fills the entire area not obscured by the taskbar on your primary monitor: |
In the graphics mode, Windows does it all automatically and displays a form that fills the entire area not obscured by the taskbar on your primary monitor: |
||
< |
<syntaxhighlight lang="qbasic">#INCLUDE <Include\Windows.inc> |
||
ShowWindow(ME, SW_MAXIMIZE) |
ShowWindow(ME, SW_MAXIMIZE) |
||
BEGIN EVENTS |
BEGIN EVENTS |
||
END EVENTS</ |
END EVENTS</syntaxhighlight> |
||
Alternatively, one can obtain the unobscured area's dimensions using the following console script: |
Alternatively, one can obtain the unobscured area's dimensions using the following console script: |
||
< |
<syntaxhighlight lang="qbasic">#APPTYPE CONSOLE |
||
#INCLUDE <Include\Windows.inc> |
#INCLUDE <Include\Windows.inc> |
||
Line 345: | Line 345: | ||
PRINT "width = ", rc.Right - rc.Left, ", height = ", rc.Bottom - rc.Top |
PRINT "width = ", rc.Right - rc.Left, ", height = ", rc.Bottom - rc.Top |
||
PAUSE</ |
PAUSE</syntaxhighlight> |
||
A typical output for a 1680x1050 primary monitor will be: |
A typical output for a 1680x1050 primary monitor will be: |
||
Line 353: | Line 353: | ||
=={{header|FreeBASIC}}== |
=={{header|FreeBASIC}}== |
||
< |
<syntaxhighlight lang="freebasic">' FB 1.05.0 Win64 |
||
' Using SystemParametersInfo function in Win32 API |
' Using SystemParametersInfo function in Win32 API |
||
Line 371: | Line 371: | ||
Print |
Print |
||
Print "Press any key to quit" |
Print "Press any key to quit" |
||
Sleep</ |
Sleep</syntaxhighlight> |
||
Output for my machine: |
Output for my machine: |
||
{{out}} |
{{out}} |
||
Line 388: | Line 388: | ||
From with the project create a form (FMain) with the following properties set: |
From with the project create a form (FMain) with the following properties set: |
||
< |
<syntaxhighlight lang="gambas">FMain.Maximized = True |
||
FMain.Visible = False ' The form can be invisible</ |
FMain.Visible = False ' The form can be invisible</syntaxhighlight> |
||
From within the projectview, rightclick the FMain form and select Edit class from the contextmenu. This will display a form class file (FMain.class) as follows: |
From within the projectview, rightclick the FMain form and select Edit class from the contextmenu. This will display a form class file (FMain.class) as follows: |
||
< |
<syntaxhighlight lang="gambas">PUBLIC SUB _new() |
||
END |
END |
||
Line 399: | Line 399: | ||
PUBLIC SUB Form_Open() |
PUBLIC SUB Form_Open() |
||
END</ |
END</syntaxhighlight> |
||
=== Adding the form resize event === |
=== Adding the form resize event === |
||
Line 405: | Line 405: | ||
We can now add a Form_Resize() event to the class file with the necessary code to obtain the screen dimensions as follows: |
We can now add a Form_Resize() event to the class file with the necessary code to obtain the screen dimensions as follows: |
||
< |
<syntaxhighlight lang="gambas">PUBLIC SUB Form_Resize() |
||
PRINT "The maximum window size that can be used without scrolling is "; FMain.Width; " x "; FMain.Height |
PRINT "The maximum window size that can be used without scrolling is "; FMain.Width; " x "; FMain.Height |
||
END</ |
END</syntaxhighlight> |
||
=={{header|Gambas}}== |
=={{header|Gambas}}== |
||
< |
<syntaxhighlight lang="gambas">Public Sub Form_Open() |
||
Print Desktop.Width |
Print Desktop.Width |
||
Print Desktop.Height |
Print Desktop.Height |
||
End</ |
End</syntaxhighlight> |
||
Output: |
Output: |
||
<pre> |
<pre> |
||
Line 424: | Line 424: | ||
=={{header|Go}}== |
=={{header|Go}}== |
||
{{libheader|RobotGo}} |
{{libheader|RobotGo}} |
||
< |
<syntaxhighlight lang="go">package main |
||
import ( |
import ( |
||
Line 442: | Line 442: | ||
fmt.Printf("Max usable : %d x %d\n", w, h) |
fmt.Printf("Max usable : %d x %d\n", w, h) |
||
} |
} |
||
}</ |
}</syntaxhighlight> |
||
On my machine the figures are: |
On my machine the figures are: |
||
Line 451: | Line 451: | ||
=={{header|Groovy}}== |
=={{header|Groovy}}== |
||
< |
<syntaxhighlight lang="groovy">def window = java.awt.GraphicsEnvironment.localGraphicsEnvironment.maximumWindowBounds |
||
println "width: $window.width, height: $window.height"</ |
println "width: $window.width, height: $window.height"</syntaxhighlight> |
||
=={{header|Haskell}}== |
=={{header|Haskell}}== |
||
< |
<syntaxhighlight lang="haskell">import Graphics.UI.Gtk |
||
import Control.Monad (when) |
import Control.Monad (when) |
||
import Control.Monad.Trans (liftIO) |
import Control.Monad.Trans (liftIO) |
||
Line 507: | Line 507: | ||
liftIO $ putStrLn ("The inner window region is now " ++ show x ++ |
liftIO $ putStrLn ("The inner window region is now " ++ show x ++ |
||
" pixels wide and " ++ show y ++ " pixels tall.") |
" pixels wide and " ++ show y ++ " pixels tall.") |
||
return True</ |
return True</syntaxhighlight> |
||
=={{header|Icon}} and {{header|Unicon}}== |
=={{header|Icon}} and {{header|Unicon}}== |
||
Raise and query a hidden window. |
Raise and query a hidden window. |
||
< |
<syntaxhighlight lang="icon">link graphics |
||
procedure main() # Window size |
procedure main() # Window size |
||
Line 521: | Line 521: | ||
write("The display size is w=",dw,", h=",dh) |
write("The display size is w=",dw,", h=",dh) |
||
end</ |
end</syntaxhighlight> |
||
{{improve|Icon|Need to handle window borders which will vary from system to system and handle or comment on additional requirements.}} |
{{improve|Icon|Need to handle window borders which will vary from system to system and handle or comment on additional requirements.}} |
||
=={{header|IWBASIC}}== |
=={{header|IWBASIC}}== |
||
<syntaxhighlight lang="iwbasic"> |
|||
<lang IWBASIC> |
|||
DEF Win:WINDOW |
DEF Win:WINDOW |
||
DEF Close:CHAR |
DEF Close:CHAR |
||
Line 562: | Line 562: | ||
Output: Maximum drawing area values: width is 1280 and height is 749. |
Output: Maximum drawing area values: width is 1280 and height is 749. |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|J}}== |
=={{header|J}}== |
||
Line 570: | Line 570: | ||
For example: |
For example: |
||
< |
<syntaxhighlight lang="j"> (".wd 'qscreen') -&(2 3&{) (wd'pclose') ]-/".'qform',:&wd 'pc a; cc g isidraw; pshow; qchildxywh g' |
||
1348 750</ |
1348 750</syntaxhighlight> |
||
Here, we had a screen with 1366 by 768 pixels (width and height), and space for decorations subtract 18 from each of those dimensions. |
Here, we had a screen with 1366 by 768 pixels (width and height), and space for decorations subtract 18 from each of those dimensions. |
||
=={{header|Java}}== |
=={{header|Java}}== |
||
< |
<syntaxhighlight lang="java">import java.awt.*; |
||
import javax.swing.JFrame; |
import javax.swing.JFrame; |
||
Line 598: | Line 598: | ||
System.out.println("Max available: " + screenSize); |
System.out.println("Max available: " + screenSize); |
||
} |
} |
||
}</ |
}</syntaxhighlight> |
||
Output: |
Output: |
||
Line 608: | Line 608: | ||
=={{header|Julia}}== |
=={{header|Julia}}== |
||
Uses the Gtk library. |
Uses the Gtk library. |
||
< |
<syntaxhighlight lang="julia"> |
||
win = GtkWindow("hello", 100, 100) |
win = GtkWindow("hello", 100, 100) |
||
fullscreen(win) |
fullscreen(win) |
||
Line 614: | Line 614: | ||
println(width(win), " ", height(win)) |
println(width(win), " ", height(win)) |
||
destroy(win) |
destroy(win) |
||
</syntaxhighlight> |
|||
</lang> |
|||
{{output}} <pre> |
{{output}} <pre> |
||
1920 1080 |
1920 1080 |
||
Line 621: | Line 621: | ||
=={{header|Kotlin}}== |
=={{header|Kotlin}}== |
||
{{trans|Java}} |
{{trans|Java}} |
||
< |
<syntaxhighlight lang="scala">// version 1.1 |
||
import java.awt.Toolkit |
import java.awt.Toolkit |
||
Line 644: | Line 644: | ||
fun main(args: Array<String>) { |
fun main(args: Array<String>) { |
||
Test() |
Test() |
||
}</ |
}</syntaxhighlight> |
||
Sample output: |
Sample output: |
||
{{out}} |
{{out}} |
||
Line 654: | Line 654: | ||
=={{header|Lingo}}== |
=={{header|Lingo}}== |
||
< |
<syntaxhighlight lang="lingo">put _system.desktopRectList |
||
-- [rect(0, 0, 1360, 768), rect(1360, 0, 2960, 1024)]</ |
-- [rect(0, 0, 1360, 768), rect(1360, 0, 2960, 1024)]</syntaxhighlight> |
||
=={{header|Lua}}== |
=={{header|Lua}}== |
||
< |
<syntaxhighlight lang="lua">nw = require("nw") |
||
win = nw:app():window(320, 240) |
win = nw:app():window(320, 240) |
||
win:show() |
win:show() |
||
win:maximize() |
win:maximize() |
||
cw, ch = win:client_size() |
cw, ch = win:client_size() |
||
print(cw .. " x " .. ch)</ |
print(cw .. " x " .. ch)</syntaxhighlight> |
||
On a 1920 x 1080 screen.. |
On a 1920 x 1080 screen.. |
||
{{out}} |
{{out}} |
||
Line 676: | Line 676: | ||
We can read twipsX and twipsY as twips per pixel in X and Y direction |
We can read twipsX and twipsY as twips per pixel in X and Y direction |
||
<syntaxhighlight lang="m2000 interpreter"> |
|||
<lang M2000 Interpreter> |
|||
Module CheckAllMonitors { |
Module CheckAllMonitors { |
||
mode 16 ' font size |
mode 16 ' font size |
||
Line 750: | Line 750: | ||
} |
} |
||
CheckAllMonitors |
CheckAllMonitors |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Mathematica}} / {{header|Wolfram Language}}== |
=={{header|Mathematica}} / {{header|Wolfram Language}}== |
||
Example output on a 1280x1024 system. |
Example output on a 1280x1024 system. |
||
< |
<syntaxhighlight lang="mathematica">Differences@Transpose@SystemInformation["Devices"][[1, 2, 1, 1, 2]] |
||
->{{1260, 951}}</ |
->{{1260, 951}}</syntaxhighlight> |
||
=={{header|Nim}}== |
=={{header|Nim}}== |
||
Line 761: | Line 761: | ||
{{libheader|Gtk2}} |
{{libheader|Gtk2}} |
||
Getting the screen size, ignoring borders, is as easy as: |
Getting the screen size, ignoring borders, is as easy as: |
||
< |
<syntaxhighlight lang="nim">import |
||
gtk2, gdk2 |
gtk2, gdk2 |
||
Line 767: | Line 767: | ||
var w = gdk2.screen_width() |
var w = gdk2.screen_width() |
||
var h = gdk2.screen_height() |
var h = gdk2.screen_height() |
||
echo("WxH=",w,"x",h)</ |
echo("WxH=",w,"x",h)</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>WxH=1920x1080</pre> |
<pre>WxH=1920x1080</pre> |
||
But getting the real size excluding borders is more difficult, at least with Gtk. We need to draw a window at maximum size and wait enough time before asking for its size. The following program does the job: |
But getting the real size excluding borders is more difficult, at least with Gtk. We need to draw a window at maximum size and wait enough time before asking for its size. The following program does the job: |
||
< |
<syntaxhighlight lang="nim">import glib2, gtk2 |
||
proc printSize(window: PWindow): guint {.cdecl.} = |
proc printSize(window: PWindow): guint {.cdecl.} = |
||
Line 788: | Line 788: | ||
discard g_timeout_add(100, printSize, addr(window[])) |
discard g_timeout_add(100, printSize, addr(window[])) |
||
main()</ |
main()</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>W x H = 1920 x 1031</pre> |
<pre>W x H = 1920 x 1031</pre> |
||
Line 795: | Line 795: | ||
{{libheader|gintro}} |
{{libheader|gintro}} |
||
This is the translation of Gtk2 program to Gtk3 using “gintro” bindings. |
This is the translation of Gtk2 program to Gtk3 using “gintro” bindings. |
||
< |
<syntaxhighlight lang="nim">import gintro/[glib, gobject, gtk, gio] |
||
var window: ApplicationWindow |
var window: ApplicationWindow |
||
Line 822: | Line 822: | ||
let app = newApplication(Application, "Rosetta.ScreenSize") |
let app = newApplication(Application, "Rosetta.ScreenSize") |
||
discard app.connect("activate", activate) |
discard app.connect("activate", activate) |
||
discard app.run()</ |
discard app.run()</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>W x H = 1920 x 1031</pre> |
<pre>W x H = 1920 x 1031</pre> |
||
Line 828: | Line 828: | ||
===With IUP=== |
===With IUP=== |
||
{{libheader|IUP}} |
{{libheader|IUP}} |
||
< |
<syntaxhighlight lang="nim">import |
||
iup |
iup |
||
Line 849: | Line 849: | ||
#discard iup.mainloop() |
#discard iup.mainloop() |
||
iup.close()</ |
iup.close()</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>1280x800 |
<pre>1280x800 |
||
Line 859: | Line 859: | ||
=={{header|PARI/GP}}== |
=={{header|PARI/GP}}== |
||
<lang |
<syntaxhighlight lang="parigp">plothsizes()[1..2]</syntaxhighlight> |
||
=={{header|Perl}}== |
=={{header|Perl}}== |
||
==={{libheader|Perl/Tk}}=== |
==={{libheader|Perl/Tk}}=== |
||
<syntaxhighlight lang="perl"> |
|||
<lang Perl> |
|||
use strict; |
use strict; |
||
use warnings; |
use warnings; |
||
Line 872: | Line 872: | ||
return ($mw->maxsize); |
return ($mw->maxsize); |
||
} |
} |
||
</syntaxhighlight> |
|||
</lang> |
|||
get_size returns (1425,870) here. |
get_size returns (1425,870) here. |
||
Line 878: | Line 878: | ||
{{trans|Nim}} |
{{trans|Nim}} |
||
{{libheader|Phix/pGUI}} |
{{libheader|Phix/pGUI}} |
||
<!--< |
<!--<syntaxhighlight lang="phix">--> |
||
<span style="color: #008080;">include</span> <span style="color: #000000;">pGUI</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span> |
<span style="color: #008080;">include</span> <span style="color: #000000;">pGUI</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span> |
||
Line 894: | Line 894: | ||
<span style="color: #7060A8;">IupClose</span><span style="color: #0000FF;">()</span> |
<span style="color: #7060A8;">IupClose</span><span style="color: #0000FF;">()</span> |
||
<!--</ |
<!--</syntaxhighlight>--> |
||
{{Out}} |
{{Out}} |
||
<pre> |
<pre> |
||
Line 903: | Line 903: | ||
=={{header|PicoLisp}}== |
=={{header|PicoLisp}}== |
||
The following works on ErsatzLisp, the Java version of PicoLisp. |
The following works on ErsatzLisp, the Java version of PicoLisp. |
||
< |
<syntaxhighlight lang="picolisp">(let Frame (java "javax.swing.JFrame" T "Window") |
||
(java Frame 'setExtendedState |
(java Frame 'setExtendedState |
||
(java (public "javax.swing.JFrame" 'MAXIMIZED_BOTH)) ) |
(java (public "javax.swing.JFrame" 'MAXIMIZED_BOTH)) ) |
||
Line 911: | Line 911: | ||
(prinl "Width: " (java (public Size 'width))) |
(prinl "Width: " (java (public Size 'width))) |
||
(prinl "Height: " (java (public Size 'height))) ) |
(prinl "Height: " (java (public Size 'height))) ) |
||
(java Frame 'dispose) )</ |
(java Frame 'dispose) )</syntaxhighlight> |
||
Output (on a 1024x768 screen): |
Output (on a 1024x768 screen): |
||
<pre>Width: 1010 |
<pre>Width: 1010 |
||
Line 920: | Line 920: | ||
fullScreen() is the recommended approach to draw a window covering the entire screen from Processing 3.0+ onwards. The implementation below first creates a window and then prints the dimensions onto the canvas. |
fullScreen() is the recommended approach to draw a window covering the entire screen from Processing 3.0+ onwards. The implementation below first creates a window and then prints the dimensions onto the canvas. |
||
< |
<syntaxhighlight lang="java"> |
||
//Aamrun, 26th June 2022 |
//Aamrun, 26th June 2022 |
||
Line 928: | Line 928: | ||
text("Screen Height : " + str(height), 100, 100); |
text("Screen Height : " + str(height), 100, 100); |
||
text("Screen Width : " + str(width), 100, 200); |
text("Screen Width : " + str(width), 100, 200); |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|PureBasic}}== |
=={{header|PureBasic}}== |
||
< |
<syntaxhighlight lang="purebasic">If OpenWindow(0, 0, 0, 5, 5, "", #PB_Window_Maximize + #PB_Window_Invisible) |
||
maxX = WindowWidth(0) |
maxX = WindowWidth(0) |
||
maxY = WindowHeight(0) |
maxY = WindowHeight(0) |
||
CloseWindow(0) |
CloseWindow(0) |
||
MessageRequester("Result", "Maximum Window Width: " + Str(maxX) + ", Maximum Window Height: " + Str(maxY)) |
MessageRequester("Result", "Maximum Window Width: " + Str(maxX) + ", Maximum Window Height: " + Str(maxY)) |
||
EndIf</ |
EndIf</syntaxhighlight> |
||
Sample output for a screen area 1600 x 1200: |
Sample output for a screen area 1600 x 1200: |
||
<pre>Maximum Window Width: 1600, Maximum Window Height: 1181</pre> |
<pre>Maximum Window Width: 1600, Maximum Window Height: 1181</pre> |
||
=={{header|Python}}== |
=={{header|Python}}== |
||
<syntaxhighlight lang="python"> |
|||
<lang Python> |
|||
#!/usr/bin/env python3 |
#!/usr/bin/env python3 |
||
Line 952: | Line 952: | ||
font=("Helvetica", 25)).pack() # add a label and set the size to text. |
font=("Helvetica", 25)).pack() # add a label and set the size to text. |
||
root.mainloop() |
root.mainloop() |
||
</syntaxhighlight> |
|||
</lang> |
|||
Sample output for 1366 x 768 screen: |
Sample output for 1366 x 768 screen: |
||
<pre>1366 x 706</pre> |
<pre>1366 x 706</pre> |
||
=={{header|Racket}}== |
=={{header|Racket}}== |
||
< |
<syntaxhighlight lang="racket"> |
||
#lang racket/gui |
#lang racket/gui |
||
(define-values [W H] |
(define-values [W H] |
||
Line 964: | Line 964: | ||
(send f show #f)))) |
(send f show #f)))) |
||
(printf "~ax~a\n" W H) |
(printf "~ax~a\n" W H) |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Raku}}== |
=={{header|Raku}}== |
||
Line 971: | Line 971: | ||
This is kind-of a silly task. The maximum window size is going to depend on your OS, hardware, display server and graphics toolkit, not your programming language. Taken at face value, using a Linux system running an X11 display server, the maximum displayable window size is the resolution of your monitor. Basically, the size of your desktop viewport. The Raku module X11::libxdo returns the desktop viewport size for get-desktop-dimensions which is the effective maximum window size. |
This is kind-of a silly task. The maximum window size is going to depend on your OS, hardware, display server and graphics toolkit, not your programming language. Taken at face value, using a Linux system running an X11 display server, the maximum displayable window size is the resolution of your monitor. Basically, the size of your desktop viewport. The Raku module X11::libxdo returns the desktop viewport size for get-desktop-dimensions which is the effective maximum window size. |
||
<lang |
<syntaxhighlight lang="raku" line>use X11::libxdo; |
||
my $xdo = Xdo.new; |
my $xdo = Xdo.new; |
||
Line 977: | Line 977: | ||
my ($dw, $dh) = $xdo.get-desktop-dimensions( 0 ); |
my ($dw, $dh) = $xdo.get-desktop-dimensions( 0 ); |
||
say "Desktop viewport dimensions: (maximum-fullscreen size) $dw x $dh";</ |
say "Desktop viewport dimensions: (maximum-fullscreen size) $dw x $dh";</syntaxhighlight> |
||
{{out|On my system returns}} |
{{out|On my system returns}} |
||
<pre>Desktop viewport dimensions: (maximum-fullscreen size) 1920 x 1080</pre> |
<pre>Desktop viewport dimensions: (maximum-fullscreen size) 1920 x 1080</pre> |
||
Line 992: | Line 992: | ||
=={{header|Ring}}== |
=={{header|Ring}}== |
||
< |
<syntaxhighlight lang="ring"> |
||
load "guilib.ring" |
load "guilib.ring" |
||
new qApp { |
new qApp { |
||
Line 1,004: | Line 1,004: | ||
exec() |
exec() |
||
} |
} |
||
</syntaxhighlight> |
|||
</lang> |
|||
Output: |
Output: |
||
Line 1,014: | Line 1,014: | ||
IE browser uses different functions than everyone else. |
IE browser uses different functions than everyone else. |
||
So you write code for the world, and also for IE |
So you write code for the world, and also for IE |
||
< |
<syntaxhighlight lang="runbasic"> |
||
html "<INPUT TYPE='HIDDEN' id='winHigh' name='winHigh' VALUE='";winHigh;"'></input>" |
html "<INPUT TYPE='HIDDEN' id='winHigh' name='winHigh' VALUE='";winHigh;"'></input>" |
||
html "<INPUT TYPE='HIDDEN' id='winWide' name='winWide' VALUE='";winWide;"'></input>" |
html "<INPUT TYPE='HIDDEN' id='winWide' name='winWide' VALUE='";winWide;"'></input>" |
||
Line 1,048: | Line 1,048: | ||
var x = winSize(); |
var x = winSize(); |
||
//--></script> |
//--></script> |
||
"</ |
"</syntaxhighlight> |
||
=={{header|Scala}}== |
=={{header|Scala}}== |
||
< |
<syntaxhighlight lang="scala">import java.awt.{Dimension, Insets, Toolkit} |
||
import javax.swing.JFrame |
import javax.swing.JFrame |
||
Line 1,070: | Line 1,070: | ||
new MaxWindowDims |
new MaxWindowDims |
||
} |
} |
||
}</ |
}</syntaxhighlight> |
||
=={{header|Sidef}}== |
=={{header|Sidef}}== |
||
Using the Tk library: |
Using the Tk library: |
||
< |
<syntaxhighlight lang="ruby">require('Tk') |
||
func max_window_size() -> (Number, Number) { |
func max_window_size() -> (Number, Number) { |
||
Line 1,081: | Line 1,081: | ||
var (width, height) = max_window_size(); |
var (width, height) = max_window_size(); |
||
say (width, 'x', height);</ |
say (width, 'x', height);</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 1,090: | Line 1,090: | ||
=={{header|Tcl}}== |
=={{header|Tcl}}== |
||
{{libheader|Tk}} |
{{libheader|Tk}} |
||
< |
<syntaxhighlight lang="tcl">package require Tk |
||
proc maxSize {} { |
proc maxSize {} { |
||
# Need a dummy window; max window can be changed by scripts |
# Need a dummy window; max window can be changed by scripts |
||
Line 1,100: | Line 1,100: | ||
# Default max size of window is value we want |
# Default max size of window is value we want |
||
return [wm maxsize $top] |
return [wm maxsize $top] |
||
}</ |
}</syntaxhighlight> |
||
On this system, that returns <code>1440 836</code>. Further discussion of related matters, including platform limitations, is on [http://wiki.tcl.tk/10872 the Tcler's Wiki]. |
On this system, that returns <code>1440 836</code>. Further discussion of related matters, including platform limitations, is on [http://wiki.tcl.tk/10872 the Tcler's Wiki]. |
||
Line 1,109: | Line 1,109: | ||
The first method involves querying the screen dimensions and then subtracting pixels used by the frame and desktop bars: |
The first method involves querying the screen dimensions and then subtracting pixels used by the frame and desktop bars: |
||
< |
<syntaxhighlight lang="vb">TYPE syswindowstru |
||
screenheight AS INTEGER |
screenheight AS INTEGER |
||
screenwidth AS INTEGER |
screenwidth AS INTEGER |
||
Line 1,123: | Line 1,123: | ||
syswindow.screenheight=Screen.Height / Screen.TwipsPerPixelY |
syswindow.screenheight=Screen.Height / Screen.TwipsPerPixelY |
||
' Make adjustments for window decorations and menubars</ |
' Make adjustments for window decorations and menubars</syntaxhighlight> |
||
=== Method 2 === |
=== Method 2 === |
||
Line 1,139: | Line 1,139: | ||
Bounds are the screen's dimensions; working area is the is the region that excludes "taskbars, docked windows, and docked tool bars" (from Framework documentation). |
Bounds are the screen's dimensions; working area is the is the region that excludes "taskbars, docked windows, and docked tool bars" (from Framework documentation). |
||
< |
<syntaxhighlight lang="vbnet">Imports System.Drawing |
||
Imports System.Windows.Forms |
Imports System.Windows.Forms |
||
Line 1,150: | Line 1,150: | ||
Console.WriteLine($"Primary screen working area: {workingArea.Width}x{workingArea.Height}") |
Console.WriteLine($"Primary screen working area: {workingArea.Width}x{workingArea.Height}") |
||
End Sub |
End Sub |
||
End Module</ |
End Module</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 1,158: | Line 1,158: | ||
Alternatively, use the dimensions of a borderless form with WindowState set to FormWindowState.Maximized (i.e. a full-screen window that is shown above the taskbar). |
Alternatively, use the dimensions of a borderless form with WindowState set to FormWindowState.Maximized (i.e. a full-screen window that is shown above the taskbar). |
||
< |
<syntaxhighlight lang="vbnet">Imports System.Drawing |
||
Imports System.Windows.Forms |
Imports System.Windows.Forms |
||
Line 1,172: | Line 1,172: | ||
End Using |
End Using |
||
End Sub |
End Sub |
||
End Module</ |
End Module</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 1,179: | Line 1,179: | ||
=={{header|Wren}}== |
=={{header|Wren}}== |
||
{{libheader|DOME}} |
{{libheader|DOME}} |
||
< |
<syntaxhighlight lang="ecmascript">import "input" for Keyboard |
||
import "dome" for Window, Process |
import "dome" for Window, Process |
||
import "graphics" for Canvas, Color |
import "graphics" for Canvas, Color |
||
Line 1,196: | Line 1,196: | ||
static draw(alpha) {} |
static draw(alpha) {} |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 1,206: | Line 1,206: | ||
=={{header|XPL0}}== |
=={{header|XPL0}}== |
||
GetFB is a built-in function available on the Raspberry Pi that returns information about the current frame buffer. |
GetFB is a built-in function available on the Raspberry Pi that returns information about the current frame buffer. |
||
< |
<syntaxhighlight lang="xpl0">int A; |
||
[A:= GetFB; |
[A:= GetFB; |
||
Text(0, "Width = "); IntOut(0, A(0)); CrLf(0); |
Text(0, "Width = "); IntOut(0, A(0)); CrLf(0); |
||
Text(0, "Height = "); IntOut(0, A(1)); CrLf(0); |
Text(0, "Height = "); IntOut(0, A(1)); CrLf(0); |
||
]</ |
]</syntaxhighlight> |
||
{{out}} |
{{out}} |