winsafe\shell\com_interfaces/itaskbarlist3.rs
1#![allow(non_camel_case_types, non_snake_case)]
2
3use crate::co;
4use crate::decl::*;
5use crate::kernel::privs::*;
6use crate::ole::privs::*;
7use crate::prelude::*;
8use crate::shell::vts::*;
9
10com_interface! { ITaskbarList3: "ea1afb91-9e28-4b86-90e9-9e9f8a5eefaf";
11 /// [`ITaskbarList3`](https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nn-shobjidl_core-itaskbarlist3)
12 /// COM interface.
13 ///
14 /// Automatically calls
15 /// [`IUnknown::Release`](https://learn.microsoft.com/en-us/windows/win32/api/unknwn/nf-unknwn-iunknown-release)
16 /// when the object goes out of scope.
17 ///
18 /// # Examples
19 ///
20 /// ```no_run
21 /// use winsafe::{self as w, prelude::*, co};
22 ///
23 /// let obj = w::CoCreateInstance::<w::ITaskbarList3>(
24 /// &co::CLSID::TaskbarList,
25 /// None::<&w::IUnknown>,
26 /// co::CLSCTX::INPROC_SERVER,
27 /// )?;
28 /// # w::HrResult::Ok(())
29 /// ```
30}
31
32impl shell_ITaskbarList for ITaskbarList3 {}
33impl shell_ITaskbarList2 for ITaskbarList3 {}
34impl shell_ITaskbarList3 for ITaskbarList3 {}
35
36/// This trait is enabled with the `shell` feature, and provides methods for
37/// [`ITaskbarList3`](crate::ITaskbarList3).
38///
39/// Prefer importing this trait through the prelude:
40///
41/// ```no_run
42/// use winsafe::prelude::*;
43/// ```
44pub trait shell_ITaskbarList3: shell_ITaskbarList2 {
45 /// [`ITaskbarList3::RegisterTab`](https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist3-registertab)
46 /// method.
47 fn RegisterTab(&self, hwnd_tab: &HWND, hwnd_mdi: &HWND) -> HrResult<()> {
48 ok_to_hrresult(unsafe {
49 (vt::<ITaskbarList3VT>(self).RegisterTab)(self.ptr(), hwnd_tab.ptr(), hwnd_mdi.ptr())
50 })
51 }
52
53 /// [`ITaskbarList3::SetOverlayIcon`](https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist3-setoverlayicon)
54 /// method.
55 fn SetOverlayIcon(
56 &self,
57 hwnd: &HWND,
58 hicon: Option<&HICON>,
59 description: &str,
60 ) -> HrResult<()> {
61 ok_to_hrresult(unsafe {
62 (vt::<ITaskbarList3VT>(self).SetOverlayIcon)(
63 self.ptr(),
64 hwnd.ptr(),
65 hicon.map_or(std::ptr::null_mut(), |h| h.ptr()),
66 WString::from_str(description).as_ptr(),
67 )
68 })
69 }
70
71 /// [`ITaskbarList3::SetProgressState`](https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist3-setprogressstate)
72 /// method.
73 fn SetProgressState(&self, hwnd: &HWND, tbpf_flags: co::TBPF) -> HrResult<()> {
74 ok_to_hrresult(unsafe {
75 (vt::<ITaskbarList3VT>(self).SetProgressState)(self.ptr(), hwnd.ptr(), tbpf_flags.raw())
76 })
77 }
78
79 /// [`ITaskbarList3::SetProgressValue`](https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist3-setprogressvalue)
80 /// method.
81 ///
82 /// # Examples
83 ///
84 /// Setting progress to 50%:
85 ///
86 /// ```no_run
87 /// use winsafe::{self as w, prelude::*};
88 ///
89 /// let tbar: w::ITaskbarList3; // initialized somewhere
90 /// # let tbar = unsafe { w::ITaskbarList3::null() };
91 /// let hwnd: w::HWND;
92 /// # let hwnd = w::HWND::NULL;
93 ///
94 /// tbar.SetProgressValue(&hwnd, 50, 100)?;
95 /// # w::HrResult::Ok(())
96 /// ```
97 fn SetProgressValue(&self, hwnd: &HWND, completed: u64, total: u64) -> HrResult<()> {
98 ok_to_hrresult(unsafe {
99 (vt::<ITaskbarList3VT>(self).SetProgressValue)(self.ptr(), hwnd.ptr(), completed, total)
100 })
101 }
102
103 /// [`ITaskbarList3::SetTabActive`](https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist3-settabactive)
104 /// method.
105 fn SetTabActive(&self, hwnd_tab: &HWND, hwnd_mdi: &HWND) -> HrResult<()> {
106 ok_to_hrresult(unsafe {
107 (vt::<ITaskbarList3VT>(self).SetTabActive)(
108 self.ptr(),
109 hwnd_tab.ptr(),
110 hwnd_mdi.ptr(),
111 0,
112 )
113 })
114 }
115
116 /// [`ITaskbarList3::SetTabOrder`](https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist3-settaborder)
117 /// method.
118 fn SetTabOrder(&self, hwnd_tab: &HWND, hwnd_insert_before: &HWND) -> HrResult<()> {
119 ok_to_hrresult(unsafe {
120 (vt::<ITaskbarList3VT>(self).SetTabOrder)(
121 self.ptr(),
122 hwnd_tab.ptr(),
123 hwnd_insert_before.ptr(),
124 )
125 })
126 }
127
128 /// [`ITaskbarList3::SetThumbnailClip`](https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist3-setthumbnailclip)
129 /// method.
130 fn SetThumbnailClip(&self, hwnd: &HWND, clip: Option<RECT>) -> HrResult<()> {
131 ok_to_hrresult(unsafe {
132 (vt::<ITaskbarList3VT>(self).SetThumbnailClip)(
133 self.ptr(),
134 hwnd.ptr(),
135 pcvoid_or_null(clip.as_ref()),
136 )
137 })
138 }
139
140 /// [`ITaskbarList3::SetThumbnailTooltip`](https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist3-setthumbnailtooltip)
141 /// method.
142 fn SetThumbnailTooltip(&self, hwnd: &HWND, tip: Option<&str>) -> HrResult<()> {
143 ok_to_hrresult(unsafe {
144 (vt::<ITaskbarList3VT>(self).SetThumbnailTooltip)(
145 self.ptr(),
146 hwnd.ptr(),
147 WString::from_opt_str(tip).as_ptr(),
148 )
149 })
150 }
151}