BrowserWindow.SetMenu(null) not working #376

Closed
opened 2026-01-29 16:37:57 +00:00 by claunia · 2 comments
Owner

Originally created by @shazha on GitHub (Aug 9, 2019).

Thanks for this great project, it's really helpful 😃

  • Version: 5.22.14
    .Net Core SDK version: latest 2.2 release

  • Target: Windows 10

The menu bar is supposed to be removed completely by invoking BrowerWindow.SetMenu(null) or Menu.setApplicationMenu(null). However, the default menu, which contains standard items such as File and Edit, is not suppressed and the menu bar is not removed from created BrowserWindow on Windows.

Originally created by @shazha on GitHub (Aug 9, 2019). Thanks for this great project, it's really helpful 😃 * **Version**: 5.22.14 .Net Core SDK version: latest 2.2 release * **Target**: Windows 10 The menu bar is supposed to be removed completely by invoking `BrowerWindow.SetMenu(null)` or `Menu.setApplicationMenu(null)`. However, the default menu, which contains standard items such as `File` and `Edit`, is not suppressed and the menu bar is not removed from created BrowserWindow on Windows.
claunia added the bug label 2026-01-29 16:37:57 +00:00
Author
Owner

@default-writer commented on GitHub (Aug 21, 2019):

@GregorBiswanger

The menu bar is supposed to be removed completely by invoking browserWindow.RemoveMenu();

See also win.removeMenu()

Example:

string viewPath = $"http://localhost:{BridgeSettings.WebPort}/windows/demowindow";

Electron.IpcMain.On("new-window", async (args) =>
{
    var browserWindow = await Electron.WindowManager.CreateWindowAsync(viewPath);
    browserWindow.RemoveMenu();
});

Electron.IpcMain.On("manage-window", async (args) =>
{
    var browserWindow = await Electron.WindowManager.CreateWindowAsync(viewPath);
    browserWindow.OnMove += UpdateReply;
    browserWindow.OnResize += UpdateReply;
    browserWindow.RemoveMenu();
});

Electron.IpcMain.On("listen-to-window", async (args) =>
{
    var mainBrowserWindow = Electron.WindowManager.BrowserWindows.First();

    var browserWindow = await Electron.WindowManager.CreateWindowAsync(viewPath);
    browserWindow.OnFocus += () => Electron.IpcMain.Send(mainBrowserWindow, "listen-to-window-focus");
    browserWindow.OnBlur += () => Electron.IpcMain.Send(mainBrowserWindow, "listen-to-window-blur");
    browserWindow.RemoveMenu();

    Electron.IpcMain.On("listen-to-window-set-focus", (x) => browserWindow.Focus());
});
@default-writer commented on GitHub (Aug 21, 2019): @GregorBiswanger The menu bar is supposed to be removed completely by invoking `browserWindow.RemoveMenu();` See also [win.removeMenu()](https://electronjs.org/docs/api/browser-window#winremovemenu-linux-windows) Example: ```c# string viewPath = $"http://localhost:{BridgeSettings.WebPort}/windows/demowindow"; Electron.IpcMain.On("new-window", async (args) => { var browserWindow = await Electron.WindowManager.CreateWindowAsync(viewPath); browserWindow.RemoveMenu(); }); Electron.IpcMain.On("manage-window", async (args) => { var browserWindow = await Electron.WindowManager.CreateWindowAsync(viewPath); browserWindow.OnMove += UpdateReply; browserWindow.OnResize += UpdateReply; browserWindow.RemoveMenu(); }); Electron.IpcMain.On("listen-to-window", async (args) => { var mainBrowserWindow = Electron.WindowManager.BrowserWindows.First(); var browserWindow = await Electron.WindowManager.CreateWindowAsync(viewPath); browserWindow.OnFocus += () => Electron.IpcMain.Send(mainBrowserWindow, "listen-to-window-focus"); browserWindow.OnBlur += () => Electron.IpcMain.Send(mainBrowserWindow, "listen-to-window-blur"); browserWindow.RemoveMenu(); Electron.IpcMain.On("listen-to-window-set-focus", (x) => browserWindow.Focus()); }); ```
Author
Owner

@GregorBiswanger commented on GitHub (Aug 21, 2019):

Big thanks to @hack2root for your contribution!

This new feature comes with the next version 5.22.15.

@GregorBiswanger commented on GitHub (Aug 21, 2019): Big thanks to @hack2root for your contribution! This new feature comes with the next version **5.22.15**.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#376