xtd - Reference Guide  0.2.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
message.h
Go to the documentation of this file.
1 #pragma once
5 
6 #include <iomanip>
7 #include <sstream>
8 #include <cstdint>
9 #include <string>
10 #include <xtd/object.h>
11 #include <xtd/ustring.h>
12 #include "../forms_export.h"
13 
14 namespace xtd {
15  namespace forms {
25  class forms_export_ message : public object {
26  public:
28  message() = default;
29  message(const message& message) = default;
30  message& operator=(const message&) = default;
32 
36  intptr_t hwnd() const {return hwnd_;}
40  void hwnd(intptr_t value) {hwnd_ = value;}
41 
45  intptr_t lparam() const {return lparam_;}
49  void lparam(intptr_t value) {lparam_ = value;}
50 
53  int32_t msg() const {return msg_;}
56  void msg(int32_t value) {msg_ = value;}
57 
60  intptr_t result() const {return result_;}
63  void result(intptr_t value) {result_ = value;}
64 
68  intptr_t wparam() const {return wparam_;}
72  void wparam(intptr_t value) {wparam_ = value;}
73 
75  intptr_t handle() const {return handle_;}
76  void handle(intptr_t value) {handle_ = value;}
78 
86  static message create(intptr_t hwnd, int32_t msg, intptr_t wparam, intptr_t lparam) {return message(hwnd, msg, wparam, lparam);}
87 
89  static message create(intptr_t hwnd, int32_t msg, intptr_t wparam, intptr_t lparam, intptr_t result) {return message(hwnd, msg, wparam, lparam, result);}
90  static message create(intptr_t hwnd, int32_t msg, intptr_t wparam, intptr_t lparam, intptr_t result, intptr_t handle) {return message(hwnd, msg, wparam, lparam, result, handle);}
92 
96  template<typename type>
97  type get_lparam() { return reinterpret_cast<type>(lparam_); }
98 
101  xtd::ustring to_string() const noexcept override;
102 
104  friend std::ostream& operator<<(std::ostream& os, const xtd::forms::message& message) noexcept {
105  return os << message.to_string();
106  }
108 
109 
110  private:
111  message(intptr_t hwnd, int32_t msg, intptr_t wparam, intptr_t lparam) : hwnd_(hwnd), msg_(msg), wparam_(wparam), lparam_(lparam) {counter_++;}
112  message(intptr_t hwnd, int32_t msg, intptr_t wparam, intptr_t lparam, intptr_t result) : hwnd_(hwnd), msg_(msg), wparam_(wparam), lparam_(lparam), result_(result) {counter_++;}
113  message(intptr_t hwnd, int32_t msg, intptr_t wparam, intptr_t lparam, intptr_t result, intptr_t handle) : hwnd_(hwnd), msg_(msg), wparam_(wparam), lparam_(lparam), result_(result), handle_(handle) {counter_++;}
114 
115  intptr_t hwnd_ = 0;
116  int32_t msg_ = 0;
117  intptr_t wparam_ = 0;
118  intptr_t lparam_ = 0;
119  intptr_t result_ = 0;
120  intptr_t handle_ = 0;
121  static int32_t counter_;
122  };
123  }
124 }
std::type_info type
Stores information about a type.
Definition: types.h:179
intptr_t lparam() const
Gets the lparam field of the message.
Definition: message.h:45
type get_lparam()
Gets the lparam value and converts the value to an object.
Definition: message.h:97
int32_t msg() const
Gets the ID number for the message.
Definition: message.h:53
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:48
intptr_t wparam() const
Gets the wparam field of the message.
Definition: message.h:68
void hwnd(intptr_t value)
Sets the window handle of the message.
Definition: message.h:40
void lparam(intptr_t value)
Sets the lparam field of the message.
Definition: message.h:49
static message create(intptr_t hwnd, int32_t msg, intptr_t wparam, intptr_t lparam)
Creates a new message.
Definition: message.h:86
Contains xtd::ustring class.
Implements a Windows message.
Definition: message.h:25
Contains xtd::object class.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes...
Definition: object.h:26
void msg(int32_t value)
Sets the ID number for the message.
Definition: message.h:56
void wparam(intptr_t value)
Sets the wparam field of the message.
Definition: message.h:72
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition: about_box.h:13
intptr_t hwnd() const
Gets the window handle of the message.
Definition: message.h:36
xtd::ustring to_string() const noexcept override
Returns a string that represents the current message.
void result(intptr_t value)
Sets the value that is returned to Windows in response to handling the message.
Definition: message.h:63
intptr_t result() const
Gets the value that is returned to Windows in response to handling the message.
Definition: message.h:60
std::string to_string(const value_t &value, const std::string &fmt, const std::locale &loc)
Convert a specified value into a string with specified format and locale.
Definition: to_string.h:37