Multiple FormRegions, the GUID, and ThisAddIn.RequestService()

P

pkelley

My setup:
Windows XP, Microsoft Visual Studio 2005, using VSTO SE, developing in C#.

Question background:
With regard to a single FormRegion, Microsoft instructs the following:

Replace the definition of the FormRegionHookup class with the following
code. This code implements the
Microsoft.Office.Interop.Outlook.FormRegionStartup interface, and applies the
ComVisibleAttribute, GuidAttribute, ProgIdAttribute, and
ClassInterfaceAttribute attributes to the FormRegionHookup class.

[ComVisible(true),
Guid("88F7BFBE-7666-4a0c-BCFD-2740E6625E04"),
ProgId("FormRegionAddIn.FormRegionHookup"),
ClassInterface(ClassInterfaceType.AutoDual)]
public class FormRegionHookup : Outlook.FormRegionStartup

Question:
If I have 2 FormRegions that I have created and I have 2 classes where each
class extends the Outlook.FormRegionStartup interface.

1. Do I use the same GUID for both classes?

Guid("88F7BFBE-7666-4a0c-BCFD-2740E6625E04")

My gut answer to this question is "Yes", but I just want to make sure.
 
P

pkelley

Worse yet, my "ThisAddIn" class only has 1 "protected override object
RequestService(Guid serviceGuid)" method.

We are taught to write:

if (serviceGuid ==
typeof(Microsoft.Office.Interop.Outlook.FormRegionStartup).GUID)
{
// Instantiate your form here.
myForm = new myFormRegionHookup();
myForm2 = new myForm2RegionHookup();

// Then return your form to the caller. Yeah, but which form???
return ???;
}
 
P

pkelley

Solved these problems:

The FormRegion you return from "RequestService()" will define the
"FormRegionName" used in the call to "GetFormRegionStorage()".

Since I have 2 FormRegions, and since "RequestService()" gets called once
for each FormRegion in my AddIn, I just keep track of which FormRegion I
return from "RequestService()" using a boolean variable, like this:

// Return the "m_form1" on the first pass and the
// "m_form2" on the next pass.
if (!m_form1Returned)
{
m_form1Returned = true;
return m_form1;
}
else
{
return m_form2;
}

pkelley said:
Worse yet, my "ThisAddIn" class only has 1 "protected override object
RequestService(Guid serviceGuid)" method.

We are taught to write:

if (serviceGuid ==
typeof(Microsoft.Office.Interop.Outlook.FormRegionStartup).GUID)
{
// Instantiate your form here.
myForm = new myFormRegionHookup();
myForm2 = new myForm2RegionHookup();

// Then return your form to the caller. Yeah, but which form???
return ???;
}

pkelley said:
My setup:
Windows XP, Microsoft Visual Studio 2005, using VSTO SE, developing in C#.

Question background:
With regard to a single FormRegion, Microsoft instructs the following:

Replace the definition of the FormRegionHookup class with the following
code. This code implements the
Microsoft.Office.Interop.Outlook.FormRegionStartup interface, and applies the
ComVisibleAttribute, GuidAttribute, ProgIdAttribute, and
ClassInterfaceAttribute attributes to the FormRegionHookup class.

[ComVisible(true),
Guid("88F7BFBE-7666-4a0c-BCFD-2740E6625E04"),
ProgId("FormRegionAddIn.FormRegionHookup"),
ClassInterface(ClassInterfaceType.AutoDual)]
public class FormRegionHookup : Outlook.FormRegionStartup

Question:
If I have 2 FormRegions that I have created and I have 2 classes where each
class extends the Outlook.FormRegionStartup interface.

1. Do I use the same GUID for both classes?

Guid("88F7BFBE-7666-4a0c-BCFD-2740E6625E04")

My gut answer to this question is "Yes", but I just want to make sure.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top