1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
//! Windows API utilities for coordinate conversion, bit operations, and message parameter handling.
//!
//! This crate provides utilities for working with Windows API concepts including:
//! - Coordinate conversion between client and screen coordinates
//! - Bit manipulation (LOWORD, HIWORD, LOBYTE, HIBYTE)
//! - Windows message parameter handling (WPARAM, LPARAM)
//!
//! # Features
//!
//! - **Coordinate Conversion**: ClientToScreen, ScreenToClient functionality
//! - **Bit Manipulation**: Extract high/low words and bytes from integers
//! - **Message Parameters**: Type-safe WPARAM and LPARAM handling
//! - **Cross-platform**: Works on Windows, Linux, and macOS
//! - **No-std support**: Core functionality available without std
//! - **Feature Gating**: Enable only the functionality you need
//! - **Serialization**: Optional serde support for message types
//! - **Windows Interop**: Seamless compatibility with windows crate
//!
//! # Feature Flags
//!
//! - `coordinates`: Enables coordinate conversion types and traits
//! - `bit-ops`: Enables bit manipulation utilities
//! - `messages`: Enables Windows message handling
//! - `serde`: Enables serialization support for types
//! - `windows-interop`: Enables seamless compatibility with windows crate
//! - `full`: Enables all features
//! - `minimal`: Disables all optional features (default: enabled)
//!
//! # Quick Start
//!
//! ## Using default features (coordinates + messages)
//!
//! ```toml
//! [dependencies]
//! windows-api-utils = "0.1"
//! ```
//!
//! ```rust
//! use windows_api_utils::prelude::*;
//!
//! // Coordinate conversion
//! let window = Window::new(12345, Rect::new(100, 100, 500, 400), Default::default());
//! let client_point = Point::new(50, 30);
//! let screen_point = window.client_to_screen(client_point).unwrap();
//!
//! // Message handling
//! let message = WindowMessage::mouse_move(100, 200, KeyModifiers::default());
//! if let Some(mouse_event) = MessageParser::parse_mouse_message(message) {
//! println!("Mouse at ({}, {})", mouse_event.x, mouse_event.y);
//! }
//! ```
//!
//! ## Using with windows crate interop
//!
//! ```toml
//! [dependencies]
//! windows-api-utils = { version = "0.1", features = ["windows-interop"] }
//! windows = "0.52"
//! ```
//!
//! ```rust
//! use windows_api_utils::prelude::*;
//! use windows::Win32::Foundation::{WPARAM, LPARAM};
//!
//! // 完全兼容,无需转换!
//! let win_wparam = WPARAM(0x1234);
//! let our_wparam = WParam::from(win_wparam);
//! let back_to_win: WPARAM = our_wparam.into();
//!
//! assert_eq!(win_wparam.0, back_to_win.0);
//!
//! // 坐标转换测试
//! let win_lparam = LPARAM(0x00C80064); // x=100, y=200
//! let our_lparam = LParam::from(win_lparam);
//! let (x, y) = our_lparam.as_point();
//! assert_eq!(x, 100);
//! assert_eq!(y, 200);
//!
//! // from_point -> our_lparam -> win_lparam 完整流程测试
//! let our_lparam_from_coords = LParam::from_point(300, 400);
//! let win_lparam_from_our: LPARAM = our_lparam_from_coords.into();
//! let (x_back, y_back) = our_lparam_from_coords.as_point();
//! assert_eq!(x_back, 300);
//! assert_eq!(y_back, 400);
//!
//! // 验证转换后的值是正确的坐标编码
//! let expected_value = ((400 as u32) << 16) | (300 as u32);
//! assert_eq!(win_lparam_from_our.0 as u32, expected_value);
//! ```
//!
//! ## Using only coordinate features
//!
//! ```toml
//! [dependencies]
//! windows-api-utils = { version = "0.1", default-features = false, features = ["coordinates"] }
//! ```
//!
//! ```rust
//! use windows_api_utils::{Point, Rect, Window, CoordinateTransformer};
//!
//! let window = Window::new(12345, Rect::new(100, 100, 500, 400), Default::default());
//! let client_point = Point::new(50, 30);
//! let screen_point = window.client_to_screen(client_point).unwrap();
//! ```
//!
//! ## Using only bit operations
//!
//! ```toml
//! [dependencies]
//! windows-api-utils = { version = "0.1", default-features = false, features = ["bit-ops"] }
//! ```
//!
//! ```rust
//! # // 注意:这个测试需要 bit-ops 特性
//! # use windows_api_utils::{loword, hiword, make_long, BitUtils};
//! #
//! let value = 0x12345678;
//! let low = loword(value); // 0x5678
//! let high = hiword(value); // 0x1234
//! let reconstructed = make_long(high, low);
//! ```
//!
//! ## Minimal usage (no-std compatible)
//!
//! ```toml
//! [dependencies]
//! windows-api-utils = { version = "0.1", default-features = false }
//! ```
//!
//! ```rust
//! use windows_api_utils::WindowsUtilsError;
//!
//! // Only error types available in minimal mode
//! ```
// Core modules - always available
// Feature-gated modules
// Re-export error types (always available)
pub use *;
// Conditional re-exports based on features
pub use *;
pub use *;
pub use *;
/// Prelude for convenient imports based on enabled features.