xtd 0.2.0
xtd::forms::message Class Reference

Definition

Implements a Windows message.

Header
#include <xtd/forms/message>
Namespace
xtd::forms
Library
xtd.forms
Remarks
The message structure wraps messages that Windows sends. You can use this structure to wrap a message and assign it to the window procedure to be dispatched. You can also use this structure to get information about a message the system sends to your application or controls.
You cannot create the message directly. Instead, use the create method. For the sake of efficiency, the message uses its pool of existing Messages instead of instantiating a new one, if possible. However, if a message is not available in the pool, a new one is instantiated.
Windows message are simulate on macOS and linux.
Examples:
action1.cpp, action2.cpp, action3.cpp, form_and_messages.cpp, and wnd_proc.cpp.

Properties

intptr hwnd () const noexcept
 Gets the window handle of the message. More...
 
void hwnd (intptr value)
 Sets the window handle of the message. More...
 
intptr lparam () const noexcept
 Gets the lparam field of the message. More...
 
void lparam (intptr value)
 Sets the lparam field of the message. More...
 
uint32 msg () const noexcept
 Gets the ID number for the message. More...
 
void msg (uint32 value)
 Sets the ID number for the message. More...
 
intptr result () const noexcept
 Gets the value that is returned to Windows in response to handling the message. More...
 
void result (intptr value)
 Sets the value that is returned to Windows in response to handling the message. More...
 
intptr wparam () const noexcept
 Gets the wparam field of the message. More...
 
void wparam (intptr value)
 Sets the wparam field of the message. More...
 

Methods

template<typename type_t >
type_t get_lparam () const noexcept
 Gets the lparam value and converts the value to an object. More...
 
xtd::ustring to_string () const noexcept override
 Returns a string that represents the current message. More...
 
static message create (intptr hwnd, int32 msg, intptr wparam, intptr lparam)
 Creates a new message. 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...
 
- 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

◆ create()

static message xtd::forms::message::create ( intptr  hwnd,
int32  msg,
intptr  wparam,
intptr  lparam 
)
static

Creates a new message.

Parameters
hwndThe window handle that the message is for.
msgThe message ID.The message ID.
wparamThe message wparam field.
lparamThe message lparam field.
Returns
A xtd::forms::message that represents the message that was created.
Remarks
Use the xtd::message::create method to create a xtd::forms::message to wrap a message sent by Windows.

◆ get_lparam()

template<typename type_t >
type_t xtd::forms::message::get_lparam ( ) const
inlinenoexcept

Gets the lparam value and converts the value to an object.

Template Parameters
typeThe type to use to create an instance. This type must be declared as a structure type.
Returns
An object that represents an instance of the class specified by the template parameter, with the data from the lparam field of the message.

◆ hwnd() [1/2]

intptr xtd::forms::message::hwnd ( ) const
noexcept

Gets the window handle of the message.

Returns
The window handle of the message.
Remarks
Window handle is a value that uniquely identifies a window on the system. This property returns a handle of the window whose window procedure receives this message. It is useful when your code need to interact with some native Windows API functions that expect window handles as parameters.

◆ hwnd() [2/2]

void xtd::forms::message::hwnd ( intptr  value)

Sets the window handle of the message.

Parameters
hwndThe window handle of the message.
Remarks
Window handle is a value that uniquely identifies a window on the system. This property returns a handle of the window whose window procedure receives this message. It is useful when your code need to interact with some native Windows API functions that expect window handles as parameters.

◆ lparam() [1/2]

intptr xtd::forms::message::lparam ( ) const
noexcept

Gets the lparam field of the message.

Returns
The lparam field of the message.
Remarks
The value of this field depends on the message. Use the lparam field to get information that is important for handling the message. lparam is typically used to store an object if it is needed by the message.
Examples:
form_and_messages.cpp.

◆ lparam() [2/2]

void xtd::forms::message::lparam ( intptr  value)

Sets the lparam field of the message.

Parameters
valueThe lparam field of the message.
Remarks
The value of this field depends on the message. Use the lparam field to get information that is important for handling the message. lparam is typically used to store an object if it is needed by the message.

◆ msg() [1/2]

uint32 xtd::forms::message::msg ( ) const
noexcept

Gets the ID number for the message.

Returns
The ID number for the message.
Examples:
form_and_messages.cpp, and wnd_proc.cpp.

◆ msg() [2/2]

void xtd::forms::message::msg ( uint32  value)

Sets the ID number for the message.

Parameters
valueThe ID number for the message.

◆ result() [1/2]

intptr xtd::forms::message::result ( ) const
noexcept

Gets the value that is returned to Windows in response to handling the message.

Returns
The return value of the message.

◆ result() [2/2]

void xtd::forms::message::result ( intptr  value)

Sets the value that is returned to Windows in response to handling the message.

Parameters
valueThe return value of the message.

◆ to_string()

xtd::ustring xtd::forms::message::to_string ( ) const
overridevirtualnoexcept

Returns a string that represents the current message.

Returns
A xtd::ustring that represents the current message.

Reimplemented from xtd::object.

◆ wparam() [1/2]

intptr xtd::forms::message::wparam ( ) const
noexcept

Gets the wparam field of the message.

Returns
The wparam field of the message.
Remarks
The value of this field depends on the message. Use the wparam field to get information that is important to handling the message. This field is typically used to store small pieces of information, such as flags.
Examples:
form_and_messages.cpp, and wnd_proc.cpp.

◆ wparam() [2/2]

void xtd::forms::message::wparam ( intptr  value)

Sets the wparam field of the message.

Parameters
valueThe wparam field of the message.
Remarks
The value of this field depends on the message. Use the wparam field to get information that is important to handling the message. This field is typically used to store small pieces of information, such as flags.

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