Dear jthoma1-ga,
I have coded up the alternate solution for you. It's rather large to
present on this site, so I have uploaded it to some of my web space
for you:
http://www.arkane.demon.co.uk/Files/OutlookPanels.zip
(One caveat I will mention is that I'm away from home for the New Year
at the moment, and unfortunately I only have C# installed on my
laptop, not VB.NET, and I couldn't find this sample anywhere in VB. It
doesn't use any language-specific tricks, though, so I hope it should
be understandable. If not, please request a clarification and I'll
post a VB.NET version as soon as I'm back with my main machine. Thanks
for your understanding.)
Explanation:
What this solution does, rather than use MDI child windows as the
subwindows called up by the Outlook bar, is to make those subwindows
User Controls, which you can design in the visual designer. I've
created two, PanelA and PanelB, in the sample; their only special
characteristic is that they both inherit from OutlookPanel, so that
you can handle them through a single data type.
The magic happens in the main form. To simulate your layout, although
I don't have an Outlook Bar control here, I've added two toolbars to
this form, at the top and left.
Each panel (subwindow) you wish to use is stored in a private member
of the form - I create them in the MainForm constructor, and store
them all, and another private member holds the currently visible
panel.
The panels are changed by the ChangePanel method. It first performs a
couple of checks to see if the requested panel is already visible, or
no panel is visible (as you would expect when the form first appears,
then removes the old panel from the Controls collection of the form,
hiding it, and adds the new panel into the Controls collection, making
it visible. It then resizes and places the new panel to fill the main
window, less the space occupied by the toolbars, anchors it to the
window so that it will keep filling it even if the form is resized,
and calls Refresh to repaint the window with the new panel in place.
ChangePanel simply takes a reference to one of the panel member
variables, and can be called from wherever you like - here, I call it
from two toolbar buttons, but there's no reason why it couldn't be
called from the Outlook bar, menu items, etceters.
At the moment this is a simple implementation which used a fixed
number of panels, but it could easily be extended to use a dynamic
collection of panels rather than the private member variables I use
here. It also preserves all panel contents while they're hidden;
additional logic would be needed if you want to alter their state at
this time.
I hope this alternate solution achieves the effect you're looking for.
I have had a look at the possibilites of the unmanaged solution, but
it appears to be significantly harder than I initially thought, with
scope for some interesting problems.
If this answer isn't quite what you're looking for, please feel free
to request a clarification,
cerebrate-ga |