xtd 0.2.0
xtd::forms::screen Class Reference

Definition

Represents a display device or multiple display devices on a single system.

Header
#include <xtd/forms/screen>
Namespace
xtd::forms
Library
xtd.forms
Remarks
The constructor for this object is not public, so you cannot explicitly create a screen object. The object is created when you call its public methods.
Examples
The following code example demonstrates the use of screen class.
#include <xtd/forms/application>
#include <xtd/forms/form>
using namespace xtd::forms;
auto main()->int {
form form1;
form1.location(area.location());
form1.size({area.size().width() / 2, area.size().height() / 2});
form1.text("screen 1/4");
form1.visible(true);
form form2;
form2.location({area.location().x() + area.size().width() / 2, area.location().y()});
form2.size({area.size().width() / 2, area.size().height() / 2});
form2.text("screen 2/4");
form2.visible(true);
form form3;
form3.location({area.location().x(), area.location().y() + area.size().height() / 2});
form3.size({area.size().width() / 2, area.size().height() / 2});
form3.text("screen 3/4");
form3.visible(true);
form form4;
form4.location({area.location().x() + area.size().width() / 2, area.location().y() + area.size().height() / 2});
form4.size({area.size().width() / 2, area.size().height() / 2});
form4.text("screen 4/4");
form4.visible(true);
}
Examples
The following code example shows how to get screen informations of screen component.
#include <xtd/drawing/colors>
#include <xtd/forms/application>
#include <xtd/forms/form>
#include <xtd/forms/screen>
#include <xtd/forms/text_box>
using namespace xtd;
using namespace xtd::drawing;
using namespace xtd::forms;
class main_form : public form {
public:
main_form() {
back_color(colors::dark_blue());
client_size({450, 300});
fore_color(colors::yellow());
text("Screen informations example");
screen_informations_text_box.dock(dock_style::fill);
screen_informations_text_box.multiline(true);
screen_informations_text_box.parent(*this);
screen_informations_text_box.read_only(true);
screen_informations_text_box.word_wrap(false);
screen_informations_text_box.append_text(ustring::format("Number of screens: {}{}", screen::all_screens().size(), environment::new_line()));
screen_informations_text_box.append_text(ustring::format("Standard pixels per inch: {}{}", screen::get_standard_pixels_per_inch(), environment::new_line()));
auto index = 1;
for (auto screen : screen::all_screens()) {
screen_informations_text_box.append_text(environment::new_line());
screen_informations_text_box.append_text(ustring::format("Screen: {}\n", index, environment::new_line()));
screen_informations_text_box.append_text(ustring::format(" Device name: {}{}", screen.device_name(), environment::new_line()));
screen_informations_text_box.append_text(ustring::format(" Bounds: {}{}", screen.bounds(), environment::new_line()));
screen_informations_text_box.append_text(ustring::format(" High resolution: {}{}", screen.high_resolution(), environment::new_line()));
screen_informations_text_box.append_text(ustring::format(" working area: {}{}", screen.working_area(), environment::new_line()));
screen_informations_text_box.append_text(ustring::format(" Primary: {}{}", screen.primary(), environment::new_line()));
screen_informations_text_box.append_text(ustring::format(" Bits per pixels (Depth): {}{}", screen.bits_per_pixel(), environment::new_line()));
screen_informations_text_box.append_text(ustring::format(" Pixels per Inch (PPI): {}{}", screen.pixels_per_inch(), environment::new_line()));
screen_informations_text_box.append_text(ustring::format(" Scale factor: {}{}", screen.scale_factor()));
++index;
}
}
private:
text_box screen_informations_text_box;
};
auto main()->int {
}
Examples:
screen_informations.cpp.

Properties

static std::vector< screenall_screens ()
 Gets an array of all displays on the system. More...
 
static screen primary_screen ()
 Gets the primary display. More...
 
int32 bits_per_pixel () const noexcept
 Gets the number of bits of memory, associated with one pixel of data. More...
 
const drawing::rectanglebounds () const noexcept
 Gets the bounds of the display. More...
 
const xtd::ustringdevice_name () const
 Gets the device name associated with a display. More...
 
bool high_resolution () const noexcept
 Gets a value indicating whether a particular display is high resolution. More...
 
int32 pixels_per_inch () const noexcept
 Gets the number of pixels per inch of the display. More...
 
bool primary () const noexcept
 Gets a value indicating whether a particular display is the primary device. More...
 
double scale_factor () const noexcept
 Gets the scale factor of the display. More...
 
const drawing::rectangleworking_area () const noexcept
 Gets the working area of the display. The working area is the desktop area of the display, excluding taskbars, docked windows, and docked tool bars. More...
 

Methods

static drawing::graphics create_graphics ()
 Creates the xtd::drawing::graphics for the screen. More...
 
static screen from_control (const control &control)
 Retrieves a screen for the display that contains the largest portion of the specified control. More...
 
static screen from_handle (intptr handle)
 Retrieves a screen for the display that contains the largest portion of the object referred to by the specified handle. More...
 
static screen from_point (const drawing::point &point)
 Retrieves a screen for the display that contains the specified point. More...
 
static screen from_rectangle (const drawing::rectangle &rect)
 Retrieves a screen for the display that contains the largest portion of the rectangle. More...
 
static drawing::rectangle get_bounds (const control &control)
 Retrieves the bounds of the display that contains the largest portion of the specified control. More...
 
