Drop-in replacement for Electron's BrowserWindow with working aspect ratio on Windows.
The module addresses this Electron issue: https://github.com/electron/electron/issues/8036.
Warning: this package extends BrowserWindow, that approach doesn't work properly with some Electron API, more here. Underline code can still be used to implement custom Window class that doesn't extend BrowserWindow but keeps reference to it (idea for next version of this library!)
npm install --save electron-aspect-ratio-browser-window
const AspectRatioBrowserWindow = ;// AspectRatioBrowserWindow instead of BrowserWindow:const mainWindow =width: 800height: 450;// Aspect ratio works on Windows, Linux, and Mac:mainWindow;
git clone https://github.com/antonfisher/electron-aspect-ratio-browser-window.gitcd electron-aspect-ratio-browser-window/examplenpm installnpm start
- utilizes Winuser.h resize hook: https://docs.microsoft.com/en-us/windows/win32/winmsg/wm-sizing
- supports different screen scales: 100-125-150% setting on Windows.
This module was inspired by two responses on the original issue: