Trait winsafe::prelude::comctl_Hwnd
source · pub trait comctl_Hwnd: user_Hwnd {
// Provided methods
unsafe fn DefSubclassProc<M>(&self, msg: M) -> M::RetType
where M: MsgSend { ... }
fn InitializeFlatSB(&self) -> HrResult<()> { ... }
fn RemoveWindowSubclass(
&self,
subclass_func: SUBCLASSPROC,
subclass_id: usize
) -> SysResult<()> { ... }
unsafe fn SetWindowSubclass(
&self,
subclass_proc: SUBCLASSPROC,
subclass_id: usize,
ref_data: usize
) -> SysResult<()> { ... }
fn TaskDialog(
&self,
window_title: Option<&str>,
main_instruction: Option<&str>,
content: Option<&str>,
common_buttons: TDCBF,
icon: IconRes<'_>
) -> HrResult<DLGID> { ... }
fn UninitializeFlatSB(&self) -> HrResult<()> { ... }
}
Available on crate features
kernel
and comctl
only.Expand description
This trait is enabled with the comctl
feature, and provides methods for
HWND
.
Prefer importing this trait through the prelude:
use winsafe::prelude::*;
Provided Methods§
sourceunsafe fn DefSubclassProc<M>(&self, msg: M) -> M::RetTypewhere
M: MsgSend,
unsafe fn DefSubclassProc<M>(&self, msg: M) -> M::RetTypewhere
M: MsgSend,
DefSubclassProc
function.
The return type is variable, being defined by the RetType
associated
type of the MsgSend
trait. That means each
message can define its own return type.
§Safety
Messages manipulate pointers, copies and window states. Improper use may lead to undefined behavior.
sourcefn InitializeFlatSB(&self) -> HrResult<()>
fn InitializeFlatSB(&self) -> HrResult<()>
InitializeFlatSB
function.
sourcefn RemoveWindowSubclass(
&self,
subclass_func: SUBCLASSPROC,
subclass_id: usize
) -> SysResult<()>
fn RemoveWindowSubclass( &self, subclass_func: SUBCLASSPROC, subclass_id: usize ) -> SysResult<()>
RemoveWindowSubclass
function.
sourceunsafe fn SetWindowSubclass(
&self,
subclass_proc: SUBCLASSPROC,
subclass_id: usize,
ref_data: usize
) -> SysResult<()>
unsafe fn SetWindowSubclass( &self, subclass_proc: SUBCLASSPROC, subclass_id: usize, ref_data: usize ) -> SysResult<()>
sourcefn TaskDialog(
&self,
window_title: Option<&str>,
main_instruction: Option<&str>,
content: Option<&str>,
common_buttons: TDCBF,
icon: IconRes<'_>
) -> HrResult<DLGID>
fn TaskDialog( &self, window_title: Option<&str>, main_instruction: Option<&str>, content: Option<&str>, common_buttons: TDCBF, icon: IconRes<'_> ) -> HrResult<DLGID>
TaskDialog
function.
If you need more customization, see the
TaskDialogIndirect
function.
§Examples
An information message with just an OK button:
use winsafe::{self as w, prelude::*, co};
let hwnd: w::HWND; // initialized somewhere
hwnd.TaskDialog(
Some("Operation successful"),
None,
Some("The operation completed successfully."),
co::TDCBF::OK,
w::IconRes::Info,
)?;
Prompt the user to click OK or Cancel upon a question:
use winsafe::{self as w, prelude::*, co};
let hwnd: w::HWND; // initialized somewhere
let answer = hwnd.TaskDialog(
Some("My app name"),
Some("File modified"),
Some("The file has been modified.\nProceed closing the application?"),
co::TDCBF::OK | co::TDCBF::CANCEL,
w::IconRes::Warn,
)?;
if answer == co::DLGID::OK {
println!("User clicked OK.");
}
sourcefn UninitializeFlatSB(&self) -> HrResult<()>
fn UninitializeFlatSB(&self) -> HrResult<()>
UninitializeFlatSB
function.
Object Safety§
This trait is not object safe.