Howto resize remote.browserwindow?


I am extending the smart mirror app, which uses angular and electron to have a number or floating windows displaying image content. this all works. te image viewer is an angular ‘service’, not on the main thread.

anyhow… sometimes the images are smaller than the window size I selected, so I would like to resize the floating viewer window to the image about to be loaded. … but window.setSize() and window.setBounds() are not supported on remote windows… the parent of these is really the desktop… I can’t setparent() on them either…
and if I ipc to the main process window, these are still remote and cannot size/resize…

anyone have any suggestions on how to accomplish this? (I had intended to call setBounds on every window refresh (15-30 seconds) after calculating the smaller of the two sizes. image, or declared…


the only thing IN the window is an image file ( ie window.loadURL(“file:///somepath/somename.jpg”))


I’m sorry if I don’t understand your question well. But, did you try it with getCurrentWindow? Like this: remote.getCurrentWindow().setSize(width, height); in these windows.


thanks… at the time of the need for resize, the code is in a timer event handler. not in the window itself… also the window in question may not have focus,

I have an array of windows which will get their content refreshed. I am looping thru the array, and have an arbitrary remote.BrowserWindow to manipulate. this code is also not running in the main window.

I ‘think’ looking more at this, that I need to add more content to the page, and send an pic message to the window, that will allow the api you provided… basically, tell the window to resize itself…

win = new BrowserWindow({width: 800, height: 600,show:false})

// sometime later
==== load the prototype html

win.webContents.on(‘did-finish-load’, () => {
win.webContents.send(‘loadnew’, image_url, {…})


So, this didn’t work either… trying to tell the window to effectively resize itself… I created a small html file with one image in it, and some javascript to listen to some IPC request…replace the image URL (with some dom, document write function) and then do a setBounds…(which does top corner and dimensions)

but I haven’t found a way to actually send a message to that independent window.

I can send from the timer event handler, to the the main window ipc receiver… but this appears NOT to be in the mainindow’s context… getCurrentWindow() wouldn’t help, as this is not mainwindow().

because this code is running on a timer event handler, it is not IN any window context.


Ok, I finally was able to accomplish this… I had to executeJavascript() in the window to have it resize itself.