Hooking into window proc for inspector window

Add-in Express™ Support Service
That's what is more important than anything else

Hooking into window proc for inspector window
Hooking into window proc for inspector window 
Pino Carafa




Posts: 162
Joined: 2016-09-28
Hello Add-in Express. Would you perhaps have a simple VB.NET example showing how to do this?
Posted 18 Oct, 2019 08:32:33 Top
Andrei Smolin


Add-in Express team


Posts: 18823
Joined: 2006-05-11
Hello Pino,

No, we don't have it. Such an example cannot be small and simple. Are you sure you really need to subclass the Inspector window? What do you need to achieve?


Andrei Smolin
Add-in Express Team Leader
Posted 18 Oct, 2019 08:45:29 Top
Pino Carafa




Posts: 162
Joined: 2016-09-28
Hello Andrei - in light of my recent issues with PropertyAccessors..... I have an external Executable that deals with our Case Management System. From that Executable the user can choose to Email. When they do that, I try to get the currently active Outlook.Application (if none present I Create it anew at that point), and from there I do CreateItem and I Activate the Inspector.

Before all my recent "troubles" I would simply go to the PropertyAccessor of the new MailItem and I would set the CaseReference property that you'll remember from my previous question. I would now like to avoid doing that, and instead set new Properties on the ADXOlForm

I would imagine that from my Executable I cannot get a handle on that ADXOlForm, so I was hoping I could use PostMessage or SendMessage to send the CaseReference to the Inspector window instead and hook into its Window Proc to pick it up. After that I can use the functionality we already hammered out in the previous Topic.

I noticed I could Override the WndPrc on the ADXOlForm but of course that has its own hWnd which is not the same as the Inspector's

This is not urgent. Would just be "nice to have" :)
Posted 18 Oct, 2019 10:57:42 Top
Andrei Smolin


Add-in Express team


Posts: 18823
Joined: 2006-05-11
Hello Pino,

Your application can communicate with your Outlook add-in loaded in that Outlook application.

OutlookApp.COMAddins.Item(strMyComAddinProgId).Object.MyPublicPropertyOrMethod.

1. strMyComAddinProgId - see the ProgId attribute of your add-in module.
2. MyPublicPropertyOrMethod is called via late binding (see System.Type.InvokeMember in MSDN or search through our forums)

See also http://www.add-in-express.com/creating-addins-blog/2010/07/02/standalone-application-addin-communicate/.


Andrei Smolin
Add-in Express Team Leader
Posted 21 Oct, 2019 03:42:40 Top
Pino Carafa




Posts: 162
Joined: 2016-09-28
Ok.... It sounds very promising indeed, but I have a small problem...

I get as far as this
TryCast(oOutlook, Microsoft.Office.Interop.Outlook.Application).COMAddIns.Item("KeyhouseOutlookAddin.AddinModule")

But the object returned doesn't appear to give the the option to connect to my method. Also, when I check the TypeName of the .Object it returns "IDTExtensibility2" rather than my AddinModule type name?
Posted 21 Oct, 2019 05:55:24 Top
Andrei Smolin


Add-in Express team


Posts: 18823
Joined: 2006-05-11
You've missed .Object:

TryCast(oOutlook, Microsoft.Office.Interop.Outlook.Application).COMAddIns.Item("KeyhouseOutlookAddin.AddinModule").Object.MyMethod()

MyMethod() is called via late binding.


Andrei Smolin
Add-in Express Team Leader
Posted 21 Oct, 2019 06:01:57 Top
Pino Carafa




Posts: 162
Joined: 2016-09-28
Ahhhhhhhhhh .Object.COMAddinObj...

Ok I think I'm getting there.
Posted 21 Oct, 2019 06:04:35 Top
Pino Carafa




Posts: 162
Joined: 2016-09-28
No... I'm not.

Ok. Let's say I do this
Dim oTest as Object

oTest = TryCast(oOutlook, Microsoft.Office.Interop.Outlook.Application).COMAddIns.Item("KeyhouseOutlookAddin.AddinModule")

oTest.DoAboutBox()
"Public member 'DoAboutBox' on type 'COMAddIn' not found"

oTest.Object.DoAboutBox()
"Public member 'DoAboutBox' on type 'IDTExtensibility2' not found"

oTest.GetType().InvokeMember("DoAboutBox", System.Reflection.BindingFlags.InvokeMethod, Nothing, oTest, Nothing)
"Unknown Name.(Exception from HRESULT: 0x80020006 (DISP_E_UNKNOWNNAME))"

oTest.Object.GetType().InvokeMember("DoAboutBox", System.Reflection.BindingFlags.InvokeMethod, Nothing, oTest.Object, Nothing)
"Unknown Name" again

I think the problem is that oTest.Object gives me an object of type IDTExtensibility2, instead of KeyhouseOutlookAddin.AddinModule ...
Posted 21 Oct, 2019 06:22:29 Top
Pino Carafa




Posts: 162
Joined: 2016-09-28
Ok never mind! There must be something wrong in DoAboutBox(). I just created a brand new Public Sub SayHello() on "KeyhouseOutlookAddin.AddinModule" and

oTest.Object.SayHello()

works perfectly. All good, so!
Posted 21 Oct, 2019 06:48:46 Top
Andrei Smolin


Add-in Express team


Posts: 18823
Joined: 2006-05-11
Great!


Andrei Smolin
Add-in Express Team Leader
Posted 21 Oct, 2019 07:20:30 Top