winsafe\comctl\structs/
structs_other.rs

1#![allow(non_camel_case_types, non_snake_case)]
2
3use std::marker::PhantomData;
4
5use crate::co;
6use crate::comctl::privs::*;
7use crate::decl::*;
8use crate::kernel::{ffi_types::*, privs::*};
9use crate::prelude::*;
10
11/// [`BUTTON_IMAGELIST`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-button_imagelist)
12/// struct.
13#[repr(C)]
14pub struct BUTTON_IMAGELIST {
15	pub himl: HIMAGELIST,
16	pub margin: RECT,
17	pub uAlign: co::BIA,
18}
19
20/// [`BUTTON_SPLITINFO`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-button_splitinfo)
21/// struct.
22#[repr(C)]
23pub struct BUTTON_SPLITINFO {
24	pub mask: co::BCSIF,
25	pub himlGlyph: HIMAGELIST,
26	pub uSplitStyle: co::BCSS,
27	pub size: SIZE,
28}
29
30/// [`COLORSCHEME`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-colorscheme)
31/// struct.
32#[repr(C)]
33pub struct COLORSCHEME {
34	dwSize: u32,
35	pub clrBtnHighlight: COLORREF,
36	pub clrBtnShadow: COLORREF,
37}
38
39impl_default!(COLORSCHEME, dwSize);
40
41/// [`DATETIMEPICKERINFO`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-datetimepickerinfo)
42/// struct.
43#[repr(C)]
44pub struct DATETIMEPICKERINFO {
45	cbSize: u32,
46	pub rcCheck: RECT,
47	pub stateCheck: co::STATE_SYSTEM,
48	pub rcButton: RECT,
49	pub stateButton: co::STATE_SYSTEM,
50	pub hwndEdit: HWND,
51	pub hwndUD: HWND,
52	pub hwndDropDown: HWND,
53}
54
55impl_default!(DATETIMEPICKERINFO, cbSize);
56
57/// [`EDITBALLOONTIP`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-editballoontip)
58/// struct.
59#[repr(C)]
60pub struct EDITBALLOONTIP<'a, 'b> {
61	cbStruct: u32,
62	pszTitle: *mut u16,
63	pszText: *mut u16,
64	pub ttiIcon: co::TTI,
65
66	_pszTitle: PhantomData<&'a mut u16>,
67	_pszText: PhantomData<&'b mut u16>,
68}
69
70impl_default!(EDITBALLOONTIP, cbStruct, 'a, 'b);
71
72impl<'a, 'b> EDITBALLOONTIP<'a, 'b> {
73	pub_fn_string_ptr_get_set!('a, pszTitle, set_pszTitle);
74	pub_fn_string_ptr_get_set!('b, pszText, set_pszText);
75}
76
77/// [`HDITEM`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-hditemw)
78/// struct.
79#[repr(C)]
80pub struct HDITEM<'a> {
81	pub mask: co::HDI,
82	pub cxy: i32,
83	pszText: *mut u16,
84	pub hbm: HBITMAP,
85	cchTextMax: i32,
86	pub fmt: co::HDF,
87	pub lParam: isize,
88	pub iImage: i32,
89	pub iOrder: i32,
90	pub typeFilter: co::HDFT,
91	pub pvFilter: *mut std::ffi::c_void,
92	pub state: co::HDIS,
93
94	_pszText: PhantomData<&'a mut u16>,
95}
96
97impl_default!(HDITEM, 'a);
98
99impl<'a> HDITEM<'a> {
100	pub_fn_string_buf_get_set!('a, pszText, set_pszText, raw_pszText, cchTextMax);
101}
102
103/// [`HDHITTESTINFO`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-hdhittestinfo)
104/// struct.
105#[repr(C)]
106#[derive(Default)]
107pub struct HDHITTESTINFO {
108	pub pt: POINT,
109	pub flags: co::HHT,
110	pub iItem: i32,
111}
112
113/// [`HDLAYOUT`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-hdlayout)
114/// struct.
115#[repr(C)]
116pub struct HDLAYOUT<'a, 'b> {
117	prc: *mut RECT,
118	pwpos: *mut WINDOWPOS,
119
120	_prc: PhantomData<&'a mut RECT>,
121	_pwpos: PhantomData<&'b mut WINDOWPOS>,
122}
123
124impl_default!(HDLAYOUT, 'a, 'b);
125
126impl<'a, 'b> HDLAYOUT<'a, 'b> {
127	pub_fn_ptr_get_set!('a, prc, set_prc, RECT);
128	pub_fn_ptr_get_set!('b, pwpos, set_pwpos, WINDOWPOS);
129}
130
131/// [`INITCOMMONCONTROLSEX`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-initcommoncontrolsex)
132/// struct
133#[repr(C)]
134pub struct INITCOMMONCONTROLSEX {
135	dwSize: u32,
136	pub icc: co::ICC,
137}
138
139impl_default!(INITCOMMONCONTROLSEX, dwSize);
140
141/// [`LITEM`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-litem)
142/// struct.
143#[repr(C)]
144pub struct LITEM {
145	pub mask: co::LIF,
146	pub iLink: i32,
147	pub state: co::LIS,
148	pub stateMask: co::LIS,
149	szID: [u16; MAX_LINKID_TEXT],
150	szUrl: [u16; L_MAX_URL_LENGTH],
151}
152
153impl_default!(LITEM);
154
155impl LITEM {
156	pub_fn_string_arr_get_set!(szID, set_szID);
157	pub_fn_string_arr_get_set!(szUrl, set_szUrl);
158}
159
160/// [`LVBKIMAGE`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-lvbkimagew)
161/// struct.
162#[repr(C)]
163pub struct LVBKIMAGE<'a> {
164	pub uFlags: co::LVBKIF,
165	pub hbm: HBITMAP,
166	pszImage: *mut u16,
167	cchImageMax: u32,
168	pub xOffsetPercent: i32,
169	pub yOffsetPercent: i32,
170
171	_pszImage: PhantomData<&'a mut u16>,
172}
173
174impl_default!(LVBKIMAGE, 'a);
175
176impl<'a> LVBKIMAGE<'a> {
177	pub_fn_string_buf_get_set!('a, pszImage, set_pszImage, raw_pszImage, cchImageMax);
178}
179
180/// [`LVCOLUMN`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-lvcolumnw)
181/// struct.
182#[repr(C)]
183pub struct LVCOLUMN<'a> {
184	pub mask: co::LVCF,
185	pub fmt: co::LVCFMT_C,
186	pub cx: i32,
187	pszText: *mut u16,
188	cchTextMax: i32,
189	pub iSubItem: i32,
190	pub iImage: i32,
191	pub iOrder: i32,
192	pub cxMin: i32,
193	pub cxDefault: i32,
194	pub cxIdeal: i32,
195
196	_pszText: PhantomData<&'a mut u16>,
197}
198
199impl_default!(LVCOLUMN, 'a);
200
201impl<'a> LVCOLUMN<'a> {
202	pub_fn_string_buf_get_set!('a, pszText, set_pszText, raw_pszText, cchTextMax);
203}
204
205/// [`LVFINDINFO`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-lvfindinfow)
206/// struct.
207#[repr(C)]
208pub struct LVFINDINFO<'a> {
209	pub flags: co::LVFI,
210	psz: *mut u16,
211	pub lParam: isize,
212	pub pt: POINT,
213	pub vkDirection: co::VK_DIR,
214
215	_psz: PhantomData<&'a mut u16>,
216}
217
218impl_default!(LVFINDINFO, 'a);
219
220impl<'a> LVFINDINFO<'a> {
221	pub_fn_string_ptr_get_set!('a, psz, set_psz);
222}
223
224/// [`LVFOOTERINFO`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-lvfooterinfo)
225/// struct.
226#[repr(C)]
227pub struct LVFOOTERINFO<'a> {
228	pub mask: co::LVFF,
229	pszText: *mut u16,
230	cchTextMax: i32,
231	pub cItems: u32,
232
233	_pszText: PhantomData<&'a mut u16>,
234}
235
236impl_default!(LVFOOTERINFO, 'a);
237
238impl<'a> LVFOOTERINFO<'a> {
239	pub_fn_string_buf_get_set!('a, pszText, set_pszText, raw_pszText, cchTextMax);
240}
241
242/// [`LVFOOTERITEM`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-lvfooteritem)
243/// struct.
244#[repr(C)]
245pub struct LVFOOTERITEM<'a> {
246	pub mask: co::LVFIF,
247	pub iItem: i32,
248	pszText: *mut u16,
249	cchTextMax: i32,
250	pub state: co::LVFIS,
251	pub stateMask: co::LVFIS,
252
253	_pszText: PhantomData<&'a mut u16>,
254}
255
256impl_default!(LVFOOTERITEM, 'a);
257
258impl<'a> LVFOOTERITEM<'a> {
259	pub_fn_string_buf_get_set!('a, pszText, set_pszText, raw_pszText, cchTextMax);
260}
261
262/// [`LVGROUP`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-lvgroup)
263/// struct.
264#[repr(C)]
265pub struct LVGROUP<'a, 'b, 'c, 'd, 'e, 'f, 'g> {
266	cbSize: u32,
267	pub mask: co::LVGF,
268	pszHeader: *mut u16,
269	cchHeader: i32,
270	pszFooter: *mut u16,
271	cchFooter: i32,
272	pub iGroupId: i32,
273	pub stateMask: co::LVGS,
274	pub state: co::LVGS,
275	pub uAlign: co::LVGA_FH,
276	pszSubtitle: *mut u16,
277	cchSubtitle: i32,
278	pszTask: *mut u16,
279	cchTask: i32,
280	pszDescriptionTop: *mut u16,
281	cchDescriptionTop: i32,
282	pszDescriptionBottom: *mut u16,
283	cchDescriptionBottom: i32,
284	pub iTitleImage: i32,
285	pub iExtendedImage: i32,
286	pub iFirstItem: i32,
287	pub cItems: u32,
288	pszSubsetTitle: *mut u16,
289	cchSubsetTitle: i32,
290
291	_pszHeader: PhantomData<&'a mut u16>,
292	_pszFooter: PhantomData<&'b mut u16>,
293	_pszSubtitle: PhantomData<&'c mut u16>,
294	_pszTask: PhantomData<&'d mut u16>,
295	_pszDescriptionTop: PhantomData<&'e mut u16>,
296	_pszDescriptionBottom: PhantomData<&'f mut u16>,
297	_pszSubsetTitle: PhantomData<&'g mut u16>,
298}
299
300impl_default!(LVGROUP, cbSize, 'a, 'b, 'c, 'd, 'e, 'f, 'g);
301
302impl<'a, 'b, 'c, 'd, 'e, 'f, 'g> LVGROUP<'a, 'b, 'c, 'd, 'e, 'f, 'g> {
303	pub_fn_string_buf_get_set!('a, pszHeader, set_pszHeader, raw_pszHeader, cchHeader);
304	pub_fn_string_buf_get_set!('b, pszFooter, set_pszFooter, raw_pszFooter, cchFooter);
305	pub_fn_string_buf_get_set!('c, pszSubtitle, set_pszSubtitle, raw_pszSubtitle, cchSubtitle);
306	pub_fn_string_buf_get_set!('d, pszTask, set_pszTask, raw_pszTask, cchTask);
307	pub_fn_string_buf_get_set!('e, pszDescriptionTop, set_pszDescriptionTop, raw_pszDescriptionTop, cchDescriptionTop);
308	pub_fn_string_buf_get_set!('f, pszDescriptionBottom, set_pszDescriptionBottom, raw_pszDescriptionBottom, cchDescriptionBottom);
309	pub_fn_string_buf_get_set!('g, pszSubsetTitle, set_pszSubsetTitle, raw_pszSubsetTitle, cchSubsetTitle);
310}
311
312/// [`LVGROUPMETRICS`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-lvgroupmetrics)
313/// struct.
314#[repr(C)]
315pub struct LVGROUPMETRICS {
316	cbSize: u32,
317	pub mask: co::LVGMF,
318	pub Left: u32,
319	pub Top: u32,
320	pub Right: u32,
321	pub Bottom: u32,
322	pub crLeft: COLORREF,
323	pub crTop: COLORREF,
324	pub crRight: COLORREF,
325	pub crBottom: COLORREF,
326	pub crHeader: COLORREF,
327	pub crFooter: COLORREF,
328}
329
330impl_default!(LVGROUPMETRICS, cbSize);
331
332/// [`LVHITTESTINFO`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-lvhittestinfo)
333/// struct.
334#[repr(C)]
335#[derive(Default)]
336pub struct LVHITTESTINFO {
337	pub pt: POINT,
338	pub flags: co::LVHT,
339	pub iItem: i32,
340	pub iSubItem: i32,
341	pub iGroup: i32,
342}
343
344/// [`LVINSERTGROUPSORTED`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-lvinsertgroupsorted)
345/// struct.
346#[repr(C)]
347pub struct LVINSERTGROUPSORTED<'a, 'b, 'c, 'd, 'e, 'f, 'g> {
348	pub pfnGroupCompare: Option<PFNLVGROUPCOMPARE>,
349	pub pvData: usize,
350	pub lvGroup: LVGROUP<'a, 'b, 'c, 'd, 'e, 'f, 'g>,
351}
352
353impl<'a, 'b, 'c, 'd, 'e, 'f, 'g> Default for LVINSERTGROUPSORTED<'a, 'b, 'c, 'd, 'e, 'f, 'g> {
354	fn default() -> Self {
355		Self {
356			pfnGroupCompare: None,
357			pvData: 0,
358			lvGroup: LVGROUP::default(), // has cbSize, so we can't use impl_default_size macro
359		}
360	}
361}
362
363/// [`LVINSERTMARK`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-lvinsertmark)
364/// struct.
365#[repr(C)]
366pub struct LVINSERTMARK {
367	cbSize: u32,
368	pub dwFlags: co::LVIM,
369	pub iItem: i32,
370	dwReserved: u32,
371}
372
373impl_default!(LVINSERTMARK);
374
375/// [`LVITEM`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-lvitemw)
376/// struct.
377#[repr(C)]
378pub struct LVITEM<'a> {
379	pub mask: co::LVIF,
380	pub iItem: i32,
381	pub iSubItem: i32,
382	pub state: co::LVIS,
383	pub stateMask: co::LVIS,
384	pszText: *mut u16,
385	cchTextMax: i32,
386	pub iImage: i32,
387	pub lParam: isize,
388	pub iIndent: i32,
389	pub iGroupId: co::LVI_GROUPID,
390	pub cColumns: u32,
391	pub puColumns: *mut i32,
392	pub piColFmt: *mut co::LVCFMT_I,
393	pub iGroup: i32,
394
395	_pszText: PhantomData<&'a mut u16>,
396}
397
398impl_default!(LVITEM, 'a);
399
400impl<'a> LVITEM<'a> {
401	pub_fn_string_buf_get_set!('a, pszText, set_pszText, raw_pszText, cchTextMax);
402}
403
404/// [`LVITEMINDEX`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-lvitemindex)
405/// struct.
406#[repr(C)]
407#[derive(Default, Clone, Copy, PartialEq, Eq)]
408pub struct LVITEMINDEX {
409	pub iItem: i32,
410	pub iGroup: i32,
411}
412
413/// [`LVSETINFOTIP`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-lvsetinfotip)
414/// struct.
415#[repr(C)]
416pub struct LVSETINFOTIP<'a> {
417	cbSize: u32,
418	pub dwFlags: u32, // unspecified
419	pszText: *mut u16,
420	pub iItem: i32,
421	pub iSubItem: i32,
422
423	_pszText: PhantomData<&'a mut u16>,
424}
425
426impl_default!(LVSETINFOTIP, cbSize, 'a);
427
428impl<'a> LVSETINFOTIP<'a> {
429	pub_fn_string_ptr_get_set!('a, pszText, set_pszText);
430}
431
432/// [`LVTILEINFO`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-lvtileinfo)
433/// struct.
434#[repr(C)]
435pub struct LVTILEINFO<'a> {
436	cbSize: u32,
437	pub iItem: i32,
438	cColumns: u32,
439	puColumns: *mut u32,
440	piColFmt: *mut co::LVCFMT_C,
441
442	_puColumns: PhantomData<&'a mut u32>,
443}
444
445impl_default!(LVTILEINFO, cbSize, 'a);
446
447impl<'a> LVTILEINFO<'a> {
448	/// Returns the `puColumns` field.
449	#[must_use]
450	pub fn puColumns(&self) -> Option<&'a mut [u32]> {
451		unsafe {
452			self.puColumns
453				.as_mut()
454				.map(|_| std::slice::from_raw_parts_mut(self.puColumns, self.cColumns as _))
455		}
456	}
457
458	/// Returns the `piColFmt` field.
459	#[must_use]
460	pub fn piColFmt(&self) -> Option<&'a mut [co::LVCFMT_C]> {
461		unsafe {
462			self.puColumns
463				.as_mut()
464				.map(|_| std::slice::from_raw_parts_mut(self.piColFmt, self.cColumns as _))
465		}
466	}
467
468	/// Sets the `puColumns` and `piColFmt` fields.
469	///
470	/// # Panics
471	///
472	/// Panics if `puColumns` and `piColFmt` slices have different lengths.
473	pub fn set_puColumns_piColFmt(&mut self, val: Option<(&'a mut [u32], &'a mut [co::LVCFMT_C])>) {
474		if let Some(val) = val {
475			if val.0.len() != val.1.len() {
476				panic!("Different slice lengths: {} and {}.", val.0.len(), val.1.len());
477			}
478			self.cColumns = val.0.len() as _;
479			self.puColumns = val.0.as_mut_ptr();
480			self.piColFmt = val.1.as_mut_ptr();
481		} else {
482			self.cColumns = 0;
483			self.puColumns = std::ptr::null_mut();
484			self.piColFmt = std::ptr::null_mut();
485		}
486	}
487}
488
489/// [`LVTILEVIEWINFO`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-lvtileviewinfo)
490/// struct.
491#[repr(C)]
492pub struct LVTILEVIEWINFO {
493	cbSize: u32,
494	pub dwMask: co::LVTVIM,
495	pub dwFlags: co::LVTVIF,
496	pub sizeTile: SIZE,
497	pub cLines: i32,
498	pub rcLabelMargin: RECT,
499}
500
501impl_default!(LVTILEVIEWINFO, cbSize);
502
503/// [`MCGRIDINFO`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-mcgridinfo)
504/// struct.
505#[repr(C)]
506pub struct MCGRIDINFO<'a> {
507	cbSize: u32,
508	pub dwPart: co::MCGIP,
509	pub dwFlags: co::MCGIF,
510	pub iCalendar: i32,
511	pub iRow: i32,
512	pub iCol: i32,
513	bSelected: BOOL,
514	pub stStart: SYSTEMTIME,
515	pub stEnd: SYSTEMTIME,
516	pub rc: RECT,
517	pszName: *mut u16,
518	cchName: usize,
519
520	_pszName: PhantomData<&'a mut u16>,
521}
522
523impl_default!(MCGRIDINFO, cbSize, 'a);
524
525impl<'a> MCGRIDINFO<'a> {
526	pub_fn_bool_get_set!(bSelected, set_bSelected);
527	pub_fn_string_buf_get_set!('a, pszName, set_pszName, raw_pszName, cchName);
528}
529
530/// [`MCHITTESTINFO`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-mchittestinfo)
531/// struct.
532#[repr(C)]
533pub struct MCHITTESTINFO {
534	cbSize: u32,
535	pub pt: POINT,
536	pub uHit: co::MCHT,
537	pub st: SYSTEMTIME,
538	pub rc: RECT,
539	pub iOffset: i32,
540	pub iRow: i32,
541	pub iCol: i32,
542}
543
544impl_default!(MCHITTESTINFO, cbSize);
545
546/// [`MONTHDAYSTATE`](https://learn.microsoft.com/en-us/windows/win32/controls/monthdaystate)
547/// struct.
548#[repr(transparent)]
549#[derive(Default, Clone, Copy, PartialEq, Eq)]
550pub struct MONTHDAYSTATE(u32);
551
552impl MONTHDAYSTATE {
553	/// Returns the state of the bit corresponding to the given day index.
554	///
555	/// # Panics
556	///
557	/// Panics if `index` is greater than 31.
558	#[must_use]
559	pub fn get_day(&self, index: u8) -> bool {
560		if index > 31 {
561			panic!("MONTHDAYSTATE max index is 31, tried to get {}.", index)
562		} else {
563			((self.0 >> index) & 1) != 0
564		}
565	}
566
567	/// Sets the state of the bit corresponding to the given day index.
568	///
569	/// # Panics
570	///
571	/// Panics if `index` is greater than 31.
572	pub fn set_day(&mut self, index: u8, state: bool) {
573		if index > 31 {
574			panic!("MONTHDAYSTATE max index is 31, tried to set {}.", index)
575		} else if state {
576			self.0 |= 1 << index;
577		} else {
578			self.0 &= !(1 << index);
579		}
580	}
581}
582
583/// [`NMBCDROPDOWN`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmbcdropdown)
584/// struct.
585#[repr(C)]
586pub struct NMBCDROPDOWN {
587	pub hdr: NMHDR,
588	pub rcButton: RECT,
589}
590
591/// [`NMBCHOTITEM`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmbchotitem)
592/// struct.
593#[repr(C)]
594pub struct NMBCHOTITEM {
595	pub hdr: NMHDR,
596	pub dwFlags: co::HICF,
597}
598
599/// [`NMCHAR`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmchar)
600/// struct.
601#[repr(C)]
602pub struct NMCHAR {
603	pub hdr: NMHDR,
604	pub ch: u32,
605	pub dwItemPrev: u32,
606	pub dwItemNext: u32,
607}
608
609/// [`NMCUSTOMDRAW`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmcustomdraw)
610/// struct.
611#[repr(C)]
612pub struct NMCUSTOMDRAW {
613	pub hdr: NMHDR,
614	pub dwDrawStage: co::CDDS,
615	pub hdc: HDC,
616	pub rc: RECT,
617	pub dwItemSpec: usize,
618	pub uItemState: co::CDIS,
619	pub lItemlParam: isize,
620}
621
622/// [`NMDATETIMECHANGE`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmdatetimechange)
623/// struct.
624#[repr(C)]
625pub struct NMDATETIMECHANGE {
626	pub nmhdr: NMHDR,
627	pub dwFlags: co::GDT,
628	pub st: SYSTEMTIME,
629}
630
631/// [`NMDATETIMEFORMAT`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmdatetimeformatw)
632/// struct.
633#[repr(C)]
634pub struct NMDATETIMEFORMAT<'a> {
635	pub nmhdr: NMHDR,
636	pszFormat: *mut u16,
637	pub st: SYSTEMTIME,
638	pszDisplay: *mut u16,
639	szDisplay: [u16; 64], // used as a buffer to pszDisplay
640
641	_pszFormat: PhantomData<&'a mut u16>,
642}
643
644impl_default!(NMDATETIMEFORMAT, 'a);
645
646impl<'a> NMDATETIMEFORMAT<'a> {
647	pub_fn_string_ptr_get_set!('a, pszFormat, set_pszFormat);
648
649	/// Returns the `pszDisplay` field.
650	#[must_use]
651	pub fn pszDisplay(&self) -> String {
652		unsafe { WString::from_wchars_nullt(self.pszDisplay) }.to_string()
653	}
654
655	/// Sets the `pszDisplay` field.
656	pub fn set_pszDisplay(&mut self, text: &str) {
657		WString::from_str(text).copy_to_slice(&mut self.szDisplay);
658	}
659}
660
661/// [`NMDATETIMEFORMATQUERY`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmdatetimeformatqueryw)
662/// struct.
663#[repr(C)]
664pub struct NMDATETIMEFORMATQUERY<'a> {
665	pub nmhdr: NMHDR,
666	pszFormat: *mut u16,
667	pub szMax: SIZE,
668
669	_pszFormat: PhantomData<&'a mut u16>,
670}
671
672impl_default!(NMDATETIMEFORMATQUERY, 'a);
673
674impl<'a> NMDATETIMEFORMATQUERY<'a> {
675	pub_fn_string_ptr_get_set!('a, pszFormat, set_pszFormat);
676}
677
678/// [`NMDATETIMESTRING`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmdatetimestringw)
679/// struct.
680#[repr(C)]
681pub struct NMDATETIMESTRING<'a> {
682	pub nmhdr: NMHDR,
683	pszUserString: *mut u16,
684	pub st: SYSTEMTIME,
685	pub dwFlags: co::GDT,
686
687	_pszUserString: PhantomData<&'a mut u16>,
688}
689
690impl_default!(NMDATETIMESTRING, 'a);
691
692impl<'a> NMDATETIMESTRING<'a> {
693	pub_fn_string_ptr_get_set!('a, pszUserString, set_pszUserString);
694}
695
696/// [`NMDATETIMEWMKEYDOWN`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmdatetimewmkeydownw)
697/// struct.
698#[repr(C)]
699pub struct NMDATETIMEWMKEYDOWN<'a> {
700	pub nmhdr: NMHDR,
701	pub nVirtKey: i32,
702	pszFormat: *mut u16,
703	pub st: SYSTEMTIME,
704
705	_pszFormat: PhantomData<&'a mut u16>,
706}
707
708impl_default!(NMDATETIMEWMKEYDOWN, 'a);
709
710impl<'a> NMDATETIMEWMKEYDOWN<'a> {
711	pub_fn_string_ptr_get_set!('a, pszFormat, set_pszFormat);
712}
713
714/// [`NMDAYSTATE`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmdaystate)
715/// struct.
716#[repr(C)]
717pub struct NMDAYSTATE<'a> {
718	pub nmhdr: NMHDR,
719	pub stStart: SYSTEMTIME,
720	cDayState: i32,
721	prgDayState: *mut MONTHDAYSTATE,
722
723	_prgDayState: PhantomData<&'a mut MONTHDAYSTATE>,
724}
725
726impl_default!(NMDAYSTATE, 'a);
727
728impl<'a> NMDAYSTATE<'a> {
729	pub_fn_array_buf_get_set!('a, prgDayState, set_prgDayState, cDayState, MONTHDAYSTATE);
730}
731
732/// [`NMHDDISPINFO`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmhddispinfow)
733/// struct.
734#[repr(C)]
735pub struct NMHDDISPINFO<'a> {
736	pub hdr: NMHDR,
737	pub iItem: i32,
738	pub mask: co::HDI,
739	pszText: *mut u16,
740	cchTextMax: i32,
741	pub iImage: i32,
742	pub lParam: isize,
743
744	_pszText: PhantomData<&'a mut u16>,
745}
746
747impl_default!(NMHDDISPINFO, 'a);
748
749impl<'a> NMHDDISPINFO<'a> {
750	pub_fn_string_buf_get_set!('a, pszText, set_pszText, raw_pszText, cchTextMax);
751}
752
753/// [`NMHDFILTERBTNCLICK`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmhdfilterbtnclick)
754/// struct.
755#[repr(C)]
756pub struct NMHDFILTERBTNCLICK {
757	pub hdr: NMHDR,
758	pub iItem: i32,
759	pub rc: RECT,
760}
761
762impl_default!(NMHDFILTERBTNCLICK);
763
764/// [`NMHDR`](https://learn.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-nmhdr)
765/// struct.
766#[repr(C)]
767#[derive(PartialEq, Eq)]
768pub struct NMHDR {
769	/// A window handle to the control sending the message.
770	pub hwndFrom: HWND,
771	idFrom: usize,
772	/// Notification code sent in
773	/// [`WM_NOTIFY`](https://learn.microsoft.com/en-us/windows/win32/controls/wm-notify).
774	pub code: NmhdrCode,
775}
776
777impl_default!(NMHDR);
778
779impl NMHDR {
780	/// Returns the `idFrom` field, the ID of the control sending the message.
781	#[must_use]
782	pub const fn idFrom(&self) -> u16 {
783		self.idFrom as _
784	}
785
786	/// Sets the `idFrom` field, the ID of the control sending the message.
787	pub const fn set_idFrom(&mut self, val: u16) {
788		self.idFrom = val as _
789	}
790}
791
792/// Notification code returned in [`NMHDR`](crate::NMHDR) struct. This code is
793/// convertible to/from the specific common control notification codes –
794/// [`LVN`](crate::co::LVN), [`TVN`](crate::co::TVN), etc.
795///
796/// # Examples
797///
798/// ```no_run
799/// use winsafe::{self as w, prelude::*, co};
800///
801/// // Convert LVN to NmhrCode:
802/// let code = w::NmhdrCode::from(co::LVN::ITEMCHANGED);
803///
804/// // Convert NmhrCode to LVN – fails it code is not a valid LVN:
805/// let lvn = co::LVN::try_from(code)?;
806/// # w::SysResult::Ok(())
807/// ```
808#[repr(transparent)]
809#[derive(Default, Clone, Copy, PartialEq, Eq)]
810pub struct NmhdrCode(i32);
811
812impl From<i32> for NmhdrCode {
813	fn from(v: i32) -> Self {
814		Self(v)
815	}
816}
817
818impl PartialOrd for NmhdrCode {
819	fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
820		self.0.partial_cmp(&other.0)
821	}
822}
823impl Ord for NmhdrCode {
824	fn cmp(&self, other: &Self) -> std::cmp::Ordering {
825		self.0.cmp(&other.0)
826	}
827}
828
829impl std::fmt::Display for NmhdrCode {
830	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
831		write!(f, "{}", self.0)
832	}
833}
834
835impl NmhdrCode {
836	#[must_use]
837	pub(crate) const fn new(v: i32) -> Self {
838		Self(v)
839	}
840
841	/// Returns the primitive integer underlying value.
842	///
843	/// This method is similar to [`Into`](std::convert::Into), but it is
844	/// `const`, therefore it can be used in
845	/// [const contexts](https://doc.rust-lang.org/reference/const_eval.html).
846	#[must_use]
847	pub const fn raw(&self) -> i32 {
848		self.0
849	}
850}
851
852/// [`NMHEADER`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmheaderw)
853/// struct.
854#[repr(C)]
855pub struct NMHEADER<'a> {
856	pub hdr: NMHDR,
857	pub iItem: i32,
858	pub iButton: i32,
859	pitem: *mut HDITEM<'a>,
860
861	_pitem: PhantomData<&'a mut HDITEM<'a>>,
862}
863
864impl_default!(NMHEADER, 'a);
865
866impl<'a> NMHEADER<'a> {
867	pub_fn_ptr_get_set!('a, pitem, set_pitem, HDITEM<'a>);
868}
869
870/// [`NMITEMACTIVATE`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmitemactivate)
871/// struct.
872#[repr(C)]
873pub struct NMITEMACTIVATE {
874	pub hdr: NMHDR,
875	pub iItem: i32,
876	pub iSubItem: i32,
877	pub uNewState: co::LVIS,
878	pub uOldState: co::LVIS,
879	pub uChanged: co::LVIF,
880	pub ptAction: POINT,
881	pub lParam: isize,
882	pub uKeyFlags: co::LVKF,
883}
884
885/// [`NMOBJECTNOTIFY`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmobjectnotify)
886/// struct.
887#[repr(C)]
888pub struct NMOBJECTNOTIFY<'a> {
889	pub hdr: NMHDR,
890	pub iItem: i32,
891	piid: *mut co::IID,
892	Object: COMPTR,
893	pub hrResult: co::HRESULT,
894	pub dwFlags: u32,
895
896	_piid: PhantomData<&'a mut co::IID>,
897}
898
899impl_default!(NMOBJECTNOTIFY, 'a);
900impl_drop_comptr!(Object, NMOBJECTNOTIFY, 'a);
901
902impl<'a> NMOBJECTNOTIFY<'a> {
903	pub_fn_ptr_get_set!('a, piid, set_piid, co::IID);
904	pub_fn_comptr_get_set!(Object, set_Object, ole_IUnknown);
905}
906
907/// [`NMIPADDRESS`](https://learn.microsoft.com/en-us/windows/win32/api/Commctrl/ns-commctrl-nmipaddress)
908/// struct.
909#[repr(C)]
910pub struct NMIPADDRESS {
911	pub hdr: NMHDR,
912	pub iField: i32,
913	pub iValue: i32,
914}
915
916/// [`NMLINK`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmlink)
917/// struct.
918#[repr(C)]
919pub struct NMLINK {
920	pub hdr: NMHDR,
921	pub item: LITEM,
922}
923
924/// [`NMLISTVIEW`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmlistview)
925/// struct.
926#[repr(C)]
927pub struct NMLISTVIEW {
928	pub hdr: NMHDR,
929	pub iItem: i32,
930	pub iSubItem: i32,
931	pub uNewState: co::LVIS,
932	pub uOldState: co::LVIS,
933	pub uChanged: co::LVIF,
934	pub ptAction: POINT,
935	pub lParam: isize,
936}
937
938/// [`NMLVCACHEHINT`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmlvcachehint)
939/// struct.
940#[repr(C)]
941pub struct NMLVCACHEHINT {
942	pub hdr: NMHDR,
943	pub iFrom: i32,
944	pub iTo: i32,
945}
946
947/// [`NMLVCUSTOMDRAW`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmlvcustomdraw)
948/// struct.
949#[repr(C)]
950pub struct NMLVCUSTOMDRAW {
951	pub mcd: NMCUSTOMDRAW,
952	pub clrText: COLORREF,
953	pub clrTextBk: COLORREF,
954	pub iSubItem: i32,
955	pub dwItemType: co::LVCDI,
956	pub clrFace: COLORREF,
957	pub iIconEffect: i32,
958	pub iIconPhase: i32,
959	pub iPartId: i32,
960	pub iStateId: i32,
961	pub rcText: RECT,
962	pub uAlign: co::LVGA_HEADER,
963}
964
965/// [`NMLVDISPINFO`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmlvdispinfow)
966/// struct.
967#[repr(C)]
968pub struct NMLVDISPINFO<'a> {
969	pub hdr: NMHDR,
970	pub item: LVITEM<'a>,
971}
972
973/// [`NMLVEMPTYMARKUP`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmlvemptymarkup)
974/// struct.
975#[repr(C)]
976pub struct NMLVEMPTYMARKUP {
977	pub hdr: NMHDR,
978	pub dwFlags: co::EMF,
979	szMarkup: [u16; L_MAX_URL_LENGTH],
980}
981
982impl_default!(NMLVEMPTYMARKUP);
983
984impl NMLVEMPTYMARKUP {
985	pub_fn_string_arr_get_set!(szMarkup, set_szMarkup);
986}
987
988/// [`NMLVFINDITEM`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmlvfinditemw)
989/// struct.
990#[repr(C)]
991pub struct NMLVFINDITEM<'a> {
992	pub hdr: NMHDR,
993	pub iStart: i32,
994	pub lvfi: LVFINDINFO<'a>,
995}
996
997/// [`NMLVGETINFOTIP`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmlvgetinfotipw)
998/// struct.
999#[repr(C)]
1000pub struct NMLVGETINFOTIP<'a> {
1001	pub hdr: NMHDR,
1002	pub dwFlags: co::LVGIT,
1003	pszText: *mut u16,
1004	cchTextMax: i32,
1005	pub iItem: i32,
1006	pub iSubItem: i32,
1007	pub lParam: isize,
1008
1009	_pszText: PhantomData<&'a mut u16>,
1010}
1011
1012impl_default!(NMLVGETINFOTIP, 'a);
1013
1014impl<'a> NMLVGETINFOTIP<'a> {
1015	pub_fn_string_buf_get_set!('a, pszText, set_pszText, raw_pszText, cchTextMax);
1016}
1017
1018/// [`NMLVKEYDOWN`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmlvkeydown)
1019/// struct.
1020#[repr(C)]
1021pub struct NMLVKEYDOWN {
1022	pub hdr: NMHDR,
1023	pub wVKey: co::VK,
1024	flags: u32,
1025}
1026
1027impl_default!(NMLVKEYDOWN);
1028
1029/// [`NMLVLINK`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmlvlink)
1030/// struct.
1031#[repr(C)]
1032pub struct NMLVLINK {
1033	pub hdr: NMHDR,
1034	pub link: LITEM,
1035	pub iItem: i32,
1036	pub iSubItem: i32,
1037}
1038
1039/// [`NMLVODSTATECHANGE`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmlvodstatechange)
1040/// struct.
1041#[repr(C)]
1042pub struct NMLVODSTATECHANGE {
1043	pub hdr: NMHDR,
1044	pub iFrom: i32,
1045	pub iTo: i32,
1046	pub uNewState: co::LVIS,
1047	pub uOldState: co::LVIS,
1048}
1049
1050/// [`NMLVSCROLL`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmlvscroll)
1051/// struct.
1052#[repr(C)]
1053pub struct NMLVSCROLL {
1054	pub hdr: NMHDR,
1055	pub dx: i32,
1056	pub dy: i32,
1057}
1058
1059/// [`NMMOUSE`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmmouse)
1060/// struct.
1061#[repr(C)]
1062pub struct NMMOUSE {
1063	pub hdr: NMHDR,
1064	pub dwItemSpec: usize,
1065	pub dwItemData: usize,
1066	pub pt: POINT,
1067	pub dwHitInfo: isize,
1068}
1069
1070/// [`NMTRBTHUMBPOSCHANGING`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmtrbthumbposchanging)
1071/// struct.
1072#[repr(C)]
1073pub struct NMTRBTHUMBPOSCHANGING {
1074	pub hdr: NMHDR,
1075	pub dwPos: u32,
1076	pub nReason: co::TB,
1077}
1078
1079/// [`NMSELCHANGE`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmselchange)
1080/// struct.
1081#[repr(C)]
1082pub struct NMSELCHANGE {
1083	pub nmhdr: NMHDR,
1084	pub stSelStart: SYSTEMTIME,
1085	pub stSelEnd: SYSTEMTIME,
1086}
1087
1088/// [`NMTCKEYDOWN`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmtckeydown)
1089/// struct.
1090#[repr(C)]
1091pub struct NMTCKEYDOWN {
1092	pub hdr: NMHDR,
1093	pub wVKey: co::VK,
1094	pub flags: u32,
1095}
1096
1097impl_default!(NMTCKEYDOWN);
1098
1099/// [`NMTREEVIEW`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmtreevieww)
1100/// struct.
1101#[repr(C)]
1102pub struct NMTREEVIEW<'a, 'b> {
1103	pub hdr: NMHDR,
1104	pub action: u32, // actual type varies
1105	pub itemOld: TVITEM<'a>,
1106	pub itemNew: TVITEM<'b>,
1107	pub ptDrag: POINT,
1108}
1109
1110/// [`NMTVCUSTOMDRAW`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmtvcustomdraw)
1111/// stuct.
1112#[repr(C)]
1113pub struct NMTVCUSTOMDRAW {
1114	pub nmcd: NMCUSTOMDRAW,
1115	pub clrText: COLORREF,
1116	pub clrTextBk: COLORREF,
1117	pub iLevel: i32,
1118}
1119
1120/// [`NMTVITEMCHANGE`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmtvitemchange)
1121/// struct.
1122#[repr(C)]
1123pub struct NMTVITEMCHANGE {
1124	pub hdr: NMHDR,
1125	pub uChanged: co::TVIF,
1126	pub hItem: HTREEITEM,
1127	pub uStateNew: co::TVIS,
1128	pub uStateOld: co::TVIS,
1129	pub lParam: isize,
1130}
1131
1132/// [`NMUPDOWN`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmupdown)
1133/// struct.
1134#[repr(C)]
1135pub struct NMUPDOWN {
1136	pub hdr: NMHDR,
1137	pub iPos: i32,
1138	pub iDelta: i32,
1139}
1140
1141/// [`NMVIEWCHANGE`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmviewchange)
1142/// struct.
1143#[repr(C)]
1144pub struct NMVIEWCHANGE {
1145	pub nmhdr: NMHDR,
1146	pub dwOldView: co::MCMV,
1147	pub dwNewView: co::MCMV,
1148}
1149
1150/// [`PBRANGE`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-pbrange)
1151/// struct.
1152#[repr(C)]
1153#[derive(Default, Clone, Copy, PartialEq, Eq)]
1154pub struct PBRANGE {
1155	pub iLow: i32,
1156	pub iHigh: i32,
1157}
1158
1159/// [`PROPSHEETHEADER`](https://learn.microsoft.com/en-us/windows/win32/controls/pss-propsheetheader)
1160/// struct.
1161#[repr(C)]
1162pub struct PROPSHEETHEADER<'a, 'b, 'c, 'd, 'e, 'f> {
1163	dwSize: u32,
1164	pub dwFlags: co::PSH,
1165	pub hwndParent: HWND,
1166	pub hInstance: HINSTANCE,
1167	hIcon_pszIcon: *mut std::ffi::c_void, // union
1168	pszCaption: *mut u16,
1169	pub nPages: u32,
1170	union0: PROPSHEETHEADER_union0,
1171	ppsp_phpage: *mut std::ffi::c_void, // union,
1172	pub pfnCallback: Option<PFNPROPSHEETCALLBACK>,
1173	hbmWatermark_pszbmWatermark: *mut std::ffi::c_void, // union
1174	pub hplWatermark: HPALETTE,
1175	hbmHeader_pszbmHeader: *mut std::ffi::c_void, // union
1176
1177	_pszIcon: PhantomData<&'a u16>,
1178	_pszTitle: PhantomData<&'b mut u16>,
1179	_pStartPage: PhantomData<&'c mut u16>,
1180	_ppsp_phpage: PhantomData<&'d [PROPSHEETPAGE<'d, 'd, 'd, 'd, 'd, 'd, 'd>]>,
1181	_pszbmWatermark: PhantomData<&'e mut u16>,
1182	_pszbmHeader: PhantomData<&'f mut u16>,
1183}
1184
1185#[repr(C)]
1186union PROPSHEETHEADER_union0 {
1187	nStartPage: u32,
1188	pStartPage: *const u16,
1189}
1190
1191impl_default!(PROPSHEETHEADER, dwSize, 'a, 'b, 'c, 'd, 'e, 'f);
1192
1193impl<'a, 'b, 'c, 'd, 'e, 'f> PROPSHEETHEADER<'a, 'b, 'c, 'd, 'e, 'f> {
1194	/// Sets the `hIcon` field, which is part of an union.
1195	pub fn set_hIcon(&mut self, hicon: HICON) {
1196		self.hIcon_pszIcon = hicon.ptr();
1197	}
1198
1199	/// Sets the `pszIcon` field, which is part of an union.
1200	pub fn set_pszIcon(&mut self, buf: &'a mut IdStr) {
1201		self.hIcon_pszIcon = match buf {
1202			IdStr::Id(id) => *id as _,
1203			IdStr::Str(wstr) => unsafe { wstr.as_mut_ptr() as _ },
1204		};
1205	}
1206
1207	pub_fn_string_ptr_get_set!('b, pszCaption, set_pszCaption);
1208
1209	/// Sets the `nStartPage` field, which is part of an union.
1210	pub const fn set_nStartPage(&mut self, n: u32) {
1211		self.union0.nStartPage = n;
1212	}
1213
1214	/// Sets the `pStartPage` field, which is part of an union.
1215	pub fn set_pStartPage(&mut self, buf: &'c mut WString) {
1216		self.union0.pStartPage = unsafe { buf.as_mut_ptr() } as _;
1217	}
1218
1219	/// Sets the `ppsp` field, which is part of an union.
1220	pub const fn set_ppsp(&mut self, pages: &'d [PROPSHEETPAGE]) {
1221		self.ppsp_phpage = pages as *const _ as _;
1222	}
1223
1224	/// Sets the `phpage` field, which is part of an union.
1225	pub const fn set_phpage(&mut self, pages: &'d [HPROPSHEETPAGE]) {
1226		self.ppsp_phpage = pages as *const _ as _;
1227	}
1228
1229	/// Sets the `hbmWatermark` field, which is part of an union.
1230	pub fn set_hbmWatermark(&mut self, hbm: HBITMAP) {
1231		self.hbmWatermark_pszbmWatermark = hbm.ptr();
1232	}
1233
1234	/// Sets the `pszbmWatermark` field, which is part of an union.
1235	pub fn set_pszbmWatermark(&mut self, buf: &'e mut IdStr) {
1236		self.hbmWatermark_pszbmWatermark = match buf {
1237			IdStr::Id(id) => *id as _,
1238			IdStr::Str(wstr) => unsafe { wstr.as_mut_ptr() as _ },
1239		};
1240	}
1241
1242	/// Sets the `hbmHeader` field, which is part of an union.
1243	pub fn set_hbmHeader(&mut self, hbm: HBITMAP) {
1244		self.hbmHeader_pszbmHeader = hbm.ptr();
1245	}
1246
1247	/// Sets the `pszbmHeader` field, which is part of an union.
1248	pub fn set_pszbmHeader(&mut self, buf: &'f mut IdStr) {
1249		self.hbmHeader_pszbmHeader = match buf {
1250			IdStr::Id(id) => *id as _,
1251			IdStr::Str(wstr) => unsafe { wstr.as_mut_ptr() as _ },
1252		};
1253	}
1254}
1255
1256/// [`PROPSHEETPAGE`](https://learn.microsoft.com/en-us/windows/win32/controls/pss-propsheetpage)
1257/// struct.
1258#[repr(C)]
1259pub struct PROPSHEETPAGE<'a, 'b, 'c, 'd, 'e, 'f, 'g> {
1260	dwSize: u32,
1261	pub dwFlags: co::PSP,
1262	pub hInstance: HINSTANCE,
1263	pszTemplate_pResource: *mut std::ffi::c_void, // union
1264	hIcon_pszIcon: *mut std::ffi::c_void,         // union
1265	pszTitle: *mut u16,
1266	pub pfnDlgProc: Option<DLGPROC>,
1267	pub lParam: isize,
1268	pub pfnCallback: Option<LPFNPSPCALLBACK>,
1269	pcRefParent: *mut u32,
1270	pszHeaderTitle: *mut u16,
1271	pszHeaderSubTitle: *mut u16,
1272	pub hActCtx: *mut std::ffi::c_void,
1273	hbmHeader_pszbmHeader: *mut std::ffi::c_void, // union
1274
1275	_pszTemplate: PhantomData<&'a mut u16>,
1276	_pszIcon: PhantomData<&'b mut u16>,
1277	_pszTitle: PhantomData<&'c mut u16>,
1278	_pcRefParent: PhantomData<&'d mut u32>,
1279	_pszHeaderTitle: PhantomData<&'e mut u16>,
1280	_pszHeaderSubTitle: PhantomData<&'f mut u16>,
1281	_pszbmHeader: PhantomData<&'g u16>,
1282}
1283
1284impl_default!(PROPSHEETPAGE, dwSize, 'a, 'b, 'c, 'd, 'e, 'f, 'g);
1285
1286impl<'a, 'b, 'c, 'd, 'e, 'f, 'g> PROPSHEETPAGE<'a, 'b, 'c, 'd, 'e, 'f, 'g> {
1287	/// Sets the `pszTemplate` field, which is part of an union.
1288	pub fn set_pszTemplate(&mut self, buf: &'a mut IdStr) {
1289		self.pszTemplate_pResource = match buf {
1290			IdStr::Id(id) => *id as _,
1291			IdStr::Str(wstr) => unsafe { wstr.as_mut_ptr() as _ },
1292		};
1293	}
1294
1295	/// Sets the `pResource` field, which is part of an union.
1296	pub const fn set_pResource(&mut self, r: &DLGTEMPLATE) {
1297		self.pszTemplate_pResource = r as *const _ as _;
1298	}
1299
1300	/// Sets the `hIcon` field, which is part of an union.
1301	pub fn set_hIcon(&mut self, hicon: HICON) {
1302		self.hIcon_pszIcon = hicon.ptr();
1303	}
1304
1305	/// Sets the `pszIcon` field, which is part of an union.
1306	pub fn set_pszIcon(&mut self, buf: &'b mut IdStr) {
1307		self.hIcon_pszIcon = match buf {
1308			IdStr::Id(id) => *id as _,
1309			IdStr::Str(wstr) => unsafe { wstr.as_mut_ptr() as _ },
1310		};
1311	}
1312
1313	pub_fn_string_ptr_get_set!('c, pszTitle, set_pszTitle);
1314
1315	/// Sets the `pcRefParent` field.
1316	pub const fn set_pcRefParent(&mut self, ref_count: &'d mut u32) {
1317		self.pcRefParent = ref_count;
1318	}
1319
1320	pub_fn_string_ptr_get_set!('e, pszHeaderTitle, set_pszHeaderTitle);
1321	pub_fn_string_ptr_get_set!('f, pszHeaderSubTitle, set_pszHeaderSubTitle);
1322
1323	/// Sets the `hbmHeader` field, which is part of an union.
1324	pub fn set_hbmHeader(&mut self, hbm: HBITMAP) {
1325		self.hbmHeader_pszbmHeader = hbm.ptr();
1326	}
1327
1328	/// Sets the `pszbmHeader` field, which is part of an union.
1329	pub fn set_pszbmHeader(&mut self, buf: &'g mut IdStr) {
1330		self.hbmHeader_pszbmHeader = match buf {
1331			IdStr::Id(id) => *id as _,
1332			IdStr::Str(wstr) => unsafe { wstr.as_mut_ptr() as _ },
1333		};
1334	}
1335}
1336
1337/// [`TBADDBITMAP`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-tbaddbitmap)
1338/// struct.
1339#[repr(C)]
1340pub struct TBADDBITMAP {
1341	hInst: HINSTANCE,
1342	nID: usize,
1343}
1344
1345impl_default!(TBADDBITMAP);
1346
1347impl TBADDBITMAP {
1348	/// Returns the `hInst` and `nID` fields.
1349	#[must_use]
1350	pub fn nID(&self) -> BmpIdbRes {
1351		if self.hInst.ptr() as isize == HINST_COMMCTRL {
1352			BmpIdbRes::Idb(unsafe { co::IDB::from_raw(self.nID) })
1353		} else if self.hInst == HINSTANCE::NULL {
1354			BmpIdbRes::Bmp(unsafe { HBITMAP::from_ptr(self.nID as _) })
1355		} else {
1356			unsafe { BmpIdbRes::Res(IdStr::from_ptr(self.nID as _), self.hInst.raw_copy()) }
1357		}
1358	}
1359
1360	/// Sets the `hInst` and `nID` fields.
1361	pub fn set_nID(&mut self, val: &BmpIdbRes) {
1362		*self = match val {
1363			BmpIdbRes::Idb(idb) => Self {
1364				hInst: unsafe { HINSTANCE::from_ptr(HINST_COMMCTRL as _) },
1365				nID: idb.raw(),
1366			},
1367			BmpIdbRes::Bmp(bmp) => Self {
1368				hInst: HINSTANCE::NULL,
1369				nID: bmp.ptr() as _,
1370			},
1371			BmpIdbRes::Res(res, hInst) => Self {
1372				hInst: unsafe { hInst.raw_copy() },
1373				nID: res.as_ptr() as _,
1374			},
1375		}
1376	}
1377}
1378
1379/// [`TBBUTTON`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-tbbutton)
1380/// struct.
1381#[repr(C)]
1382pub struct TBBUTTON<'a> {
1383	pub iBitmap: i32,
1384	pub idCommand: i32,
1385	pub fsState: co::TBSTATE,
1386	pub fsStyle: co::BTNS,
1387	bReserved: [u8; 6], // assumes 64-bit architecture
1388	pub dwData: usize,
1389	iString: isize,
1390
1391	_iString: PhantomData<&'a mut u16>,
1392}
1393
1394impl_default!(TBBUTTON, 'a);
1395
1396impl<'a> TBBUTTON<'a> {
1397	/// Returns the `iString` field.
1398	#[must_use]
1399	pub fn iString(&self) -> IdxStr {
1400		if IS_INTRESOURCE(self.iString as _) {
1401			IdxStr::Idx(self.iString as _)
1402		} else {
1403			IdxStr::Str(unsafe { WString::from_wchars_nullt(self.iString as _) })
1404		}
1405	}
1406
1407	/// Sets the `iString` field.
1408	pub fn set_iString(&mut self, val: &'a mut IdxStr) {
1409		self.iString = match val {
1410			IdxStr::Idx(i) => *i as _,
1411			IdxStr::Str(s) => unsafe { s.as_mut_ptr() as _ },
1412		};
1413	}
1414}
1415
1416/// [`TBBUTTONINFO`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-tbbuttoninfow)
1417/// struct.
1418#[repr(C)]
1419pub struct TBBUTTONINFO<'a> {
1420	cbSize: u32,
1421	pub dwMask: co::TBIF,
1422	pub idCommand: i32,
1423	pub iImage: i32,
1424	pub fsState: co::TBSTATE,
1425	pub fsStyle: co::BTNS,
1426	pub cx: u16,
1427	pub lParam: usize,
1428	pszText: *mut u16,
1429	cchText: i32,
1430
1431	_pszText: PhantomData<&'a mut u16>,
1432}
1433
1434impl_default!(TBBUTTONINFO, cbSize, 'a);
1435
1436impl<'a> TBBUTTONINFO<'a> {
1437	pub_fn_string_buf_get_set!('a, pszText, set_pszText, raw_pszText, cchText);
1438}
1439
1440/// [`TBINSERTMARK`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-tbinsertmark)
1441/// struct.
1442#[repr(C)]
1443#[derive(Default)]
1444pub struct TBINSERTMARK {
1445	pub iButton: i32,
1446	pub dwFlags: co::TBIMHT,
1447}
1448
1449/// [`TBMETRICS`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-tbmetrics)
1450/// struct.
1451#[repr(C)]
1452pub struct TBMETRICS {
1453	cbSize: u32,
1454	pub dwMask: co::TBMF,
1455	pub cxPad: i32,
1456	pub cyPad: i32,
1457	pub cxBarPad: i32,
1458	pub cyBarPad: i32,
1459	pub cxButtonSpacing: i32,
1460	pub cyButtonSpacing: i32,
1461}
1462
1463impl_default!(TBMETRICS, cbSize);
1464
1465/// [`TBREPLACEBITMAP`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-tbreplacebitmap)
1466/// struct.
1467#[repr(C)]
1468pub struct TBREPLACEBITMAP {
1469	hInstOld: HINSTANCE,
1470	nIDOld: usize,
1471	hInstNew: HINSTANCE,
1472	nIDNew: usize,
1473	pub nButtons: i32,
1474}
1475
1476impl_default!(TBREPLACEBITMAP);
1477
1478impl TBREPLACEBITMAP {
1479	/// Returns the `hInstOld` and `nIDOld` fields.
1480	#[must_use]
1481	pub fn olds(&self) -> BmpInstId {
1482		if self.hInstOld == HINSTANCE::NULL {
1483			BmpInstId::Bmp(unsafe { HBITMAP::from_ptr(self.nIDOld as _) })
1484		} else {
1485			BmpInstId::InstId(unsafe { self.hInstOld.raw_copy() }, self.nIDOld as _)
1486		}
1487	}
1488
1489	/// Sets the `hInstOld` and `nIDOld` fields.
1490	pub fn set_olds(&mut self, val: BmpInstId) {
1491		match val {
1492			BmpInstId::Bmp(hbmp) => {
1493				self.hInstOld = HINSTANCE::NULL;
1494				self.nIDOld = hbmp.ptr() as _;
1495			},
1496			BmpInstId::InstId(hinst, id) => {
1497				self.hInstOld = hinst;
1498				self.nIDOld = id as _;
1499			},
1500		}
1501	}
1502
1503	/// Returns the `hInstNew` and `nIDNew` fields.
1504	#[must_use]
1505	pub fn news(&self) -> BmpInstId {
1506		if self.hInstNew == HINSTANCE::NULL {
1507			BmpInstId::Bmp(unsafe { HBITMAP::from_ptr(self.nIDNew as _) })
1508		} else {
1509			BmpInstId::InstId(unsafe { self.hInstNew.raw_copy() }, self.nIDNew as _)
1510		}
1511	}
1512
1513	/// Sets the `hInstNew` and `nIDNew` fields.
1514	pub fn set_news(&mut self, val: BmpInstId) {
1515		match val {
1516			BmpInstId::Bmp(hbmp) => {
1517				self.hInstNew = HINSTANCE::NULL;
1518				self.nIDNew = hbmp.ptr() as _;
1519			},
1520			BmpInstId::InstId(hinst, id) => {
1521				self.hInstNew = hinst;
1522				self.nIDNew = id as _;
1523			},
1524		}
1525	}
1526}
1527
1528/// [`TCHITTESTINFO`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-tchittestinfo)
1529/// struct.
1530#[repr(C)]
1531pub struct TCHITTESTINFO {
1532	pub pt: POINT,
1533	pub flags: co::TCHT,
1534}
1535
1536impl_default!(TCHITTESTINFO);
1537
1538/// [`TCITEM`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-tcitemw)
1539/// struct.
1540#[repr(C)]
1541pub struct TCITEM<'a> {
1542	pub mask: co::TCIF,
1543	pub dwState: co::TCIS,
1544	pub dwStateMask: co::TCIS,
1545	pszText: *mut u16,
1546	cchTextMax: i32,
1547	pub iImage: i32,
1548	pub lParam: isize,
1549
1550	_pszText: PhantomData<&'a mut u16>,
1551}
1552
1553impl_default!(TCITEM, 'a);
1554
1555impl<'a> TCITEM<'a> {
1556	pub_fn_string_buf_get_set!('a, pszText, set_pszText, raw_pszText, cchTextMax);
1557}
1558
1559/// [`TVHITTESTINFO`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-tvhittestinfo)
1560/// struct.
1561#[repr(C)]
1562pub struct TVHITTESTINFO {
1563	pub pt: POINT,
1564	pub flags: co::TVHT,
1565	pub hitem: HTREEITEM,
1566}
1567
1568/// [`TVINSERTSTRUCT`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-tvinsertstructw)
1569/// struct.
1570#[repr(C)]
1571pub struct TVINSERTSTRUCT<'a> {
1572	pub hParent: HTREEITEM,
1573	hInsertAfter: isize,
1574	pub itemex: TVITEMEX<'a>,
1575}
1576
1577impl_default!(TVINSERTSTRUCT, 'a);
1578
1579impl<'a> TVINSERTSTRUCT<'a> {
1580	/// Returns the `hInsertAfter` field.
1581	#[must_use]
1582	pub fn hInsertAfter(&self) -> TreeitemTvi {
1583		TreeitemTvi::from_isize(self.hInsertAfter)
1584	}
1585
1586	/// Sets the `hInsertAfter` field.
1587	pub fn set_hInsertAfter(&mut self, val: TreeitemTvi) {
1588		self.hInsertAfter = val.into();
1589	}
1590}
1591
1592/// [`TVITEMEX`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-tvitemexw)
1593/// struct.
1594#[repr(C)]
1595pub struct TVITEMEX<'a> {
1596	pub mask: co::TVIF,
1597	pub hItem: HTREEITEM,
1598	pub state: co::TVIS,
1599	pub stateMask: co::TVIS,
1600	pszText: *mut u16,
1601	cchTextMax: i32,
1602	pub iImage: i32,
1603	pub iSelectedImage: i32,
1604	pub cChildren: i32,
1605	pub lParam: isize,
1606	pub iIntegral: i32,
1607	pub uStateEx: co::TVIS_EX,
1608	hwnd: HWND,
1609	pub iExpandedImage: i32,
1610	iReserved: i32,
1611
1612	_pszText: PhantomData<&'a mut u16>,
1613}
1614
1615impl_default!(TVITEMEX, 'a);
1616
1617impl<'a> TVITEMEX<'a> {
1618	pub_fn_string_buf_get_set!('a, pszText, set_pszText, raw_pszText, cchTextMax);
1619}
1620
1621/// [`TVITEM`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-tvitemw)
1622/// struct.
1623#[repr(C)]
1624pub struct TVITEM<'a> {
1625	pub mask: co::TVIF,
1626	pub hItem: HTREEITEM,
1627	pub state: co::TVIS,
1628	pub stateMask: co::TVIS,
1629	pszText: *mut u16,
1630	cchTextMax: i32,
1631	pub iImage: i32,
1632	pub iSelectedImage: i32,
1633	pub cChildren: i32,
1634	pub lParam: isize,
1635
1636	_pszText: PhantomData<&'a mut u16>,
1637}
1638
1639impl_default!(TVITEM, 'a);
1640
1641impl<'a> TVITEM<'a> {
1642	pub_fn_string_buf_get_set!('a, pszText, set_pszText, raw_pszText, cchTextMax);
1643}
1644
1645/// [`TVSORTCB`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-tvsortcb)
1646/// struct.
1647#[repr(C)]
1648pub struct TVSORTCB {
1649	pub hParent: HTREEITEM,
1650	pub lpfnCompare: Option<PFNTVCOMPARE>,
1651	pub lParam: isize,
1652}
1653
1654impl_default!(TVSORTCB);
1655
1656/// [`UDACCEL`](https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-udaccel)
1657/// struct.
1658#[repr(C)]
1659#[derive(Default)]
1660pub struct UDACCEL {
1661	pub nSec: u32,
1662	pub nInc: u32,
1663}