Click here to Skip to main content
15,884,353 members
Articles / Desktop Programming / Win32

Inter-Process Communication (IPC) Introduction and Sample Code

Rate me:
Please Sign up or sign in to vote.
4.91/5 (57 votes)
19 Dec 2009Ms-PL8 min read 251.2K   12.2K   195  
This article will cover general IPC technologies in All-In-One Code Framework. The IPC technologies include Named Pipes, File Mapping, MailSlot, etc.
========================================================================
    OFFICE ADD-IN : CSOutlookUIDesigner Project Overview
========================================================================

/////////////////////////////////////////////////////////////////////////////
Use:

The CSOutlookUIDesigner provides samples on how to customize Office UI using
the VSTO Designers. It will demonstrate all Ribbon Controls available in the
Ribbon Designer. It will also demonstrate how to add FormRegions and 
TaskPanes to the Outlook UI.


/////////////////////////////////////////////////////////////////////////////
Creation:

A. Ribbon

In order to make the ribbon show corresponding controls on different types
of Inspectors, we need to:
1. Group the controls on the designer. One group per type of Inspector.
2. In the Ribbon's Load event, get a reference to current Inspector using
   the Context property.
3. Determine the type of the Inspector by checking the CurrentItem property.
   Sample: if (inspector.CurrentItem is MailItem) { ... }
4. Set the Visible property of corresponding Group on Ribbon to show / hide
   the controls.
   
MyRibbon uses both custom PNG files stored in project resource file and
Office built in images as control images. For those controls using Office
built in images, please note their OfficeImageId property.

B. Custom Task Pane (CTP)

In order to associate a CTP with specific types of Inspectors, we need to:
1. Handle the Application.Inspectors.NewInspector event.
2. In the event handler, get the item type of the Inspector and decide
   whether to associate a CTP with the Inspector.
3. If the item type is right, we can use ThisAddIn's CustomTaskPanes.Add
   method to have the job done.

In order to access the parent CTP / Window object within our UserControl
code, we need to:
1. Add a property of type CustomTaskPane to the UserControl.
2. After creating the CTP, pass the CTP reference to the property created
   in step 1.
3. Within the UserControl code, access the property to get the CTP reference.
   
In MyRibbon class, we have a button once clicked, will show the CTP associated
with the current Inspector. In order to achieve this, we need to:
1. Go through the Globals.ThisAddIn.CustomTaskPanes, compare each CTP's
   Window property with current Inspector.
2. If Window == Current Inspector, that CTP is the one associated with the
   Inspector.
3. Do whatever necessary with the CTP.

C. FormRegion
To get the current Outlook item within the FormRegion code, use:
this.OutlookItem

To get the current Outlook Inspector within the FormRegion code, use:
this.OutlookFormRegion.Inspector


/////////////////////////////////////////////////////////////////////////////
References:

Ribbon Designer
http://msdn.microsoft.com/en-us/library/bb386089.aspx

Office Ribbon Class
http://msdn.microsoft.com/en-us/library/microsoft.office.tools.ribbon.officeribbon.aspx

CustomTaskPane Class
http://msdn.microsoft.com/en-us/library/microsoft.office.tools.customtaskpane.aspx


/////////////////////////////////////////////////////////////////////////////

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)


Written By
China China
Microsoft All-In-One Code Framework delineates the framework and skeleton of Microsoft development techniques through typical sample codes in three popular programming languages (Visual C#, VB.NET, Visual C++). Each sample is elaborately selected, composed, and documented to demonstrate one frequently-asked, tested or used coding scenario based on our support experience in MSDN newsgroups and forums. If you are a software developer, you can fill the skeleton with blood, muscle and soul. If you are a software tester or a support engineer like us, you may extend the sample codes a little to fit your specific test scenario or refer your customer to this project if the customer's question coincides with what we collected.
http://cfx.codeplex.com/

Comments and Discussions