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.
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).