How to make a custom form for Outlook Express
and Windows Mail in VB.NET, C#, C++
Embedding custom forms into Outlook Express windows
Add-in Express introduces its form-embedding technology for Outlook Express and Windows Mail add-in developers. From the developer perspective, the technology includes three main parts:
Forms Manager. This component is a starting point of the technology. You add the Forms Manager to the add-in module using the Add OE Forms Manager command from the context menu. Then you fill its Forms collection with items described below.
Collection Item. Every item of the Forms collection binds your custom Outlook Express form to a set of properties specifying the context for your form to show. For instance, you can specify if the form will show in the bottom pane of the Folder list window for a given folder name etc.
Form. AddinExpress.OE.ADXOEForm is a highly specialized descendant of System.Windows.Forms.Form. You can place any .NET controls onto the form. The form provides a number of technology-specific properties, events, and methods. You add ADXOEForm to your project via the Add New Item dialog.
How the form-embedding technology works in Outlook Express
When a context change occurs in Outlook Express or Windows Mail, the Forms Manager loops through the items collection looking for enabled items. If the item's context settings correspond to the current context, Forms Manager raises the BeforeInstanceCreate event that allows preventing further execution of the process. If the process isn't cancelled, an instance of the form specified in the FormClassName property of the item is created. Next, the ADXBeforeFormShow event of the form is fired. Again, you can cancel the process at this stage. If you prefer to go on, the form instance is embedded to the specified location and shown.
As you can see, what is shown is an instance of the form (ADXOEForm). Nevertheless, the process described above is suitable for a certain type of scenarios only. For forms embeddable into the Outlook Express Explorer window, you can control form instancing. You access this feature through the ExplorerCached property of the collection item. There are the following values of this property:
You can show an ADXOEForm in the Outlook Express Explorer-related positions shown below.
Positions for Outlook Express Inspector-related forms are shown below:
The UI of forms includes the header and the Close button. You control them through the AlwaysShowHeader and CloseButton Boolean properties. If AlwaysShowHeader is false, the header will be only visible when two or more forms are shown in the same position. When the Close button is clicked, the corresponding ADXOEForm generates the ADXCloseButtonClick event.
ADXOEForm overrides the Active and Visible properties and changes their destination:
As described above, your custom Outlook Express form is shown whenever a context change occurs. To hide the form, you have four options at your disposal:
To show a form that is currently hidden, you cannot just change it Visible property. Instead, you must be sure that the item is enabled and that the process will not be cancelled in the ADXBeforeFormInstanceCreate and ADXBeforeFormShow events. Then, you call the ApplyTo method of the item that controls the form. The only parameter of this method accepts an explorer or inspector object.
Note. You can't use ADXOEForm when a normal form is used. For instance, you can't use ADXOEForm when you need to show a modal dialog. In the Outlook Express Explorer window, ADXOEForm will show up for mail folders only.