Struct EmbedResource

Source
pub struct EmbedResource {
    pub hinst: HINSTANCE,
}
Expand description

EmbedResource represent an embed resource file (“.rc”) inside on the executable module.

By default (without any arguments), the embed resources wraps the executable. If the embed resources are in a dll, it’s also possible to load them by setting the “module” parameter to the dll name.

Builder parameters: * module: The name of the module that owns the embed resources. If None, use the executable name.

use native_windows_gui as nwg;
fn build_embed1() -> nwg::EmbedResource {
    nwg::EmbedResource::load(None).unwrap()
}

fn build_embed2() -> nwg::EmbedResource {
    nwg::EmbedResource::load(Some("external.dll")).unwrap()
}

Fields§

§hinst: HINSTANCE

Implementations§

Source§

impl EmbedResource

Source

pub fn load(name: Option<&str>) -> Result<EmbedResource, NwgError>

Returns an embed resource that wraps the current executable. Shortcut for the builder API.

Source

pub fn builder() -> EmbedResourceBuilder

Creates a EmbedResourceBuilder. EmbedResource::load can also be used to skip the builder api

Source

pub fn string(&self, id: u32) -> Option<String>

Load a string the the RC file STRINGTABLE. Returns None if id does not map to a string.

Source

pub fn icon(&self, id: usize, size: Option<(u32, u32)>) -> Option<Icon>

Load an icon from the rc file. Returns None if id does not map to a icon. For more feature, use the Icon::builder with the embed parameter.

Source

pub fn icon_str(&self, id: &str, size: Option<(u32, u32)>) -> Option<Icon>

Load an icon identified by a string in a resource file. Returns None if id does not map to a icon.

Source

pub fn bitmap(&self, id: usize, size: Option<(u32, u32)>) -> Option<Bitmap>

Load a bitmap file from the rc file. Returns None if id does not map to a bitmap.

Source

pub fn bitmap_str(&self, id: &str, size: Option<(u32, u32)>) -> Option<Bitmap>

Load a bitmap file from the rc file. Returns None if id does not map to a bitmap.

Source

pub fn image(&self, id: usize, size: Option<(u32, u32)>) -> Option<Bitmap>

Load an image from the embed files and returns a bitmap. An image is defined this way: IMAGE_NAME IMAGE "../path/my_image.bmp" This method can load any image type supported by the image decoder.

Source

pub fn image_str(&self, id: &str, size: Option<(u32, u32)>) -> Option<Bitmap>

Load a image using a string name. See EmbedResource::image

Source

pub fn cursor(&self, id: usize) -> Option<Cursor>

Load a cursor file from the rc file. Returns None if id does not map to a cursor.

Source

pub fn cursor_str(&self, id: &str) -> Option<Cursor>

Load a cursor file from the rc file. Returns None if id does not map to a cursor.

Source

pub fn raw(&self, id: usize, ty: RawResourceType) -> Option<RawResource>

Return a wrapper over the data of an embed resource. Return None id does not map to a resource.

Source

pub fn raw_str(&self, id: &str, ty: RawResourceType) -> Option<RawResource>

Return a wrapper over the data of an embed resource. Return None id does not map to a resource.

Trait Implementations§

Source§

impl Default for EmbedResource

Source§

fn default() -> EmbedResource

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.