How to make a custom form for Outlook Express
and Windows Mail in VB.NET, C#, C++

Add-in Express™
for Outlook® Express and Microsoft® .net

Add-in Express Home > Add-in Express for Outlook Express > Online Guide > Creating custom forms for Outlook Express

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.

Custom Outlook Exprerss form - Forms manager item

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.

Choosing the Add-in Express form in 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.

Form instancing

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:

  • None. This value specifies the strategy described above. Please note that forms embedded into Outlook Express Inspector windows follow this strategy only.
  • NewInstanceForEachFolder. This is the default value of the ExplorerCached property. It specifies another strategy: every time a folder switch occurs, Forms Manager shows the same form instance for a given folder.
  • OneInstanceForAllFolders. The name suggests exactly what it says: Forms Manager shows the same form instance for all folders in the current profile.

Form positioning

You can show an ADXOEForm in the Outlook Express Explorer-related positions shown below.

All custom form positions available in the OE explorer window

Positions for Outlook Express Inspector-related forms are shown below:

All custom form positions are available in the Outlook Express inspector window

Forms mechanics

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:

  • Visible = false. The form isn't shown.
  • Visible = true, Active = false. The form is embedded into an OE window, nevertheless, it isn't the topmost one in that region.
  • Visible = true, Active = true. The form is embedded into an Outlook Express window; it is the topmost form in that region.

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:

  • Set the Enabled property of the corresponding item to false
  • Set the Cancel parameter of the ADXBeforeFormInstanceCreate event to true
  • Set the Cancel parameter of the ADXBeforeFormShow event to true
  • Set the Visible property of the form to false (or call the Hide method of the form)

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.

Customizing Outlook Express menus <<