CAB (Composite UI Application Block)

Latest post 01-25-2008 7:57 AM by Melody. 14 replies.
  • 12-18-2007 6:49 AM

    CAB (Composite UI Application Block)

    Good day! I am trying to integrate VSTA in my CAB project. Is this possible? I have a lot of sleepless nights thinking how i could integrate VSTA in my CAB project. I hope someone can give me an answer as soon as possible. Thanks!
  • 12-18-2007 11:26 AM In reply to

    • Gary
    • Top 10 Contributor
    • Joined on 07-13-2006
    • Posts 307

    Re: CAB (Composite UI Application Block)

    To get started, you should define your application's object model;  which is essentially the APIs that the VSTA programmer will use to call members of the host application.

    Do you have the object model APIs worked out?

     

  • 12-20-2007 4:57 AM In reply to

    Re: CAB (Composite UI Application Block)

    Hi Gary. Thanks for the quick reply. With regards to your question:

    Do you have the object model APIs worked out? - My answer is yes. :)

  • 12-20-2007 10:04 AM In reply to

    • Gary
    • Top 10 Contributor
    • Joined on 07-13-2006
    • Posts 307

    Re: CAB (Composite UI Application Block)

    The next step is to create a 'proxy' of your OM.  The proxy assembly allows VSTA add-ins to communicate with different versions of your application and makes it possible to load and unload add-ins.

    Creating a proxy is accomplished using proxygen, a utility that comes with the VSTA SDK. 

    Have you installed the VSTA SDK and read the documentation about using proxygen?

  • 12-21-2007 5:08 AM In reply to

    Re: CAB (Composite UI Application Block)

    Hi Gary,

       Again, thanks for the quick reply. :)

       Yep, i have already installed and read the documentation on how to use proxygen. I have been able to add the created proxy in my solution but the problem is, I'm encountering an error which says that my application does not contain a definition for the 'RemoteObject'. I'm stuck here... :(

    Regards,

    Ric

  • 12-21-2007 5:15 AM In reply to

    Re: CAB (Composite UI Application Block)

    Hi Gary,

       Just got the proxy to work... I just compared my proxy with the proxy from the EventSample project and i got it to work. Thanks for your time and help!

    Ruc

  • 01-04-2008 5:34 AM In reply to

    Re: CAB (Composite UI Application Block)

    Hi Gary,

       Good day! I would just like to ask how would I be able to delegate the events that are needed for macro recording in VSTA into my CAB application since I wouldn't be able to identify the forms and controls of those forms in my Shell Application because they are not exposed due to the architecture of CAB Applications.

    Thanks,

    Ric

  • 01-04-2008 9:49 AM In reply to

    • Melody
    • Top 10 Contributor
    • Joined on 04-26-2007
    • Syracuse, NY
    • Posts 244

    Re: CAB (Composite UI Application Block)

    Ric,

         If you would like to expose events that are associated with forms you will need to create events that do not pass unserializable parameters and hook them up in the host.  The following is an excert from the EventSample which shows how to expose form events to VSTA.  In this example a form event (button clicks for cmdOpen) is hooked up to an internal method.  In this internal method the host can process the click then raise an event which is visible to VSTA.  You would not want to hook a form event directly to a VSTA visible method- in the example below the sender is a System.Windows.Forms.Button which is unserializable. 

    I hope this helps, please let me know if you have any questions.

    Thanks,

       -Melody

    namespace EventSample
    {
    //form
    private Form1 myForm;
    internal Form1 MyForm
    {get { return myForm; } }

    //events that VSTA can access
    public event EventHandler DocumentOpenedEvent;

    public MainApplication ()
    {
    myForm = new Form1();

    //hook up the form events with event handlers
    HookUpEvents();
    }

    private void HookUpEvents()
    {
    //add event handling for the form- not accessable from VSTA
    //accesable events are raised in the methods called
    myForm.cmdOpen.Click += new EventHandler(DocumentOpen);

    }

    //code to perform the requested action can be added to the method below
    internal void DocumentOpen(object sender, EventArgs e)
    {
    //fire the DocumentOpenedEvent event which is visible to VSTA
    EventHelper.Invoke(DocumentOpenedEvent, this, EventArgs.Empty);
    }

    } //end MainApplication class
    }

  • 01-04-2008 11:24 AM In reply to

    • Gary
    • Top 10 Contributor
    • Joined on 07-13-2006
    • Posts 307

    Re: CAB (Composite UI Application Block)

    Hi Ric,

    Can you provide an example of the events needed for macro recording?  Could they be abstracted to a common usage pattern? 

    And isn't there some kind of messaging/notification pattern that bridges the parts of a CAB application?

    For a CAB application, you should create a seperate object model (class or classes), that represents the application UI, control logic and data you would expose to the VSTA add-in/macro.  This is a challenge, because CAB properly isolates the UI from the control logic and data and your object model will probably want to re-unify these elements to some extent. 

    Rather than thinking of your object model in terms of UI pieces, think about it more in terms of the data presented by the UI and the operations performed on the data.  So a list view on one of your forms would be bound to an underlying data structure (ie: arraylist) and this data structure would be exposed to VSTA in your object model with related methods, properties and events.  Whatever notification CAB implements between the Shell and UI could also be tied to the object model component you create for VSTA.

    I'm not familiar enough with CAB terms presently, but one idea would be to follow standard procedures to create an additional 'view' component similar to the a master form/view, but with no UI.  This additional component becomes the object model portion of your CAB application.  This object model portion could always be active and send/receive all the notifications via CAB architecture techniques.  The object model would also expose events to VSTA and methods and properties the add-in will call to automate the application .

    Rather than trying to tie everthing together in one OM, Another thought would be to offer many seperate object models scoped to particular forms or parts of the CAB application.  These fractional object models would create seperate add-in assemblies that would load and unload according to the lifetime of the hosting component, probably all of the fractional OMs would include a common 'application' object model portion as a basis for communication with the rest of the host application.

    Hope this chatter helps you in some way.

  • 01-06-2008 7:58 PM In reply to

    Re: CAB (Composite UI Application Block)

    Hi Gary,

       Thanks a lot! I really really appreciate your thoughts on this. I'll try to implement what you've suggested. Thanks again.

    Ric

  • 01-17-2008 6:01 AM In reply to

    Re: CAB (Composite UI Application Block)

    Hi Gary/Melody,

       Good day! I would just like to ask you guys, if I changed something in my application and then rerun the proxygen, do i need to run ProjectGen again (with all the registry editing stuff)?

    Thanks,

    Ric

  • 01-17-2008 8:28 AM In reply to

    • Melody
    • Top 10 Contributor
    • Joined on 04-26-2007
    • Syracuse, NY
    • Posts 244

    Re: CAB (Composite UI Application Block)

    Ric,

       By default ProjectGen creates add-ins which use a reference to the proxy.dll in the GAC.  As long as you are reinstalling the latest copy of the proxy in the GAC and don't change your add-ins to use a local copy, your add-ins will see the changes.  If you change something in the proxy like a scope, parameter type, or return type that an add-in was already using, the add-in will need to be recompiled.

      In the ShapeAppSamples the proxy is added to the GAC in a post build event.  For instructions on how to set up your host this way, please see Moving and Organizing DLL’s to Make VSTA Integration Easier. Part IV- Keeping the current Proxy in the GAC. Updated for VSTA v 2.

       The registry hive does not need to be edited for changes to the proxy.  The only time the registries need to be changed is if you add an In-Process Host or want to change a setting you specified prior to running vsta /setup.

    Hope this helps!

    -Melody

    Filed under: , , ,
  • 01-20-2008 10:32 PM In reply to

    Re: CAB (Composite UI Application Block)

    Cool. Thanks Melody. :)
  • 01-25-2008 1:23 AM In reply to

    Re: CAB (Composite UI Application Block)

    Hi Gary and Melody,

       Just want to let you guys know that i got my VSTA-integrated CAB application to work. I can now record and run macros using add-ins. So far, everything is working as expected. Thank you for all your help.

    Ric

  • 01-25-2008 7:57 AM In reply to

    • Melody
    • Top 10 Contributor
    • Joined on 04-26-2007
    • Syracuse, NY
    • Posts 244

    Re: CAB (Composite UI Application Block)

    Great!  If you would like to send in a sample we'd love to see it.  Are you going to do a Dynamic Programming Model integration? 

    Please let us know if we can be of further assistance.

    -Melody

Page 1 of 1 (15 items) | RSS
Copyright Summit Software Company, 2008. All rights reserved.