Thursday, November 30, 2006

A Minimal CAB Application

First CAB Application

1) Create a new Windows Form Application solution named CABQuoteViewer.
a. Change the name of the form to MainForm.

2) Add the existing CAB projects to the solution.
a. Browse to C:\Program Files\Microsoft Composite UI App Block\CSharp\Source

b. Add the existing projects for ObjectBuilder, CompositeUI, and CompositeUI.WinForms.

c. In the CABQuoteViewer project, add references to the above 3 projects.

3) Rename the file Program.cs to CABQuoteViewerApplication.cs

4) In the file CABQuoteViewerApplication.cs,
a. Add references to the CAB namespace
using Microsoft.Practices.CompositeUI;
using Microsoft.Practices.CompositeUI.WinForms;

b. Change the definition of the class from
static class Program
to
class QuoteViewerApplication : FormShellApplication

c. The body of the Main() function should just be
new QuoteViewerApplication().Run();


The final version of CABQuoteViewerApplication.cs is:

using System;
using Microsoft.Practices.CompositeUI;
using Microsoft.Practices.CompositeUI.WinForms;

namespace CABQuoteViewer
{
class CABQuoteViewerApplication : FormShellApplication
{
[STAThread]
static void Main()
{
new CABQuoteViewerApplication().Run();
}
}
}

After compiling and running this application, you will see the empty MainForm appear.

©2006 Marc Adler - All Rights Reserved

No comments: