xtd 0.2.0
system_sound.cpp

This example demonstrates the use of xtd::media::system_sound component.

Windows

macOS

Gnome

#include <xtd/forms/application>
#include <xtd/forms/button>
#include <xtd/forms/button_images>
#include <xtd/forms/form>
#include <xtd/forms/horizontal_layout_panel>
#include <xtd/media/system_sounds>
#include <xtd/startup>
using namespace xtd;
using namespace xtd::forms;
using namespace xtd::media;
namespace example {
class form1 : public form {
public:
form1() {
client_size({485, 100});
controls().push_back(layout_panel);
padding(5);
text("System sound example");
layout_panel.dock(dock_style::fill);
layout_panel.controls().push_back_range({button_asterisk, button_beep, button_exclamation, button_hand, button_question});
layout_panel.control_layout_style(button_asterisk, {size_type::auto_size, true});
layout_panel.control_layout_style(button_beep, {size_type::auto_size, true});
layout_panel.control_layout_style(button_exclamation, {size_type::auto_size, true});
layout_panel.control_layout_style(button_hand, {size_type::auto_size, true});
layout_panel.control_layout_style(button_question, {size_type::auto_size, true});
button_asterisk.text("asterisk");
button_asterisk.image(button_images::from_name("dialog-information", drawing::size(64, 64)));
button_asterisk.image_align(content_alignment::top_center);
button_asterisk.text_align(content_alignment::bottom_center);
button_asterisk.click += [&] {
};
button_beep.text("beep");
button_beep.image(button_images::from_name("dialog-ok", drawing::size(64, 64)));
button_beep.image_align(content_alignment::top_center);
button_beep.text_align(content_alignment::bottom_center);
button_beep.click += [&] {
};
button_exclamation.text("exclamation");
button_exclamation.image(button_images::from_name("dialog-warning", drawing::size(64, 64)));
button_exclamation.image_align(content_alignment::top_center);
button_exclamation.text_align(content_alignment::bottom_center);
button_exclamation.click += [&] {
};
button_hand.text("hand");
button_hand.image(button_images::from_name("dialog-error", drawing::size(64, 64)));
button_hand.image_align(content_alignment::top_center);
button_hand.text_align(content_alignment::bottom_center);
button_hand.click += [&] {
};
button_question.text("question");
button_question.image(button_images::from_name("dialog-question", drawing::size(64, 64)));
button_question.image_align(content_alignment::top_center);
button_question.text_align(content_alignment::bottom_center);
button_question.click += [&] {
};
}
static auto main() {
application::run(form1 {});
}
private:
button button_asterisk;
button button_beep;
button button_exclamation;
button button_hand;
button button_question;
};
}
startup_(example::form1::main);
static void run()
Begins running a standard application message loop on the current thread, without a form.
static xtd::drawing::image from_name(const xtd::string &name)
Gets image object with specified name.
Definition button_images.hpp:193
Represents a Windows button control.
Definition button.hpp:49
Represents a window or dialog box that makes up an application's user interface.
Definition form.hpp:54
Used to group collections of horizontally aligned controls.
Definition horizontal_layout_panel.hpp:31
Represents a display device or multiple display devices on a single system.
Definition padding.hpp:25
static system_sound exclamation()
Gets the sound associated with the Exclamation program event in the current Windows sound scheme.
static system_sound beep()
Gets the sound associated with the Beep program event in the current Windows sound scheme.
static system_sound hand()
Gets the sound associated with the Hand program event in the current Windows sound scheme.
static system_sound question()
Gets the sound associated with the Question program event in the current Windows sound scheme.
static system_sound asterisk()
Gets the sound associated with the Asterisk program event in the current Windows sound scheme.
#define startup_(main_method)
Defines the entry point to be called when the application loads. Generally this is set either to the ...
Definition startup.hpp:167
@ fill
All the control's edges are docked to the all edges of its containing control and sized appropriately...
Definition dock_style.hpp:35
@ auto_size
The control should be automatically sized to share space with its peers.
Definition size_type.hpp:24
@ top_center
Content is vertically aligned at the top, and horizontally aligned at the center.
Definition content_alignment.hpp:25
@ bottom_center
Content is vertically aligned at the bottom, and horizontally aligned at the center.
Definition content_alignment.hpp:37
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition texts.hpp:217
The xtd::media namespace contains classes for playing sound files and accessing sounds provided by th...
Definition system_sound.hpp:12
Contains classes that represent ASCII and Unicode character encodings; abstract base classes for conv...
Definition basic_string_builder.hpp:16
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
Stores an ordered pair of integers, which specify a height and width.
Definition size.hpp:31