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
impl EmbedResource
Sourcepub fn load(name: Option<&str>) -> Result<EmbedResource, NwgError>
pub fn load(name: Option<&str>) -> Result<EmbedResource, NwgError>
Returns an embed resource that wraps the current executable. Shortcut for the builder API.
Sourcepub fn builder() -> EmbedResourceBuilder
pub fn builder() -> EmbedResourceBuilder
Creates a EmbedResourceBuilder
. EmbedResource::load
can also be used to skip the builder api
Sourcepub fn string(&self, id: u32) -> Option<String>
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.
Sourcepub fn icon(&self, id: usize, size: Option<(u32, u32)>) -> Option<Icon>
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.
Sourcepub fn icon_str(&self, id: &str, size: Option<(u32, u32)>) -> Option<Icon>
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.
Sourcepub fn bitmap(&self, id: usize, size: Option<(u32, u32)>) -> Option<Bitmap>
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.
Sourcepub fn bitmap_str(&self, id: &str, size: Option<(u32, u32)>) -> Option<Bitmap>
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.
Sourcepub fn image(&self, id: usize, size: Option<(u32, u32)>) -> Option<Bitmap>
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.
Sourcepub fn image_str(&self, id: &str, size: Option<(u32, u32)>) -> Option<Bitmap>
pub fn image_str(&self, id: &str, size: Option<(u32, u32)>) -> Option<Bitmap>
Load a image using a string name. See EmbedResource::image
Sourcepub fn cursor(&self, id: usize) -> Option<Cursor>
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.
Sourcepub fn cursor_str(&self, id: &str) -> Option<Cursor>
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.
Sourcepub fn raw(&self, id: usize, ty: RawResourceType) -> Option<RawResource>
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.
Sourcepub fn raw_str(&self, id: &str, ty: RawResourceType) -> Option<RawResource>
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.