Platform SDK: MAPI |
A form server can be thought of as three things: a Win16 or Win32 program that displays an interface and handles windows messages by way of the standard Windows message pump mechanisms, an object that registers its class factory with OLE and is activated by OLE automation methods, and a MAPI object that follows the MAPI rules for interactions with other MAPI components. Your code has to handle all three of those broad requirements simultaneously.
See the COM and ActiveX Object Services section in the Platform SDK for details about registering your form server's class factory. Handling windows messages and displaying an interface are standard Windows programming techniques that don't have any special requirements with respect to MAPI forms. Again, the Platform SDK has details about Windows programming. This document contains what you need to know to implement the required and optional MAPI form interfaces so that they follow the MAPI rules for interactions with other MAPI components — primarily the MAPI Form Manager and messaging client applications.
All of the interfaces that you can use when implementing form servers are derived — either directly or indirectly — from the OLE base class IUnknown. This means that all your implementations of these interfaces will need to have QueryInterface, AddRef, and Release methods. You can save yourself a lot of work if you use multiple inheritance to implement all of the required interfaces in one new class of your own, so that all the interfaces you are using can share a single implementation of the required IUnknown methods. See the OLE documentation on the IUnknown class methods for details on the QueryInterface, AddRef, and Release methods. There are no special considerations with respect to MAPI form servers for these methods.
While not all of the MAPI form interfaces are mandatory for all form servers, the methods in any given interface are. That is, if you choose to implement a particular interface, you must implement all of the methods in the interface. This is different from the situation with some other MAPI components, such as message transports. Fortunately, the methods in the MAPI form interfaces are relatively straightforward so implementing all of them does not put a great burden on developers.
The MAPI form interfaces are independent of the type of development tool used to create a form server. This allows forms to be created using different development tools such as Microsoft® Visual C++® and tools from other vendors. The only requirement is that all form servers must support the required MAPI form interfaces.
Note It is possible to implement form servers using a mix of languages. For example, you could use Microsoft® Visual Basic® for the form's user interface and Microsoft® C/C++ for the underlying MAPI code. However, this document relates only to C++ development of form servers.
Not all of the MAPI interfaces relating to forms are required by all form servers. The optional interfaces allow you to implement some advanced form functions that are not needed by most form servers. The following table lists the interfaces, what they are for, and whether you must implement them.
Interface | Usage | Status |
---|---|---|
IMAPIForm | The primary interface that clients use when loading form servers, executing form verbs, and shutting down form servers. Also the OLE IUnknown – derived interface used to inform other OLE components what interfaces a form object implements. | Required |
IPersistMessage | Used when loading messages into and saving messages from form objects. | Required |
IMAPIFormAdviseSink | Used by form objects to keep track of messaging client status and to find out whether the form object is capable of displaying the next or previous message in a folder. | Optional |
IClassFactory | OLE class factory interface used by form objects for compliance with the OLE class factory mechanism. | Required |
IMAPIFormFactory | Used if your form server supports more than one type of form. In this case, the IMAPIFormFactory interface allows client applications to access the multiple IClassFactory interfaces (one per type of form that your form server supports) that your form server must also implement. | Optional |