Hide main form in Electron application

Hello,I want to hide the main form when a subform is showing in an Electron project, I write the code:

//hide main form
//show subform
ElectronBrowserWindow1.FormClass:= TSubForm;

but when the main form hides, the subform hides too.

How can I hide the main form only?


Modal forms are attached to their parent forms. If you hide the parent, the modal child will be hidden too. Do you have a specific reason for not using ElectronBrowserWindow1.Show instead?

Hi @Tunde , I tried '.Show', subform still hides with mainform together,after awhile,may be one or two seconds they show again together like below:

macOS is different from Windows. Looks like it is stricter in the parent-child window relation and will hide the child no matter what.

If you don't need parent-child relation at all for this project, you can remove the parent: parentWindow from the main.js file along with all the event assignments (so every bw.on(...)).

You could also duplicate the ipc-browserwindow-create message and remove the parent related code from there, but to call that manually you'll need to know the exact arguments to send through. Of course you can copy this from WEBLib.Electron but for simplicity we are going to add a NoParent property to TElectronBrowserWindow that will do exactly this. It'll be part of the next update.

I see, thank you so much @Tunde

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.