Hooking Up the Form Region

You now need to hook up the add-in to the form region. Outlook uses a service-based model. Outlook calls the RequestService method of the ThisAddin class, passing the GUID of the service it is looking for—in this case, a class that implements FormRegionStartup. You also need to declare a local variable to hold a reference to the FormRegionStartup class that you pass to the service request. Add the code in Listing 14.41 to the ThisAddin class.

Listing 14.41. Hooking up a form region public class ThisAddin

Dim MySimpleFormRegion As New MySimpleFormRegion

Private Sub ThisAddin_Startup(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles Me.Startup

End Sub

Private Sub ThisAddin_Shutdown(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles Me.Shutdown

End Sub

Protected Overrides Function RequestService( _ ByVal serviceGuid As Guid) As Object

If serviceGuid = _

GetType(Outlook.FormRegionStartup).GUID Then

Return MySimpleFormRegion End If

Return MyBase.RequestService(serviceGuid) End Function End class

0 0

Post a comment