SetWindowPos and minimum BrowserWindow width/height


#1

I’m having a bit of hard time understanding something related to BrowserWindow and SetWindowPos (the Windows API). The browser windows is created like this:

mainWindow = new BrowserWindow({
        width: 1920,
        height: 1080,
        minWidth: 1920,
        minHeight: 1080,
        show: false,
        useContentSize: true,
        webPreferences: {
            offscreen: renderToPIP
        }
    });

and at some point I’m calling this function: forceWindowSize(mainWindow.getNativeWindowHandle()) which is wrapper around SetWindowPos (using a node add-on) the function itself is this:

void ForceWindowSize(const FunctionCallbackInfo<Value> &args) {
  Isolate *isolate = args.GetIsolate();
#ifdef _WIN32
  unsigned char *bufferData = (unsigned char*)node::Buffer::Data(args[0]->ToObject());
  unsigned long handle = *reinterpret_cast<unsigned long *>(bufferData);
  HWND hwnd = (HWND)handle;

  bool result = SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, 0);

  args.GetReturnValue().Set(Boolean::New(isolate, result));
#else
  args.GetReturnValue().Set(Boolean::New(isolate, false));
#endif
}

and then if I set the screen resolution to 800x600 the browser windows is still resized to 1920x1080. I’m happy with the result but I’m not sure why it works.

Any ideas?