fltk-rs 隱藏標題欄但顯示工作列圖示

rfrf發表於2024-05-20
use fltk::{prelude::*, *};
use std::os::raw::*;

const GWL_EXSTYLE: i32 = -20;
const WS_EX_APPWINDOW: c_ulong = 0x00040000;
extern "system" {
    pub fn GetWindowLongA(wnd: *mut c_void, idx: c_int) -> c_ulong;
    pub fn SetWindowLongA(wnd: *mut c_void, idx: c_int, newval: c_ulong) -> c_long;
}

fn main() {
    let app = app::App::default();
    let mut win = window::Window::default()
        .with_size(400, 300)
        .with_label("Test");
    win.end();
    win.set_border(false);
    win.show();
    unsafe {
        let handle = win.raw_handle();
        let mut style_ex = GetWindowLongA(handle, GWL_EXSTYLE);
        style_ex |= WS_EX_APPWINDOW;
        SetWindowLongA(handle, GWL_EXSTYLE, style_ex);
    }

    app.run().unwrap();
}

相關文章