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§

source

unsafe fn DefSubclassProc<M>(&self, msg: M) -> M::RetType
where 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.

source

fn InitializeFlatSB(&self) -> HrResult<()>

InitializeFlatSB function.

source

fn RemoveWindowSubclass( &self, subclass_func: SUBCLASSPROC, subclass_id: usize ) -> SysResult<()>

source

unsafe fn SetWindowSubclass( &self, subclass_proc: SUBCLASSPROC, subclass_id: usize, ref_data: usize ) -> SysResult<()>

SetWindowSubclass function.

§Safety

You must provide a subclass procedure.

source

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.");
}
source

fn UninitializeFlatSB(&self) -> HrResult<()>

Object Safety§

This trait is not object safe.

Implementors§