Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to avoid windows zoom in electron app

Tags:

electron

If the Windows display zoom is set to 150%, the Electron app also appears zoomed. I want my app to avoid the windows zoom level and always display in 100% zoom only.

I have tried the zoomFactor:1 but it's not working.

enter image description here

like image 653
Gaurav Avatar asked Sep 12 '19 05:09

Gaurav


People also ask

How do you disable maximize button in Electron?

When creating your BrowserWindow just set the maximizable property of the options object to true . Since you didn't show us any code, this is just an example: const { BrowserWindow } = require ("electron"); var window = new BrowserWindow ({ title: "My App", maximizable: false });

Why do so many apps use Electron?

Electron apps can be developed even quicker than many other frameworks allow because they are written in JavaScript. Not only is JavaScript a language that most developers are very familiar with, but JavaScript is also far easier to debug and optimize than most other languages used to develop apps.


1 Answers

As per @hijleh suggestion, adding the following lines in the main process has resolved the issue. The app is now avoiding the Windows display zoom.

app.commandLine.appendSwitch('high-dpi-support', 1)
app.commandLine.appendSwitch('force-device-scale-factor', 1)
like image 189
Gaurav Avatar answered Nov 26 '22 23:11

Gaurav