use msgbox::IconType; use rsgt::event::WindowListener; use rsgt::graphic::load_icon; use rsgt::rframe::{RFrame, RFrameBuilder}; use rsgt::Size; use std::path::PathBuf; fn main() { // Apply Visual Style (Windows only) rsgt::os::enable_visual_style(); // Initialize RFrame let mut frame = RFrameBuilder::new() .with_size(Size(1280, 720)) .with_title("Show window") .with_visible(true) .build() .unwrap(); // Add window listener(Callback to detect Window events) frame.add_window_listener(SampleWindowListener {}); // Show window frame.run(); } struct SampleWindowListener {} impl WindowListener for SampleWindowListener { fn window_dropped_file(&mut self, path: PathBuf, frame: &RFrame) { // Load icon let icon = match load_icon(path.as_path()) { Ok(icon) => icon, Err(err) => { //Error handling msgbox::create("Error", err.to_string().as_str(), IconType::Error) .expect("TODO: panic message"); return; } }; // Set icon frame.set_icon(icon); } }