xtd 0.2.0
Loading...
Searching...
No Matches
form_and_messages.cpp

demonstrates some events received by form.

Windows

macOS

Gnome

#define TRACE
#include <xtd/forms/application>
#include <xtd/forms/trace_form>
#include <xtd/forms/form>
#include <xtd/forms/window_messages>
#include <xtd/ctrace>
using namespace xtd;
using namespace xtd::forms;
class form1 : public form {
public:
form1() {
text("Form and Messages");
}
protected:
template<typename type_t>
inline static uint16 LOWORD(type_t value) {
return static_cast<uint16>(static_cast<uint32>(value) & 0xFFFF);
}
template<typename type_t>
inline static uint16 HIWORD(type_t value) {
return static_cast<uint16>((static_cast<uint32>(value) >> 16) & 0xFFFF);
}
void wnd_proc(message& message) override {
form::wnd_proc(message);
switch (message.msg()) {
case WM_ACTIVATE: ctrace << string::format("WM_ACTIVATE [activate={}]", as<bool>(message.lparam())) << environment::new_line; break;
case WM_ACTIVATEAPP: ctrace << string::format("WM_ACTIVATEAPP [activate={}, threat={}]", as<bool>(message.wparam()), message.lparam()) << environment::new_line; break;
case WM_CANCELMODE: ctrace << "WM_CANCELMODE" << environment::new_line; break;
case WM_CHILDACTIVATE: ctrace << "WM_CHILDACTIVATE" << environment::new_line; break;
case WM_CLOSE: ctrace << "WM_CLOSE" << environment::new_line; break;
case WM_COMMAND: ctrace << string::format("WM_COMMAND [type=0x{:X8}, control={}]", message.wparam(), message.lparam()) << environment::new_line; break;
case WM_CREATE: ctrace << string::format("WM_CREATE [CREATESTRUCT={}]", message.lparam()) << environment::new_line; break;
case WM_DESTROY: ctrace << "WM_DESTROY" << environment::new_line; break;
case WM_ENTERSIZEMOVE: ctrace << "WM_ENTERSIZEMOVE" << environment::new_line; break;
case WM_ERASEBKGND: ctrace << "WM_ERASEBKGNDT" << environment::new_line; break;
case WM_EXITSIZEMOVE: ctrace << "WM_EXITSIZEMOVE" << environment::new_line; break;
case WM_GETTEXT: ctrace << string::format("WM_GETTEXT [size={}, buffer={}]", message.wparam(), message.lparam()) << environment::new_line; break;
case WM_GETTEXTLENGTH: ctrace << "WM_GETTEXTLENGTH" << environment::new_line; break;
case WM_KILLFOCUS: ctrace << "WM_KILLFOCUS" << environment::new_line; break;
case WM_LBUTTONDBLCLK: ctrace << string::format("WM_LBUTTONDBLCLK [Buttons={}, x={}, y={}]", message.wparam(), LOWORD(message.lparam()), HIWORD(message.lparam())) << environment::new_line; break;
case WM_LBUTTONDOWN: ctrace << string::format("WM_LBUTTONDOWN [Buttons={}, x={}, y={}]", message.wparam(), LOWORD(message.lparam()), HIWORD(message.lparam())) << environment::new_line; break;
case WM_LBUTTONUP: ctrace << string::format("WM_LBUTTONUP [Buttons={}, x={}, y={}]", message.wparam(), LOWORD(message.lparam()), HIWORD(message.lparam())) << environment::new_line; break;
case WM_MBUTTONDBLCLK: ctrace << string::format("WM_MBUTTONDBLCLK [Buttons={}, x={}, y={}]", message.wparam(), LOWORD(message.lparam()), HIWORD(message.lparam())) << environment::new_line; break;
case WM_MBUTTONDOWN: ctrace << string::format("WM_MBUTTONDOWN [Buttons={}, x={}, y={}]", message.wparam(), LOWORD(message.lparam()), HIWORD(message.lparam())) << environment::new_line; break;
case WM_MBUTTONUP: ctrace << string::format("WM_MBUTTONUP [Buttons={}, x={}, y={}]", message.wparam(), LOWORD(message.lparam()), HIWORD(message.lparam())) << environment::new_line; break;
case WM_MOVE: ctrace << string::format("WM_MOVE [x={}, y={}]", LOWORD(message.lparam()), HIWORD(message.lparam())) << environment::new_line; break;
case WM_MOUSEENTER: ctrace << "WM_MOUSEENTER" << environment::new_line; break;
case WM_MOUSEHWHEEL: ctrace << string::format("WM_MOUSEHWHEEL [Buttons={}, delta={}, x={}, y={}]", LOWORD(message.wparam()), HIWORD(message.wparam()), LOWORD(message.lparam()), HIWORD(message.lparam())) << environment::new_line; break;
case WM_MOUSELEAVE: ctrace << "WM_MOUSELEAVE" << environment::new_line; break;
case WM_MOUSEMOVE: ctrace << string::format("WM_MOUSEMOVE [Buttons={}, x={}, y={}]", message.wparam(), LOWORD(message.lparam()), HIWORD(message.lparam())) << environment::new_line; break;
case WM_MOUSEWHEEL: ctrace << string::format("WM_MOUSEWHEEL [Buttons={}, delta={}, x={}, y={}]", LOWORD(message.wparam()), HIWORD(message.wparam()), LOWORD(message.lparam()), HIWORD(message.lparam())) << environment::new_line; break;
case WM_PAINT: ctrace << "WM_PAINT" << environment::new_line; break;
case WM_RBUTTONDBLCLK: ctrace << string::format("WM_RBUTTONDBLCLK [Buttons={}, x={}, y={}]", message.wparam(), LOWORD(message.lparam()), HIWORD(message.lparam())) << environment::new_line; break;
case WM_RBUTTONDOWN: ctrace << string::format("WM_RBUTTONDOWN [Buttons={}, x={}, y={}]", message.wparam(), LOWORD(message.lparam()), HIWORD(message.lparam())) << environment::new_line; break;
case WM_RBUTTONUP: ctrace << string::format("WM_RBUTTONUP [Buttons={}, x={}, y={}]", message.wparam(), LOWORD(message.lparam()), HIWORD(message.lparam())) << environment::new_line; break;
case WM_SETFOCUS: ctrace << "WM_SETFOCUS" << environment::new_line; break;
case WM_SETTEXT: ctrace << string::format("WM_SETTEXT [text=\"{}\"]", reinterpret_cast<char*>(message.lparam())) << environment::new_line; break;
case WM_SHOWWINDOW: ctrace << string::format("WM_SHOWWINDOW [show={}]", as<bool>(message.wparam())) << environment::new_line; break;
case WM_SIZE: ctrace << string::format("WM_SIZE [type={}, width={}, heignt={}]", message.wparam(), LOWORD(message.lparam()), HIWORD(message.lparam())) << environment::new_line; break;
case WM_XBUTTONDBLCLK: ctrace << string::format("WM_XBUTTONDBLCLK [Buttons={}, x={}, y={}]", message.wparam(), LOWORD(message.lparam()), HIWORD(message.lparam())) << environment::new_line; break;
case WM_XBUTTONDOWN: ctrace << string::format("WM_XBUTTONDOWN [Buttons={}, x={}, y={}]", message.wparam(), LOWORD(message.lparam()), HIWORD(message.lparam())) << environment::new_line; break;
case WM_XBUTTONUP: ctrace << string::format("WM_XBUTTONUP [Buttons={}, x={}, y={}]", message.wparam(), LOWORD(message.lparam()), HIWORD(message.lparam())) << environment::new_line; break;
case WM_APPIDLE: /*ctrace << "WM_APPIDLE" << environment::new_line;*/ break;
default: ctrace << string::format("[{}]", message) << environment::new_line; break;
}
}
};
auto main() -> int {
application::run(form1 {});
}
Represents a window or dialog box that makes up an application's user interface.
Definition form.h:54
Implements a Windows message.
Definition message.h:28
intptr wparam() const noexcept
Gets the wparam field of the message.
intptr lparam() const noexcept
Gets the lparam field of the message.
uint32 msg() const noexcept
Gets the ID number for the message.
Represents a form that displays trace form. This class cannot be inherited.
Definition trace_form.h:36
uint32_t uint32
Represents a 32-bit unsigned integer.
Definition uint32.h:23
uint16_t uint16
Represents a 16-bit unsigned integer.
Definition uint16.h:23
constexpr xtd::uint32 WM_LBUTTONDOWN
Posted when the user presses the left mouse button while the cursor is in the client area of a window...
Definition window_messages.h:967
constexpr xtd::uint32 WM_MOUSELEAVE
Posted to a window when the cursor leaves the client area of the window specified in a prior call to ...
Definition window_messages.h:1436
constexpr xtd::uint32 WM_SETTEXT
Sets the text of a window.
Definition window_messages.h:86
constexpr xtd::uint32 WM_XBUTTONDOWN
Posted when the user presses the first or second X button while the cursor is in the client area of a...
Definition window_messages.h:1037
constexpr xtd::uint32 WM_EXITSIZEMOVE
Sent one time to a window, after it has exited the moving or sizing modal loop. The window enters the...
Definition window_messages.h:1214
constexpr xtd::uint32 WM_PAINT
The WM_PAINT message is sent when the system or another application makes a request to paint a portio...
Definition window_messages.h:107
constexpr xtd::uint32 WM_LBUTTONDBLCLK
Posted when the user double-clicks the left mouse button while the cursor is in the client area of a ...
Definition window_messages.h:981
constexpr xtd::uint32 WM_GETTEXTLENGTH
Determines the length, in characters, of the text associated with a window.
Definition window_messages.h:100
constexpr xtd::uint32 WM_LBUTTONUP
Posted when the user releases the left mouse button while the cursor is in the client area of a windo...
Definition window_messages.h:974
constexpr xtd::uint32 WM_ERASEBKGND
Sent when the window background must be erased (for example, when a window is resized)....
Definition window_messages.h:142
constexpr xtd::uint32 WM_CHILDACTIVATE
Sent to a child window when the user clicks the window's title bar or when the window is activated,...
Definition window_messages.h:234
constexpr xtd::uint32 WM_MOUSEWHEEL
Sent to the focus window when the mouse wheel is rotated. The DefWindowProc function propagates the m...
Definition window_messages.h:1030
constexpr xtd::uint32 WM_KILLFOCUS
Sent to a window immediately before it loses the keyboard focus.
Definition window_messages.h:64
constexpr xtd::uint32 WM_RBUTTONDBLCLK
Posted when the user double-clicks the right mouse button while the cursor is in the client area of a...
Definition window_messages.h:1002
constexpr xtd::uint32 WM_CREATE
Sent when an application requests that a window be created by calling the CreateWindowEx or CreateWin...
Definition window_messages.h:21
constexpr xtd::uint32 WM_XBUTTONDBLCLK
Posted when the user double-clicks the first or second X button while the cursor is in the client are...
Definition window_messages.h:1051
constexpr xtd::uint32 WM_MOVE
Sent after a window has been moved.
Definition window_messages.h:35
constexpr xtd::uint32 WM_GETTEXT
Copies the text that corresponds to a window into a buffer provided by the caller.
Definition window_messages.h:93
constexpr xtd::uint32 WM_XBUTTONUP
Posted when the user releases the first or second X button while the cursor is in the client area of ...
Definition window_messages.h:1044
constexpr xtd::uint32 WM_CLOSE
Sent as a signal that a window or an application should terminate.
Definition window_messages.h:114
constexpr xtd::uint32 WM_MOUSEMOVE
Posted to a window when the cursor moves. If the mouse is not captured, the message is posted to the ...
Definition window_messages.h:960
constexpr xtd::uint32 WM_ENTERSIZEMOVE
Sent one time to a window after it enters the moving or sizing modal loop. The window enters the movi...
Definition window_messages.h:1207
constexpr xtd::uint32 WM_ACTIVATEAPP
Sent when a window belonging to a different application than the active window is about to be activat...
Definition window_messages.h:192
constexpr xtd::uint32 WM_SETFOCUS
Sent to a window after it has gained the keyboard focus.
Definition window_messages.h:57
constexpr xtd::uint32 WM_SIZE
Sent to a window after its size has changed.
Definition window_messages.h:43
constexpr xtd::uint32 WM_MBUTTONUP
Posted when the user releases the middle mouse button while the cursor is in the client area of a win...
Definition window_messages.h:1016
constexpr xtd::uint32 WM_RBUTTONDOWN
Posted when the user presses the right mouse button while the cursor is in the client area of a windo...
Definition window_messages.h:988
constexpr xtd::uint32 WM_DESTROY
Sent when a window is being destroyed. It is sent to the window procedure of the window being destroy...
Definition window_messages.h:28
constexpr xtd::uint32 WM_ACTIVATE
Sent to both the window being activated and the window being deactivated. If the windows use the same...
Definition window_messages.h:50
constexpr xtd::uint32 WM_COMMAND
Sent when the user selects a command item from a menu, when a control sends a notification message to...
Definition window_messages.h:759
constexpr xtd::uint32 WM_MBUTTONDOWN
Posted when the user presses the middle mouse button while the cursor is in the client area of a wind...
Definition window_messages.h:1009
constexpr xtd::uint32 WM_CANCELMODE
Sent to cancel certain modes, such as mouse capture. For example, the system sends this message to th...
Definition window_messages.h:213
constexpr xtd::uint32 WM_MBUTTONDBLCLK
Posted when the user double-clicks the middle mouse button while the cursor is in the client area of ...
Definition window_messages.h:1023
constexpr xtd::uint32 WM_MOUSEHWHEEL
Sent to the active window when the mouse's horizontal scroll wheel is tilted or rotated....
Definition window_messages.h:1058
constexpr xtd::uint32 WM_SHOWWINDOW
Sent to a window when the window is about to be hidden or shown.
Definition window_messages.h:164
constexpr xtd::uint32 WM_RBUTTONUP
Posted when the user releases the right mouse button while the cursor is in the client area of a wind...
Definition window_messages.h:995
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition xtd_about_box.h:12
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10