Our plugin model isolates plugins in their own AppDomain so that if a plugin crashes it doesn't take down our whole client app. This also allows for us to unload and load plugins if we choose to. The problem I've run into is now it's much harder to show
my plugins (each have their own windows Form) in my main mdi window.
So I thought, why not pass the handle to the main window since I can pass primitives accross AppDomains? I then implemented a method in the main window where you pass in the plugin handle and it shows it in the main mdi window. Here's my code:
This approach seems to be buggy though... 1. The title bars of plugin windows always appear inactive as if the window was not in focus 2. When I maximize a plugin window, it does not seem to be aware that my main window has a menu and toolbar docked to the top. The maximized plugin window sits right over the top of them 3. And worst of all plugin windows are always on top of the other managed windows
Has anyone successfully been able to get this working correctly? Or is there some other way I can do this?
It seems like a managed MdiClient is not aware of the native child windows that I've added...
So I've been playing around with it a little...and I found setting the form's parent to the MdiClient's handle makes it a little less buggy. SetParent(formHandle, MdiClient.Handle);
#3 seems to no longer be a problem
The maximize issue stated in #2 is somewhat remedied. When you maximize a plugin form it no longer maximizes over the menubar and toolbar but rather under it. Usually the behavior when you maximize a window is that the window's title is appended to the mdi
parent's title. This does not happen when you maximize plugin forms.
#1 is still an issue. For some reason, the title bars always appear inactive even if they are the front-most form.
I've also noticed that tabbing to the next control doesn't work in plugin windows. Also control-tab to flip between windows is a little buggy.
There's two approaches I can think of that may fix this. I could create my own MdiClient class so that it accounts for showing child windows via an instance of Form or a handle.
Another idea, and this seems like it's kind of a hack, is to: 1. Create a Form for each plugin 2. Copy the form style, title, and icon of the plugin window to the Form I newed up 3. Remove the style from the plugin window 4. Embed the plugin window's contents in the Form
Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.