简体   繁体   中英

electron has blue outline/frame when launch

I want to use the same window outline like vscode: 在此处输入图像描述

but here is my window at launch

在此处输入图像描述

my window config

new BrowserWindow({
    minHeight: 400,
    minWidth: 600,
    center: true,
    frame: false,
    backgroundColor: "#fff",

    webPreferences: {
        spellcheck: false,
        webSecurity: true,
        nodeIntegration: true,
        contextIsolation: false,
        enableWebSQL: false,
        images: false,
        webgl: false,
    },
});

deps:

"electron": "17.0.0",
"electron-builder": "^22.14.13"

OMG, I did it!!!!

// @ts-check
const { BrowserWindow, app } = require("electron");
const path = require("path");
const { Library } = require("ffi-napi");

app.disableHardwareAcceleration();

function createWindow() {
    return new BrowserWindow({
        minHeight: 400,
        minWidth: 600,
        center: true,
        frame: false,
        show: true,
        backgroundColor: "#fff",

        webPreferences: {
            spellcheck: false,
            webSecurity: true,
            nodeIntegration: true,
            contextIsolation: false,
        },
    });
}

async function openWindow() {
    const win = createWindow();

    // ffi - napi;
    var ffi = Library("user32.dll", {
        SetWindowLongA: ["int", ["int", "int", "long"]],
        SetWindowPos: ["int", ["int", "int", "int", "int", "int", "int", "int"]],
    });
    // THICK frame
    const WS_THICKFRAME = 0x00040000;
    // show window
    const SWP_SHOWWINDOW = 0x0040;
    // draw a thick frame
    ffi.SetWindowLongA(win.getNativeWindowHandle().readUint32LE(), -16, WS_THICKFRAME);
    // show window
    ffi.SetWindowPos(win.getNativeWindowHandle().readUint32LE(), 0, 0, 0, 0, 0, SWP_SHOWWINDOW);
    win.center();

    if (app.isPackaged) {
        await win.loadFile("public/index.html");
    } else {
        await win.loadURL("http://localhost:3000");
    }

    return win;
}

exports.createWindow = createWindow;
exports.openWindow = openWindow;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM