xtd - Reference Guide  0.1.2
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
Loading...
Searching...
No Matches
message.h
Go to the documentation of this file.
1
4#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
14namespace 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}
Implements a Windows message.
Definition message.h:25
xtd::ustring to_string() const noexcept override
Returns a string that represents the current message.
void msg(int32_t value)
Sets the ID number for the message.
Definition message.h:56
intptr_t wparam() const
Gets the wparam field of the message.
Definition message.h:68
intptr_t hwnd() const
Gets the window handle of the message.
Definition message.h:36
type get_lparam()
Gets the lparam value and converts the value to an object.
Definition message.h:97
void lparam(intptr_t value)
Sets the lparam field of the message.
Definition message.h:49
intptr_t lparam() const
Gets the lparam field of the message.
Definition message.h:45
static message create(intptr_t hwnd, int32_t msg, intptr_t wparam, intptr_t lparam)
Creates a new message.
Definition message.h:86
void result(intptr_t value)
Sets the value that is returned to Windows in response to handling the message.
Definition message.h:63
void hwnd(intptr_t value)
Sets the window handle of the message.
Definition message.h:40
int32_t msg() const
Gets the ID number for the message.
Definition message.h:53
void wparam(intptr_t value)
Sets the wparam field of the message.
Definition message.h:72
intptr_t result() const
Gets the value that is returned to Windows in response to handling the message.
Definition message.h:60
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.h:26
Represents text as a sequence of UTF-8 code units.
Definition ustring.h:48
#define forms_export_
Define shared library export.
Definition forms_export.h:13
std::type_info type
Stores information about a type.
Definition types.h:179
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition about_box.h:13
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition system_report.h:17
Contains xtd::object class.
Contains xtd::ustring class.