Struct winsafe::HMENU[][src]

#[repr(C)]
pub struct HMENU { /* fields omitted */ }
Expand description

Handle to a menu.

Implementations

The null, invalid handle.

This constant is common to all handle types.

Creates a new handle instance by wrapping a pointer.

This method is common to all handle types.

Consumes the handle returning the underlying raw pointer.

This method is common to all handle types.

Tells if the handle is invalid (null).

This method is common to all handle types.

Consumes the handle into an option, which is None if the handle pointer is null.

This method is common to all handle types.

AppendMenu method.

This method is rather tricky, consider using HMENU::AppendMenuEnum.

A more convenient HMENU::AppendMenu.

Examples

Adding multiple entries at once, with their command IDs:

use winsafe::{HMENU, MenuEnum};

let my_hmenu: HMENU; // initialized somewhere

const ID_FILE_OPEN: i32 = 2001;
const ID_FILE_SAVE: i32 = 2002;
const ID_FILE_EXIT: i32 = 2003;

my_hmenu.AppendMenuEnum(&[
    MenuEnum::Entry(ID_FILE_OPEN, "&Open"),
    MenuEnum::Entry(ID_FILE_OPEN, "&Save"),
    MenuEnum::Separator,
    MenuEnum::Entry(ID_FILE_EXIT, "E&xit"),
])?;

CheckMenuItem method.

CheckMenuRadioItem method.

Panics

Panics if first, last and check don’t use the same enum field.

CreateMenu static method.

Note: If not attached to a window, must be paired with an HMENU::DestroyMenu call.

CreatePopupMenu static method.

Note: If not attached to a window, must be paired with an HMENU::DestroyMenu call.

DeleteMenu method.

DestroyMenu method.

EnableMenuItem method.

Examples

Disabling a menu item:

use winsafe::{HMENU, IdPos};

const ID_FILE_OPEN: i32 = 101;

let hmenu: HMENU; // initialized somewhere

hmenu.EnableMenuItem(
    IdPos::Id(ID_FILE_OPEN),
    false,
)?;

Disabling multiple menu items at once:

use winsafe::{HMENU, IdPos};

const ID_FILE_OPEN: i32 = 201;
const ID_FILE_SAVE: i32 = 202;

let hmenu: HMENU; // initialized somewhere

[
    (ID_FILE_OPEN, "Open\tCtrl+O"),
    (ID_FILE_SAVE, "&Save"),
].iter()
    .map(|(id, txt)| hmenu.EnableMenuItem(
        IdPos::Id(*id),
        false,
    ))
    .collect::<Result<Vec<_>, _>>()?;

GetMenuInfo method.

GetMenuItemID method.

GetMenuState method.

GetMenuString method.

GetSubMenu method.

IsMenu method.

RemoveMenu method.

SetMenuInfo method.

TrackPopupMenu method.

Note: If you just want to display a popup menu, consider the simpler HMENU::TrackPopupMenuAtPoint.

Shows the popup menu anchored at the given coordinates using TrackPopupMenu, and performs other needed operations.

This method will block until the menu disappears.

Trait Implementations

Formats the value using the given formatter.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter.

Formats the value using the given formatter.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Formats the value using the given formatter.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.