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:
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.
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
- Create HWND/NSView window handle.
- Create accordingly HWND/NSView Component.
- Set the Component’s native window.
- Make this Component the child of my MainComponent.
- Pass the native handle to the plugin.
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.
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
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();
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