static drawing::rectangle get_bounds (intptr handle)
 Retrieves the bounds of the display that contains the largest portion of the specified handle. More...
 
static drawing::rectangle get_bounds (const drawing::point &point)
 Retrieves the bounds of the display that contains the specified point. More...
 
static drawing::rectangle get_bounds (const drawing::rectangle &rect)
 Retrieves the bounds of the display that contains the largest portion of the specified rectangle. More...
 
static int32 get_standard_pixels_per_inch ()
 Gets the the standard number of pixels per inch of the display. More...
 
static drawing::rectangle get_working_area (const control &control)
 Retrieves the working area for the display that contains the largest region of the specified control. The working area is the desktop area of the display, excluding taskbars, docked windows, and docked tool bars. More...
 
static drawing::rectangle get_working_area (intptr handle)
 Retrieves the working area for the display that contains the largest region of the specified handle. The working area is the desktop area of the display, excluding taskbars, docked windows, and docked tool bars. More...
 
static drawing::rectangle get_working_area (const drawing::point &point)
 Retrieves the working area closest to the specified point. The working area is the desktop area of the display, excluding taskbars, docked windows, and docked tool bars. More...
 
static drawing::rectangle get_working_area (const drawing::rectangle &rect)
 Retrieves the working area for the display that contains the largest portion of the specified rectangle. The working area is the desktop area of the display, excluding taskbars, docked windows, and docked tool bars. More...
 

Additional Inherited Members

- Public Member Functions inherited from xtd::object
 object ()=default
 Create a new instance of the ultimate base class object. More...
 
bool equals (const object &obj) const noexcept
 Determines whether the specified object is equal to the current object. More...
 
virtual size_t get_hash_code () const noexcept
 Serves as a hash function for a particular type. More...
 
virtual type_object get_type () const noexcept
 Gets the type of the current instance. More...
 
template<typename object_t >
std::unique_ptr< object_t > memberwise_clone () const noexcept
 Creates a shallow copy of the current object. More...
 
virtual xtd::ustring to_string () const noexcept
 Returns a sxd::ustring that represents the current object. More...
 
- Static Public Member Functions inherited from xtd::object
static bool equals (const object &object_a, const object &object_b) noexcept
 Determines whether the specified object instances are considered equal. More...
 
static bool reference_equals (const object &object_a, const object &object_b) noexcept
 Determines whether the specified object instances are the same instance. More...
 

Member Function Documentation

◆ all_screens()

static std::vector<screen> xtd::forms::screen::all_screens ( )
static

Gets an array of all displays on the system.

Returns
An array of type screen, containing all displays on the system.

◆ bits_per_pixel()

int32 xtd::forms::screen::bits_per_pixel ( ) const
noexcept

Gets the number of bits of memory, associated with one pixel of data.

Returns
The number of bits of memory, associated with one pixel of data.
Remarks
Typically, the number of bits per pixel for a screen is useful when working with bitmaps.
Examples:
screen_informations.cpp.

◆ bounds()

const drawing::rectangle& xtd::forms::screen::bounds ( ) const
noexcept

Gets the bounds of the display.

Returns
A xtd::drawing::rectangle, representing the bounds of the display.
Examples:
screen_informations.cpp.

◆ device_name()

const xtd::ustring& xtd::forms::screen::device_name ( ) const

Gets the device name associated with a display.

Returns
The device name associated with a display.
Remarks
This string may contain non-printable characters.
Examples:
screen_informations.cpp.

◆ high_resolution()

bool xtd::forms::screen::high_resolution ( ) const
noexcept

Gets a value indicating whether a particular display is high resolution.

Returns
true if this display is high resolution; otherwise, false.
Examples:
screen_informations.cpp.

◆ pixels_per_inch()

int32 xtd::forms::screen::pixels_per_inch ( ) const
noexcept

Gets the number of pixels per inch of the display.

Returns
The number of pixels per inch of the display.
Remarks
See get_standard_pixels_per_inch() for more informations.
Examples:
screen_informations.cpp.

◆ primary()

bool xtd::forms::screen::primary ( ) const
noexcept

Gets a value indicating whether a particular display is the primary device.

Returns
true if this display is primary; otherwise, false.
Examples:
screen_informations.cpp.

◆ primary_screen()

static screen xtd::forms::screen::primary_screen ( )
static

Gets the primary display.

Returns
The primary display.
Remarks
For a single display system, the primary display is the only display.
Examples:
screen.cpp.

◆ scale_factor()

double xtd::forms::screen::scale_factor ( ) const
noexcept

Gets the scale factor of the display.

Returns
The scale factor of the display.
Remarks
This value is computed from pixels_per_inch() for the display divided by get_standard_pixels_per_inch().
If scale factor is equal to 1.0 is a standard display; greater than 1.0 is a high DPI display.
See get_standard_pixels_per_inch() for more informations.
Examples:
screen_informations.cpp.

◆ working_area()

const drawing::rectangle& xtd::forms::screen::working_area ( ) const
noexcept

Gets the working area of the display. The working area is the desktop area of the display, excluding taskbars, docked windows, and docked tool bars.

Returns
A xtd::drawing::rectangle, representing the working area of the display.
Remarks
The working area is the desktop area of the display, excluding taskbars, docked windows, and docked tool bars.
working_area will return the entire area of the screen if the Windows Taskbar is set to Auto-Hide, no matter whether the Taskbar is currently displayed or not.
Examples:
screen.cpp, and screen_informations.cpp.

The documentation for this class was generated from the following file: