Embedded Window


I am developing an application that displays the plugin that runs on a remote device.

I have the main window and I need a sub-window that will contain the plugin, I tried to create ResizableWindow and make it a child of the main window but when I am trying to get the native handle to it, I receive null.

I tried calling addToDesktop() which does create a native handle but the sub-window isn’t longer embedded.

I understood that the child window is lightweight and has no native handle, any idea how can I create a heavyweight embedded window?

The application will run on both Mac and Windows so I prefer to avoid using platform-specific code.


Assuming the plugins already exist, and you just need to display their editors, you can probably use JUCE’s view hosting components: NSViewComponent, XEmbedComponent, and HWNDComponent, depending on the platform. These components can embed a native window handle. Some plugin formats expect to attach to an existing window handle; in this case you may need to create an intermediate native view that you control, embed this native view, then pass a handle to the native view to the editor when you construct it.

addToDesktop would achieve something similar: you can use the second argument of this function to supply an existing window in which the component should be placed. You could then use getNativeHandle to find the window handle of the component that has been embedded in this way.

I’d recommend looking at juce_VST3PluginFormat.cpp in the JUCE repo for an example of how editor embedding can be implemented.

Hi reuk,

I am trying to achieve something similar as in The problem of displaying a Plugin in a nested window - YouTube (Plugin rendered on a nested window)

Yes the plugins exist and expect to receive existing native window handle, so if I understood correctly, to achieve the nested window I will need to

  1. Create HWND/NSView window handle.
  2. Create accordingly HWND/NSView Component.
  3. Set the Component’s native window.
  4. Make this Component the child of my MainComponent.
  5. Pass the native handle to the plugin.
  • It can’t be done with TopLevelWindow/ResizeableWindow? or any other components that already abstract the window handling?

  • Is it possible to make the JucePluginHost open plugins in nested window?

Actually I am using the VST3 format to load the plugins so maybe I can reuse the code from the Plugin Host, I will give it a look.

Thanks for your help.

1 Like

I think it should be possible to implement the nested DocumentWindow by passing false as the addToDesktop argument of the DocumentWindow constructor, and then manually calling Component::addToDesktop later, passing the native handle of the component into which you want to embed the window.

If you have other parts of the UI that will need to appear “in front” of the plugin editor, those will probably also need to be comonents with heavyweight peers (i.e. also added with addToDesktop).

1 Like

Awesome! it works.

Thank you reuk.

Hi @reuk

Sorry to bother you but is there a trick to getting a DocumentWindow embedded in another component?

I am trying some test code:

m_pDocumentWindow = new juce::DocumentWindow("test", juce::Colours::red, 0, false);
m_pDocumentWindow->setBounds(50, 50, 1000, 1000);
auto tw = this->getWindowHandle();
m_pDocumentWindow->addToDesktop(0, tw);

The handle looks correct but I just get the DocumentWindow attached to the desktop.

This code is in a subclass of AudioProcessorEditor.

Actually just calling addAndMakeVisible(m_pDocumentWindow) seems to work, I’m guessing addToDesktop with HWND is not needed?

No that doesn’t work, it is no longer heavyweight if addAndMakeVisible is called, arghhh