HowTo: Host a CAB application in Outlook, Word, Excel, or a common Winforms application

Introduction

Reusing is
a common requirement in any team or framework. However, we usually reuse at
business logic or general infrastructure level. The User Interface reuse is
more difficult to achieve. CAB architecture is loosely coupled enough to make
that possible.

The
following screenshots illustrates the bank teller quickstart application hosted
in Outlook, Word and a regular Winforms application.

Just two
lines of code [:)]

 

ho1 ho2

ho3 ho4

 

Instructions:

  1. Download the solution
  2. Extract
    the solution and build it. If you experience problems, check that
    the references to the CAB assemblies are correct.

Create
the shell and the CAB application

  1. Create a
    new project to host the shell and the CAB application.

    The shell in a regular CAB application would be a Form. However if we
    want to host the application in a different executable (Outlook, Word, IE,
    etc), we already have the container. So the Shell will be a UserControl
    .

  2. Add
    references to CAB assemblies.
  3. Create a
    regular UserControl and place the workspaces, menus, toolstrip, statusbar,
    and everything related to the shell.
  4. If you
    need to override the CAB events like AfterShellCreated or
    AddBuilderStrategies, create a new class that derives from
    CompositeUIExtensions.Hosting.UserControlShellApplication

    where TUserControlShell is the type of the UserControl created on the previous step
    and
    TWorkItem is the root work item that
    must derives from
    UserControlWorkItem.

Consume
a CAB module/app from Outlook/Word/External application

  1. Open your
    project and add references to
    CompositeUIExtensions.Hosting and the CAB assemblies. Also
    copy the project related assemblies (module assemblies for example) to the
    application output directory.
  2. Creates
    an instance of
    CompositeUIExtensions.Hosting.UserControlHost and add it to the
    correspondent Controls collection. The following code illustrates how;

UserControlHost plugin = 
new
UserControlHost();
…Controls.Add( plugin );

  1. Create
    the ProfileCatalog.xml, configure it with the desired module/s and set the
    Build Action to CopyAlways.
     

Download
the solution
that shows how to host the BankTeller app inside Outlook, Word and
Winforms.

Published: February 26 2006

blog comments powered by Disqus