GUI/Maximum window dimensions: Difference between revisions

(→‎{{header|Visual Basic .NET}}: Linked to existing pages for libraries)
Line 116:
Dimensions of the screen are (w x h) : 1536 x 864 pixels
</pre>
 
=={{header|C sharp}}==
{{trans|Visual Basic .NET}}
'''Compiler:''' Roslyn C# (language version >= 6)
{{works with|.NET Framework|4.7.2}} (simple enough that it should probably work on every Framework version--.NET Core 3.0 will support Windows Forms on Windows only)
Must be referenced:
<!--Wrap in a span with display:flex to remove libheader's line break-->
<span style="display:flex">{{libheader|GDI+}}<span style="white-space:pre"> (managed interface) [System.Drawing]</span></span>
<span style="display:flex">{{libheader|Windows Forms}}<span style="white-space:pre"> [System.Windows.Forms]</span></span>
 
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).
 
<lang csharp>using System;
using System.Drawing;
using System.Windows.Forms;
 
static class Program
{
static void Main()
{
Rectangle bounds = Screen.PrimaryScreen.Bounds;
Console.WriteLine($"Primary screen bounds: {bounds.Width}x{bounds.Height}");
 
Rectangle workingArea = Screen.PrimaryScreen.WorkingArea;
Console.WriteLine($"Primary screen working area: {workingArea.Width}x{workingArea.Height}");
}
}</lang>
 
{{out}}
<pre>Primary screen bounds: 1714x1143
Primary screen working area: 1714x1103</pre>
 
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).
 
<lang csharp>using System;
using System.Drawing;
using System.Windows.Forms;
 
static class Program
{
static void Main()
{
using (var f = new Form() { FormBorderStyle = FormBorderStyle.None, WindowState = FormWindowState.Maximized })
{
f.Show();
Console.WriteLine($"Size of maximized borderless form: {f.Width}x{f.Height}");
}
}
}</lang>
 
{{out}}
<pre>Size of maximized borderless form: 1714x1143</pre>
 
=={{header|Creative Basic}}==
Anonymous user