Reputation: 9
I am new with the ElectronJS and sorry for being not be smart with these staffs yet. I am trying to make a login page for my future company but first I need to prepare everything to able to start something. So if someone is turn on the computer then they need to use the windows login and when logged in then my application will appear and asking for the specific pin code.
Big story, in short I need to make the application to hide the desktop on all of the screens.
I did this way in C# (because I started to do in C# the project and then I found this ElectronJS and changed my mind to use this instead):
private static Rectangle GetDesktopBounds(Form main)
{
Rectangle result = new Rectangle();
for (int i = 0; i < Screen.AllScreens.Length; i++)
{
Screen screen = Screen.AllScreens[i];
result = Rectangle.Union(result, screen.Bounds);
}
main.Top = result.Top;
main.Left = result.Left;
main.Width = result.Width;
main.Height = result.Height;
return result;
}
It works fine in C# but I need in ElectronJS and I did try to make something like this:
let x;
let y;
for (let i = 0; i < screen.getAllDisplays().length; i++) {
x += screen.getAllDisplays()[i].bounds.width;
console.log(screen.getAllDisplays()[i].bounds.width);
y += screen.getAllDisplays()[i].bounds.height;
console.log(screen.getAllDisplays()[i].bounds.height);
}
And then:
win.setSize(x, y, false);
But it doesn't put the window to all of the screens to fullscreen. It does only in the primary screen. If I console log the x and y then I get the NaN message.
So the question is: How I can make the window in fullscreen and put on all of the screens same time?
Thank you for the answers in advance.
Upvotes: 0
Views: 898
Reputation: 9
Alright. I found a solution. maybe not the perfect but works fine for me:
let displays = screen.getAllDisplays()
let externalDisplay = displays.map(function (display, index, displays) {
win = new BrowserWindow(
{
x: display.bounds.x,
y: display.bounds.y,
width: 1280,
height: 720,
fullscreen: true,
backgroundColor: "#363636",
frame: false,
enableLargerThanScreen: true,
skipTaskbar: true,
disableAutoHideCursor: false
}
);
})
Upvotes: 1